[LLVMdev] Optimization passes and debug info

Matthijs Kooijman matthijs at stdin.nl
Tue Jul 8 03:33:42 PDT 2008


Hi all,

I've been fiddling around with debug info generated by clang, with the goal of
propagating line number info to our custom backend (which is not an llvm
backend, but does use llvm IR as its input).

I've created a small pass which strips all debug info except for stop points,
which are currently the only things we're interested in. Leaving only stop
points in actually works surprisingly well, most transformation passes keep
doing their work properly.

In our particular case, we found that SimplifyCFG fails to merge to basic
blocks. There is one basic block, which only contains a few phi nodes and an
unconditional branch. Normally, this block would be merged into its successor
(when it does not cause conflicts in the phi nodes). However, when debugging
info is enabled, a stop point shows up in this block. We really need to have
this block simplified away, but SimplifyCFG currently doesn't know about
stop points so leaves it be.

It would be simple to tell SimplifyCFG, for this particular transformation,
that a near-empty basic block (which can currently only contain phi nodes and
a single unconditional branch) can also contain stop points. This would simply
propagate the phi nodes where needed and throw away the stop point (which
really can't be propagated anywhere).

If your focus is on the optimizations, this is the right way to go (this
allows one to debug an optimized binary). However, the removal of the stop
point does slightly degrade the debugging capabilities (this particular case
mostly means you can't break just before a loop that's directly preceded by other
control flow). The debugging information will not become incorrect, only
incomplete.

If your focus is on getting complete debugging information, you would simply
not want to do this transformation, so you preserve all debugging
capabilities.


From this observation, I think it might be useful to have some kind of global
flag that tells transformations whether it is allowed to remove debugging code
in favour of optimizations. When we start making transformation passes
debug-info aware, I think the need for something like this might increase.

Gr.

Matthijs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080708/1fcddbf8/attachment.sig>


More information about the llvm-dev mailing list