This is an archive of the discontinued LLVM Phabricator instance.

[Assignment Tracking] Fix assertion in AssignmentTrackingPass::runOnFunction
ClosedPublic

Authored by Orlando on Apr 12 2023, 3:03 AM.

Details

Summary

The assertion exists to ensure all variables passed into trackAssignments end up with dbg.assigns associated with their backing allocas. The assertion compared the passed-in and tracked variables using DebugVariable, which includes the fragment as part of the variable identity.

It is possible for the backing alloca to be smaller than a variable (see test case). In this case the input variable (Var X, no fragment, no InlinedAt) isn't equal to the dbg.assign variable (Var X, some fragment, no InlinedAt). To cover this case the assertion now ignores fragments through the use of DebugVariableAggregate.

Diff Detail

Event Timeline

Orlando created this revision.Apr 12 2023, 3:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 3:03 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Orlando requested review of this revision.Apr 12 2023, 3:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 3:03 AM
jmorse accepted this revision.Apr 12 2023, 3:35 AM

LGTM, with nit

llvm/lib/IR/DebugInfo.cpp
2035

It's worth dropping a comment here indicating why you've used DebugVariableAggregate instead of DebugVariable, to let the reader work out that the fragment can be changed by AT.

This revision is now accepted and ready to land.Apr 12 2023, 3:35 AM
This revision was automatically updated to reflect the committed changes.
Orlando marked an inline comment as done.