This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][InstrRef] Avoid accidentally dropping fragment information during value propagation
ClosedPublic

Authored by jmorse on Nov 29 2021, 10:39 AM.

Details

Summary

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 / 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".

Diff Detail

Event Timeline

jmorse created this revision.Nov 29 2021, 10:39 AM
jmorse requested review of this revision.Nov 29 2021, 10:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2021, 10:39 AM
Orlando accepted this revision.Nov 30 2021, 2:06 AM

LGTM

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
2361

Does InScopeBlocks have any other uses? Can it be removed from vlocJoin parameter list etc?

This revision is now accepted and ready to land.Nov 30 2021, 2:06 AM
jmorse added inline comments.Nov 30 2021, 2:44 AM
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
2361

True, it can be killed off now

This revision was landed with ongoing or failed builds.Nov 30 2021, 3:33 AM
This revision was automatically updated to reflect the committed changes.