News for hackers. Stuff that matters.
Re:Clang vs. Clang by pclmulqdq on Sunday August 04, 2024 @02:24PM (#41155373)
Most architectures have a subset of their instructions that can be called in constant time (constant time meaning data-independent time). Things like non-constant pointer loads and branches are obviously out, and so are div/mod in almost all chips, but other arithmetic and conditional moves are in that set.

CPUs are actually much better at making those guarantees than compilers are.

Re:Clang vs. Clang by rbanffy on Monday August 05, 2024 @04:30AM (#41159191)
If you tell the compiler, it can generate code with only those instructions.
Re:Clang vs. Clang by ynik on Monday August 05, 2024 @05:56AM (#41159626)
That's no longer true: https://www.intel.com/content/www/us/en/developer/articles/t... x86 hardware does not guarantee anything unless you enable "Data Operand Independent Timing Mode", which is disabled by default and AFAIK can only be enabled by kernel-level code. So unless operating systems grow new syscalls to enable this mode, you're just out of luck on modern hardware.
Re:Clang vs. Clang by pclmulqdq on Monday August 05, 2024 @06:30AM (#41159795)
In the most purely theoretical sense, you are correct, but everything Intel and AMD has said indicates they will still offer strong guarantees on the DOIT instructions:

https://lore.kernel.org/all/851920c5-31c9-ddd9-3e2d-57d379aa...

In other words, they have announced the possibility of breaking that guarantee years before touching it, which is something the clang developers would never do.