[llvm-dev] gberry at codeaurora.org

Jonas Paulsson via llvm-dev llvm-dev at lists.llvm.org
Fri May 4 02:56:35 PDT 2018


Hi,

I recently found myself in trouble because the crash I had disappeared 
with -g, so I could not debug the program. This happened because the 
optimizer did not remember to consider DBG_VALUEs instruction so it 
changed its behavior, and the bug went hiding.

I then started discussing this on https://reviews.llvm.org/D45878, and 
since this is something that should be handled by all different machine 
passes, the immediate question is now what utility functions should be 
made available for common use.

1. A pass such as MachineSink.cpp must first of all remember to consider 
DBG_VALUEs when iterating over instructions, so that it does not e.g. 
"break if next instruction is not X" and therefore change its results 
with -g.

2. At a second priority,

     a) it should handle DEBUG_VALUEs when moving / erasing MachineInstrs.

     b) it should " // Merge or erase debug location to ensure 
consistent stepping in profilers and debuggers." (MachineSink.cpp).

Well, this is in fact the first point here: I think this should be 
documented somewhere by a comment so that it is clear exactly how these 
things should be handled. My personal understanding right now is that 2 
is not vital but should be done on a best-effort basis. 1 however is 
really bad if it happens (which it currently does).

We are discussing where to place these utility functions, and if 
splice() should optionally be made to do this also. It seems that 
collectDebugValues() in MachineSink.cpp is a good starting point, but we 
probably want to do an even better search than just looking at the first 
def operand.

It would be nice to get some general feedback from the community at this 
point so we know which direction to take...

/Jonas




More information about the llvm-dev mailing list