This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Fix fragment offset emission order for symbol locations
ClosedPublic

Authored by dstenb on Jan 25 2018, 4:16 AM.

Details

Summary

When emitting the location for a global variable with fragmented debug
expressions, make sure that the offset pieces, which represent
optimized-out parts of the variable, are emitted before their succeeding
fragments' expressions. Previously, if the succeeding fragment's
location was a symbol, the offset piece was emitted after, rather than
before, that symbol's expression. This effectively meant that the symbols
were associated with the wrong parts of the variable.

This fixes PR36085.

Diff Detail

Repository
rL LLVM

Event Timeline

dstenb created this revision.Jan 25 2018, 4:16 AM
JDevlieghere added inline comments.Jan 26 2018, 4:11 AM
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
232 ↗(On Diff #131414)

Just from looking at the code, as neither Expr nor DwarfExpr are used in the if-clause above, can we move up this part too?

dstenb added inline comments.Jan 26 2018, 4:36 AM
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
232 ↗(On Diff #131414)

The current order needs to be kept for the case where Expr is a DW_OP_LLVM_fragment expression. If we are dealing with a fragment expression, and we emit a symbol location in the if (Global) clause, then the piece resulting from the fragment expression must be emitted after that. This situation can be seen for the fragments corresponding to the bar and qux fields in the attached reproducer.

I don't if there are other cases where the emission order of the symbol location and Expr matters.

aprantl accepted this revision.Jan 26 2018, 9:14 AM

Good catch!

This revision is now accepted and ready to land.Jan 26 2018, 9:14 AM
This revision was automatically updated to reflect the committed changes.

I submitted this for David.

JDevlieghere added inline comments.Jan 29 2018, 6:43 AM
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
232 ↗(On Diff #131414)

Thanks for the explanation!