This is an archive of the discontinued LLVM Phabricator instance.

[Assignment Tracking] Trunc fragments for stores to vars smaller than the alloca
ClosedPublic

Authored by Orlando on Apr 11 2023, 7:56 AM.

Details

Summary

In D147777 emitDbgAssign was fixed to discard assignments which touched any bits outside the bounds of a variable. This patch changes emitDbgAssign to discard assignments which touch bits only outside the variable bounds, and creates a truncated fragment expression for stores partially overlapping the variable. This is necessary because the alloca is interpreted as a store (of undef), meaning without this patch emitDbgAssign would discard the inital dbg.assign for a variable that is smaller than the alloca.

Diff Detail

Event Timeline

Orlando created this revision.Apr 11 2023, 7:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 7:56 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Orlando requested review of this revision.Apr 11 2023, 7:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 7:56 AM
jmorse accepted this revision.Apr 11 2023, 8:55 AM

LGTM with some fairly standard nits

llvm/lib/IR/DebugInfo.cpp
1854–1856

Can we assert this, for when it likely changes in the future and we forget this code?

1860

Seeing how both inputs are unsigned and one argument is zero, isn't this guaranteed to always be FragStartBit? (Could produce a warning somewhere)

llvm/test/DebugInfo/Generic/assignment-tracking/declare-to-assign/var-not-alloca-sized.ll
5–7

"looks right" is a bit too vague when someone has to update this test in the future, spelling it out a bit more would be better.

This revision is now accepted and ready to land.Apr 11 2023, 8:55 AM
Orlando updated this revision to Diff 512493.Apr 11 2023, 9:35 AM
Orlando marked 2 inline comments as done.

Thanks

+ Address nits + respond in-line

llvm/lib/IR/DebugInfo.cpp
1854–1856

That info would come from the VarRecord which doesn't yet support any kind of offset. We could add a "dummy" field to that struct and then assert that it is zero here, but I'm not sure that's much better than the VarStartBit = 0; below. wdyt?

1860

Yeah that's right, I was setting up for a future where it's not always zero. But good point about potential warning. I've replaced the line with a FIXME.

jmorse accepted this revision.Apr 11 2023, 9:59 AM

LGTM

llvm/lib/IR/DebugInfo.cpp
1854–1856

Ehhh, yeah, that's still going to require us to "just remember" what to change. It doesn't sound like adding an assertion will help.

1860

cool cool cool

This revision was landed with ongoing or failed builds.Apr 11 2023, 10:18 AM
This revision was automatically updated to reflect the committed changes.