Debug info not preserved by llvm-as (LLParser)?

Hi there,

If I run:

clang -S -emit-llvm -o - -g test.c

for a trivial test.c I see debug info in the IR as expected. However, if I run:

clang -S -emit-llvm -o - -g test.c | llvm-as | llvm-dis

the debug info is stripped. Is this intentional? If so, is there a way to force the debug metadata to make its way through the pipeline? This is on either LLVM 3.5 or LLVM 3.4.

This has come up for me because I was hoping to provide IR in place of source code in a certain part of our application and while it works any unit tests that rely on debug info are broken. Tracking down the issue let me to this.

Peter Zion

(oops, dropped the ML by accident)

Hi David,

Indeed, I built stock 3.5.1 LLVM+Clang and the problem went away. Diffing the resulting IR I found that the clang I was using (stock Xcode ‘Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)’) was not including !llvm.module.flags with references to the DWARF and debug info versions. When I manually added this to the output from the Xcode Clang the problem went away; so I think it’s safe to assume that our compiler has the same problem as we are also not including the llvm.module.flags. Thanks for pointing me in the right direction!

Peter Zion