This is an archive of the discontinued LLVM Phabricator instance.

[Utils] Insert DW_OP_bit_piece when only describing part of the variable
ClosedPublic

Authored by loladiro on Jan 11 2016, 5:38 AM.

Details

Summary

The dbg.declare -> dbg.value conversion looks through any zext/sext to find a value to describe the variable (in the expectation that those zext/sext instruction will go away later). However, those values do not cover the entire variable and thus need a DW_OP_bit_piece.

Diff Detail

Repository
rL LLVM

Event Timeline

loladiro updated this revision to Diff 44474.Jan 11 2016, 5:38 AM
loladiro retitled this revision from to [Utils] Insert DW_OP_bit_piece when only describing part of the variable.
loladiro updated this object.
loladiro added a reviewer: aprantl.
loladiro set the repository for this revision to rL LLVM.
loladiro added a subscriber: llvm-commits.
aprantl added inline comments.Jan 11 2016, 8:56 AM
lib/Transforms/Utils/Local.cpp
1061 ↗(On Diff #44474)

It's not clear to me that a sign/zero-extended value always indicates that the value is a subset of the variable. Is that guaranteed? Note that the Verifier checks that a piece does not cover the entire variable.

test/Transforms/Util/split-bit-piece.ll
1 ↗(On Diff #44474)

SORA can create bit pieces, but in this case I assume it's Local that is supposed to generate the bit piece?

14 ↗(On Diff #44474)

Please also check for the fist argument of the dbg.value so it is clear what the assumptions about the lowering are. This will help us keeping the test useful in the future.

loladiro added inline comments.Jan 11 2016, 9:20 AM
lib/Transforms/Utils/Local.cpp
1061 ↗(On Diff #44474)

Yes, I think that's guaranteed. sext/zext guarantee that they expand from a smaller to a larger value, and if the IR was correct before, then the extended value would cover the entire variable, so this should be smaller. One case that does occur to me however, is where the expression already contains a DW_OP_bit_piece. In that case we'll have to update the existing one.

test/Transforms/Util/split-bit-piece.ll
1 ↗(On Diff #44474)

Well, SORA calls the Local util, but I'll make the comment more clear.

14 ↗(On Diff #44474)

Ok.

loladiro updated this revision to Diff 44553.Jan 11 2016, 2:05 PM
  • Fix the case where the expression already is a bit piece
  • Update comment explaining what the test is testing
  • Check for the first argument of the llvm.dbg.value call
aprantl accepted this revision.Jan 12 2016, 12:58 PM
aprantl edited edge metadata.

Accepted with minor comments.

lib/Transforms/Utils/Local.cpp
1056 ↗(On Diff #44553)

Please add a comment explaining why and why the piece has to be smaller than the variable.
Nitpick: the clang coding standards prefer full sentences as comments, with a trailing '.'.

This revision is now accepted and ready to land.Jan 12 2016, 12:58 PM
This revision was automatically updated to reflect the committed changes.