News for hackers. Stuff that matters.
Re:Exploiting Undefined Behavior in C/C++ Programs: The Perf... by mwkaufma on Friday April 25, 2025 @12:58PM (#43795976)
Reading e.g. the 13% perf regression in simdjson from disabling UB:

  A simpler alternative is to compile the program with LTO. We confirmed that LLVM’s inter-procedural analyses can propagate both alignment and dereferenceability information for this function, which allows the LTO build to recover the performance loss.
"can" is doing a lot of heavy-lifting here. Guaranteeing expected optimizations "will" be applied are hard-enough, without leaving it entirely to an easily-derailed indirect side-effect.
Re:Exploiting Undefined Behavior in C/C++ Programs: The Perf... by UebVar on Friday April 25, 2025 @01:25PM (#43796294)
This is "can" has exactly the same meaning as in "UB can make your programms faster". You could replace it with "it does, at least with clang". LTO is, in this regard, the same as UB, and unlike guaranteed optimizations, such as the single member optimization, or the empty base optimization.
Re:Exploiting Undefined Behavior in C/C++ Programs: The Perf... by mwkaufma on Friday April 25, 2025 @01:56PM (#43796655)
Concretely, here, the UB-exploitation in question in this case is assuming that the "this" pointer in C++ is aligned and non-null, meaning it's a pervasive annotation throughout C++ codebases, not an edge-case.

Relying on LTO to "discover" this annotation through interprocedural analysis -- based on my experience of looking at LTO in practice -- will not be as comprehensive, and even when it works it accomplishes its task in an achingly-slow and expensive way.

This is a real devil-is-in-the-details case.

Re:Exploiting Undefined Behavior in C/C++ Programs: The Perf... by quotemstr on Friday April 25, 2025 @03:49PM (#43797876)
I love when papers disagree with their own abstracts.