Juneyoung Lee, Chung-Kil Hur, Ralf Jung, Zhengyang Liu, John Regehr, Nuno P. Lopes
LLVM miscompiles certain programs in C, C++, and Rust that use low-level language features such as raw pointers in Rust or conversion between integers and pointers in C or C++. The problem is that it is difficult for the compiler to implement aggressive, high-level memory optimizations while also respecting the guarantees made by the programming languages to low-level programs. A deeper problem is that the memory model for LLVM's intermediate representation (IR) is informal and the semantics of corner cases are not always clear to all compiler developers.
We developed a novel memory model for LLVM IR and formalized it. The new model requires a handful of problematic IR-level optimizations to be removed, but it also supports the addition of new optimizations that were not previously legal. We have implemented the new model and shown that it fixes known memory-model-related miscompilations without impacting the quality of generated code.
J. Lee, C. Hur, R. Jung, Z. Liu, J. Regehr, N. P. Lopes. Reconciling High-Level Optimizations and Low-Level Code in LLVM. Proc. of the ACM on Programming Languages, Volume 2 Issue OOPSLA, Nov. 2018.
@article{llvmmem-oopsla18, title = {Reconciling {High-Level} Optimizations and {Low-Level} Code in {LLVM}}, author = {Juneyoung Lee and Chung-Kil Hur and Ralf Jung and Zhengyang Liu and John Regehr and Nuno P. Lopes}, journal = {Proc. of the ACM on Programming Languages}, volume = {2}, number = {OOPSLA}, publisher = {ACM}, doi = {10.1145/3276495}, month = nov, year = 2018 }
© The Authors, 2018. This is the author's version of the work. It is posted here for your personal use. Not for redistribution.