This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Handle stack slot offsets for spilled sub-registers in LDV
ClosedPublic

Authored by dstenb on Sep 4 2018, 2:00 AM.

Details

Summary

Extend LDV so that stack slot offsets for spilled sub-registers
are added to the emitted debug locations. This is accomplished
by querying InstrInfo::getStackSlotRange().

With this change, LDV will add a DW_OP_plus_uconst operation to
the expression if a sub-register is spilled. Later on, PEI will
add an offset operation for the stack slot, meaning that we will
get expressions of the forms:

  • {DW_OP_constu #fp-offset, DW_OP_minus, DW_OP_plus_uconst #subreg-offset}
  • {DW_OP_plus_const #fp-offset, DW_OP_minus, DW_OP_plus_uconst #subreg-offset}

The two offset operations should ideally be merged.

Diff Detail

Event Timeline

dstenb created this revision.Sep 4 2018, 2:00 AM
bjope added a subscriber: bjope.Sep 4 2018, 2:32 AM

The best place to do the simplification / constant-folding in the DIExpresssion is in DwarfExpression.cpp, just before it gets emitted.

lib/CodeGen/LiveDebugVariables.cpp
1222

The DW_OP_deref is not already part of the expression if Loc.wasIndirect()?

test/CodeGen/PowerPC/live-debug-vars-subreg-offset.ll
43

Nice testcase! You can reduce it even further by setting all of the !dbg locations to the same location.

aprantl accepted this revision.Sep 4 2018, 8:48 AM
This revision is now accepted and ready to land.Sep 4 2018, 8:48 AM
dstenb added a comment.Sep 5 2018, 1:22 AM

The best place to do the simplification / constant-folding in the DIExpresssion is in DwarfExpression.cpp, just before it gets emitted.

Okay! I'll look into putting together a separate patch for that.

lib/CodeGen/LiveDebugVariables.cpp
1222

As far as I have understood it, the locations that are covered by "WasIndirect" are the indirect (reg+offset) DBG_VALUEs, which if they are not spilled are as the indirect DW_OP_*breg* operations, so they will not have a DW_OP_deref beforehand.

test/CodeGen/PowerPC/live-debug-vars-subreg-offset.ll
43

Good idea!

dstenb added inline comments.Sep 5 2018, 1:24 AM
lib/CodeGen/LiveDebugVariables.cpp
1222

s/spilled are as/will be emitted as/

dstenb updated this revision to Diff 163979.Sep 5 2018, 1:25 AM

Removed unnecessary !dbg locations in the test. I also moved the file to test/DebugInfo/.

dstenb added a comment.Sep 6 2018, 6:39 AM

Thanks for the review! I'll submit this tomorrow when I have time to track the build bots.

This revision was automatically updated to reflect the committed changes.