[llvm-dev] Reviving the DebugIR pass

Dan Liew via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 21 11:19:02 PDT 2018


I recently had the need to see the correspondence between some Clang
generated LLVM IR and the compiled machine code within a debugger
(lldb in this case). Unfortunately it looks like the functionality to
do this used to be in a pass called 'DebugIR' but was removed due to
the lack of a maintainer [1].

It appears an attempt was made [2] to revive this but it appears to
have stalled.

I am very keen to see this feature land back in LLVM, so I'd either
like to take over [2] (only if the original author is no longer
interested) or rewrite the feature from scratch based on feedback on
what the community needs.

The use cases for this feature I see are:

* Debugging instrumentation inserted by LLVM passes. This is my use
case. I need to debug ASan instrumentation so looking at the original
source code in lldb is pretty useless because I can't see the
instrumentation. Looking at the LLVM IR on the otherhand is very
useful because I can see the ASan instrumentation at a (slightly)
higher level than the native machine code assembly.

* Debugging JIT'ed code. The LLVM IR that is JIT'ed might not come
from a higher level language and might be generated directly. In this
case the only debug information that makes sense is the LLVM IR
representation of the JIT'ed LLVM IR. This might be a bit tricky
though because there might not be an on disk representation of the

* Writing portions of a runtime in LLVM IR. This is not something I
advise doing but sometimes its necessary to write parts of a compiler
runtime in LLVM IR when it is difficult to write the equivalent code
in a higher level language. This is something I've had to do in KLEE
before because I couldn't get Clang to emit the LLVM IR in the precise
form that I wanted.

Debug information is not really my expertise but I'm happy to become
the code owner/maintainer of whatever implementation we end up with
(so that it doesn't get removed again) if necessary.

This work could also be used to fix [3]. Although this probably needs
more though because there's the question of whether we should preserve
existing debug information in an LLVM IR file or write over it when it
is given to Clang.

Any thoughts on this?

[1] https://reviews.llvm.org/rL222945
[2] https://reviews.llvm.org/D40778
[3] https://bugs.llvm.org/show_bug.cgi?id=35770


More information about the llvm-dev mailing list