The LinkAllPasses.h file is included in several main programs, to force
a large number of passes to be linked in. However, the ForcePassLinking
constructor uses undefined behavior, since it calls member functions on
nullptr, e.g.:
((llvm::Function*)nullptr)->viewCFGOnly(); llvm::RGPassManager RGM; ((llvm::RegionPass*)nullptr)->runOnRegion((llvm::Region*)nullptr, RGM);
When the optimization level is -O2 or higher, the code below the first
nullptr dereference is optimized away, and replaced by ud2 (on x86).
Therefore, the calls after that first dereference are never emitted. In
my case, I noticed there was no call to llvm::sys::RunningOnValgrind()!
Replace these two instances of nullptr by 1, which is ugly, but at
least defined, and accomplishes the goal of emitting the desired
references.