[PATCH] D114727: [DebugInfo][InstrRef] Avoid accidentally dropping fragment information during value propagation

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 29 10:39:11 PST 2021


jmorse created this revision.
jmorse added reviewers: StephenTozer, Orlando, TWeaver.
Herald added a subscriber: hiraditya.
jmorse requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

A while back, the method `vlocJoin` was responsible for updating all variable location information at the entry point into a block. However, it was split into two parts:

- `vlocJoin` remained to check whether a PHI on block entry could be eliminated, and that incoming DIExpressions and indirect-ness agreed,
- `pickVPHILoc` identifies a location (i.e.. register) where a PHI could occur.

With rG102d2a8a9905 <https://reviews.llvm.org/rG102d2a8a99057b2f54ca97661f862e33d055171a> / D114578 <https://reviews.llvm.org/D114578>, we started tracking variable values that are assigned in out-of-scope blocks, which is what VarLocBasedLDV does. In VarLocBasedLDV, entry to such out-of-scope blocks is ignored because there are no instructions in scope and there's an assignment in the block anyway. Unfortunately, due to the split mentioned above, this led to:

- `vlocJoin` not updating the live-in DIExpression of such a block, but
- `pickVPHILoc` could find a location for a PHI if the parent blocks have a live-out value

Which meant we would accidentally not update DIExpression information on entry to a block, dropping fragment information, and creating a bogus DBG_VALUE, leading to an assertion failure.

Simple solution: delete the filter inherited from VarLocBasedLDV. We'll do slightly more work than necessary, but not a huge amount, and it'll be correct. I've added an assertion to check that all the block live-in variable locations we create have the correct fragment information, which should make this fail in a more clear manner in the future.

The attached test is reduced from some libcxx test that was crashing; the first block is in scope, two subsequent blocks are out of scope, all blocks assign to the variable in question "_First".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114727

Files:
  llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
  llvm/test/DebugInfo/MIR/InstrRef/out-of-scope-blocks.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114727.390401.patch
Type: text/x-patch
Size: 9386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211129/8a50960f/attachment.bin>


More information about the llvm-commits mailing list