Open Quuxplusone opened 10 years ago
Attached test.c
(110 bytes, text/x-csrc): Example source where mmu
variable metadata gets stripped after applying globalopt
I ran into this same issue on trunk. It seems GlobalOpt makes no efforts to preserve debug info on code that accesses global variables. In particular, in the case that GlobalOpt messes with the type of a global variable in TryToShrinkGlobalToBoolean(), GlobalOpt needs to replace all the loads and stores of the global with new loads and stores of the correct type. So it uses new LoadInst
and new StoreInst
to generate the new instructions and then erases the old ones, where it should be doing at least something like New->setDebugLoc(Old->getDebugLoc())
.
Elsewhere in LLVM, one can usually depend on LLVM transforms preserving at least line information for load and store instructions. This helps a lot with error reporting for sanitizers.
test.c
(110 bytes, text/x-csrc)Created attachment 12808 Example source where
mmu
variable metadata gets stripped after applying globaloptWhen using the globalopt optimization (every optimization level except O0) the debug metadata is partially removed, and there is no more reference to the global value inside the associated variable metadata. This interferes with any subsequent passes that might make use of such debug info.