This is an archive of the discontinued LLVM Phabricator instance.

Fix PR32288
ClosedPublic

Authored by aprantl on Mar 15 2017, 4:01 PM.

Details

Summary

http://bugs.llvm.org/show_bug.cgi?id=32288

The DWARF generated by LLVM includes this location:

0x55 0x93 0x04
DW_OP_reg5 DW_OP_piece(4)

When GCC's DWARF is simply 0x55 (DW_OP_reg5) without the DW_OP_piece. I believe it's reasonable to assume the DWARF consumer knows which part of a register logically holds the value (low bytes, high bytes, how many bytes, etc) for a primitive value like an integer.

Diff Detail

Event Timeline

aprantl created this revision.Mar 15 2017, 4:01 PM

To review my own patch; I think we now have a coverage gap, since there is no testcase that tests a variable that is in a subregister at a nonzero offset.

... up until the point where I discover that I already created such a testcase a couple of months ago (llvm/test/DebugInfo/MIR/X86/bit-piece-dh.mir).

dblaikie accepted this revision.Mar 15 2017, 4:43 PM

Looks OK :)

lib/CodeGen/AsmPrinter/DwarfExpression.cpp
290–291

Is this ever true? What does that mean? (I guess it means there's no sub register at work? But that'd be handled by the below case too, right?)

Is this to improve legibility, then?

test/DebugInfo/X86/PR26148.ll
22

That's a bit confusing/interesting. (wonder what the rest of that location description now contains)

test/DebugInfo/X86/dw_op_minus_direct.ll
11–12

This one's interesting - because the register's not at the top level.

I would've expected the piece(4) would go against rax first, before the "- 1" & /could/ be relevant (a consumer might not know whether a register used in a complex location expression is the size of the destination value or not, etc)? But I guess it's probably OK?

This revision is now accepted and ready to land.Mar 15 2017, 4:43 PM
aprantl marked 2 inline comments as done.Mar 15 2017, 5:06 PM
aprantl added inline comments.
lib/CodeGen/AsmPrinter/DwarfExpression.cpp
290–291

Yes, that's the default for when nobody called setSubRegisterPiece() or reset it.

test/DebugInfo/X86/PR26148.ll
22

There's another 32-bit variable above it that now has a shorter expression.

test/DebugInfo/X86/dw_op_minus_direct.ll
11–12

That's an interesting edge-case, because the minus could underflow the upper part of rax and thus pollute the eax with garbage. We'd need to mask it out before the DW_OP_minus if we want this to be perfect.

aprantl marked 2 inline comments as done.Mar 16 2017, 9:47 AM

Landed together with a fix for dw_op_minus_direct.ll.

aprantl closed this revision.Mar 16 2017, 10:37 AM

r297965