llc and debug information

Hi all,

I’m having an issue with debug information and llc. A test program:

#include

using namespace std;

void foo() {
cout << "My return address is " << __builtin_return_address(0) <<
endl << flush;
}

int main(int argc, char *argv[]) {
foo();
return 0;
}

When I compile my test program to LLVM bytecode, and then use llc to take the bytecode to assembly, llc appears to strip the debugging information along the way:

llvm-g++ -g -c -emit-llvm test.cpp
llc test.o
g++ test.o.s
./a.out
My return address is 0x400b92
addr2line 0x400b92
??:0

My goal is to run a transformation pass on the bytecode to put in a few instrumentation hooks for a dynamic analysis I’m writing. Debug information, even if it’s a little off, would be extremely useful to have in the final binary. This build chain worked with a 2.6svn version of llc (that is, the final binary would have debug information which corresponded reasonably well to the source. Also it seemed to work when this question was sent http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-April/021697.html), but I recently upgraded to a 2.7svn version with the results above. Is this change intended? Is there a way tell llc to keep debug information in?

Thanks!
Nick

I always use -O0 together with -g because I had far too many problems
of the like already to define on the fly if it's safe or not *not* to
use it.

Maybe that helps...

cheers,
--renato

Reclaim your digital rights, eliminate DRM, learn more at
http://www.defectivebydesign.org/what_is_drm

try -O0 in llc command line.

Thanks for the quick responses, but unfortunately still no luck:

llvm-g++ -g -O0 -c -emit-llvm test.cpp
llc -O0 test.o
g++ test.o.s
./a.out
My return address is 0x400bb2
addr2line 0x400bb2
??:0

Also to further implicate llc, this works:

llvm-g++ -g -O0 -S test.cpp
g++ test.s
./a.out
My return address is 0x400bf9
addr2line 0x400bf9
/home/jalbert/llvmtest//test.cpp:13

Anymore thoughts?

-Nick

Nick Jalbert wrote:

Thanks for the quick responses, but unfortunately still no luck:

> llvm-g++ -g -O0 -c -emit-llvm test.cpp
> llc -O0 test.o
> g++ test.o.s
> ./a.out My return address is 0x400bb2
> addr2line 0x400bb2
??:0

Also to further implicate llc, this works:

> llvm-g++ -g -O0 -S test.cpp > g++ test.s > ./a.out My return address is 0x400bf9
> addr2line 0x400bf9
/home/jalbert/llvmtest//test.cpp:13

Anymore thoughts?

maybe try passing -disable-fp-elim to llc?

Ciao,

Duncan.

Figured out my problem, mailing the list in case anyone else runs into the same issue. I had updated the LLVM tools to the svn version, but not the front end. It seems that debugging information is handled differently with the latest version of the tools (perhaps as a result of this proposal?). I ended up grabbing a prerelease of llvm2.6 found here, and building both the front end and the LLVM tools from source. Using tools from a consistent period in time solved my problem–oops!

Thanks to everyone who tried to help out :).

-Nick