2019 EuroLLVM Developers’ Meeting: J. Lee “Safely Optimizing Casts between Pointers and Integers”

preview_player
Показать описание

Safely Optimizing Casts between Pointers and Integers - Juneyoung Lee (Seoul National University, Korea)


In this talk, a list of optimizations that soundly removes casts between pointers and integers will be presented. In LLVM, a pointer is more than just an integer: LLVM allows a pointer to track its underlying object, and the rule to find it is defined as based-on relation. This allows LLVM to aggressively optimize load/stores, but makes the meaning of pointer-integer casts complicated. This causes conflict between existing optimizations, causing long-standing miscompilation bugs like 34548.

To fix it, we suggest disabling folding of inttoptr(ptrtoint(p)) to p and using a safe workaround to remove them. This optimization is important because it's removing a significant portion of such cast pairs. We'll show that even if the optimization is disabled, majority of casts can be removed by carefully adding new \& modifying existing optimizations. After the updates, the performance is still comparable to the original LLVM.

Рекомендации по теме