I am trying to build a bytecode file with optimizations and debug information using llvm-gcc. Compiling with "-g" works fine, but when I add the optimizations flag, all debug information disappears. On the other hand, if I first "-emit-llvm" with "-g" and no optimizations, and then apply "opt -std-compile-opts", then debug information seems to be preserved. I have two questions: 1) The "Source Level Debugging with LLVM" documentation page states the following: "Compiling a program with "-O3 -g" gives you full debug information that is always available and accurate for reading [...]" Is this incorrect or am I missing something? What is causing the debug info to be wiped? 2) Are the llvm-gcc -O levels (e.g. -O1, -O2, etc.) approximately equivalent to the regular gcc -O levels, or are they really quite different? I couldn't find any recent discussion on this in the archives. Many thanks, Marc
Hi, running llvm-gcc with optimization turns off debug info. That is because the LLVM optimizers do not yet know how to deal with it well.> 1) The "Source Level Debugging with LLVM" documentation page states > the following: "Compiling a program with "-O3 -g" gives you full > debug information that is always available and accurate for reading > [...]" Is this incorrect or am I missing something? What is causing > the debug info to be wiped?It is not being generated in the first place. The above quote reflects a vision of the future and not present reality!> 2) Are the llvm-gcc -O levels (e.g. -O1, -O2, etc.) approximately > equivalent to the regular gcc -O levels, or are they really quite > different? I couldn't find any recent discussion on this in the > archives.In my experience -O2 is about the same, while gcc's -O3 and llvm-gcc's -O3 differ quite a lot. Your mileage may vary :) Ciao, Duncan.
Reasonably Related Threads
- Can we keep debug information of local variable when in the optimization condition?
- [LLVMdev] Pointer sizes, GetElementPtr, and offset sizes
- llc -O2 vs. llc -O3 --> same debug-pass=Executions but output.obj differs?
- Replicate Individual O3 optimizations
- [LLVMdev] Optimization passes and debug info