Exploiting Undefined Behavior in C/C++ Programs for Optimization: A Study on the(…)
summary
Demonstrates a large experiment using LLVM/Clang extensions to toggle 18 UB flags across 24 real applications (7M LOC) on Intel, AMD and ARM, measuring end-to-end effects. Shows a toy signed overflow optimization gives a 2x microbenchmark gain but that across real workloads the average runtime and binary-size changes are minimal, with ARM more sensitive. Builds flag implementations and three LLVM optimizer controls and finds most slowdowns are recovered with LTO or small optimizer fixes.
AI-written summary · about
chapters (13)
- 0:00Undefined behavior in C/C++
- 1:05Linux kernel bug from pointer deref
- 2:07Why UB exists for performance
- 3:31Signed integer overflow UB gains
- 5:19Categorizing UB in compilers
- 7:32Measuring UB optimization impact
- 8:56Experimental compiler flags
- 11:03Benchmark compilation process
- 11:23Binary size across architectures
- 12:48Performance on Intel and AMD CPUs
- 13:51Recovering performance without UB
- 14:53Security risks in UB semantics
- 15:39Conclusion and future
related talks
01h 30mDangerous Optimizations in C and C++ Programming Languages
01h 27mDangerous Optimizations! in C++ - Part Deux
18mDon't Look UB: Exposing Sanitizer-Eliding Compiler Optimizations
46m“My Little Optimizer: Undefined Behavior is Magic"
15mNot So Fast: Understanding and Mitigating Negative Impacts of Compiler Optimizations on Code Reuse G
33mUndefined Behavior in C++: What Every Programmer Should Know and Fear
45mA Few Effective gcc/clang Optimizations for Embedded Systems
49mUndefined Behavior in 2017 (part 1 of 2)
