This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Omit location list entries with empty ranges
ClosedPublic

Authored by dstenb on Dec 20 2018, 2:51 AM.

Details

Summary

This fixes PR39710. In that case we emitted a location list looking like
this:

.Ldebug_loc0:

.quad   .Lfunc_begin0-.Lfunc_begin0
.quad   .Lfunc_begin0-.Lfunc_begin0
.short  1                       # Loc expr size
.byte   85                      # DW_OP_reg5
.quad   .Lfunc_begin0-.Lfunc_begin0
.quad   .Lfunc_end0-.Lfunc_begin0
.short  1                       # Loc expr size
.byte   85                      # super-register DW_OP_reg5
.quad   0
.quad   0

As seen, the first entry's beginning and ending addresses evalute to 0,
which meant that the entry inadvertently became a "end of list" entry,
resulting in the location list ending sooner than expected.

To fix this, omit all entries with empty ranges. Location list entries
with empty ranges do not have any effect, as specified by DWARF, so we
might as well drop them:

"A location list entry (but not a base address selection or end of list
entry) whose beginning and ending addresses are equal has no effect
because the size of the range covered by such an entry is zero."

Diff Detail

Event Timeline

dstenb created this revision.Dec 20 2018, 2:51 AM
aprantl accepted this revision.Dec 20 2018, 9:00 AM

Looks generally good to me.

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
1188

why not just move the condition two lines further down?

This revision is now accepted and ready to land.Dec 20 2018, 9:00 AM
dstenb marked an inline comment as done.Jan 7 2019, 6:48 AM
dstenb added inline comments.
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
1188

Sorry for the late response due to the holiday season!

I'm not sure I follow. Do you mean to merge this code with the DIExpr->isFragment() code at line 1198 somehow?

aprantl added inline comments.Jan 7 2019, 9:52 AM
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
1188

Yeah, this code block looks like it is repeated further down below and I was wondering if it could be simplified / deduplicated.

dstenb marked an inline comment as done.Jan 8 2019, 7:50 AM
dstenb added inline comments.
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
1188

If it is okay for you, I think I prefer bailing out early like this at the cost of that code duplication, in order to avoid creating an unused DebugLocEntry object, and dealing with the DebugLoc.back().MergeValues(Loc) invocation in that conditional, as I think that might make the code a bit harder to understand.

aprantl added inline comments.Jan 8 2019, 8:15 AM
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
1188

sure, your call.

This revision was automatically updated to reflect the committed changes.