-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DebugInfo][RemoveDIs] Make dropping variable locations explicit #72399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3122,6 +3122,11 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, | |
} | ||
|
||
// Hoist the instructions. | ||
// In "RemoveDIs" non-instr debug-info mode, drop DPValues attached to these | ||
// instructions, in the same way that dbg.value intrinsics are dropped at the | ||
// end of this block. | ||
for (auto &It : make_range(ThenBB->begin(), ThenBB->end())) | ||
It.dropDbgValues(); | ||
BB->splice(BI->getIterator(), ThenBB, ThenBB->begin(), | ||
std::prev(ThenBB->end())); | ||
|
||
|
@@ -5179,6 +5184,15 @@ bool SimplifyCFGOpt::simplifyUnreachable(UnreachableInst *UI) { | |
|
||
bool Changed = false; | ||
|
||
// Ensure that any debug-info records that used to occur after the Unreachable | ||
// are moved to in front of it -- otherwise they'll "dangle" at the end of | ||
// the block. | ||
BB->flushTerminatorDbgValues(); | ||
|
||
// Debug-info records on the unreachable inst itself should be deleted, as | ||
// below we delete everything past the final executable instruction. | ||
UI->dropDbgValues(); | ||
Comment on lines
+5192
to
+5194
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't the DPValues on the unreachable come "before" it though? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They do, and it's arguable that we should keep them, however that's not what the current behaviour with dbg.values is -- the loop immediately below these lines iterates through and deletes any instructions that don't call/branch/signal etc, i.e. anything where it's inevitable that the unreachable will be hit. That includes dbg.values, which get deleted, which is what this addition preserves. |
||
|
||
// If there are any instructions immediately before the unreachable that can | ||
// be removed, do so. | ||
while (UI->getIterator() != BB->begin()) { | ||
|
@@ -5195,6 +5209,10 @@ bool SimplifyCFGOpt::simplifyUnreachable(UnreachableInst *UI) { | |
// block will be the unwind edges of Invoke/CatchSwitch/CleanupReturn, | ||
// and we can therefore guarantee this block will be erased. | ||
|
||
// If we're deleting this, we're deleting any subsequent dbg.values, so | ||
// delete DPValue records of variable information. | ||
BBI->dropDbgValues(); | ||
|
||
// Delete this instruction (any uses are guaranteed to be dead) | ||
BBI->replaceAllUsesWith(PoisonValue::get(BBI->getType())); | ||
BBI->eraseFromParent(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few lines up there's an ominous comment
// WARNING: keep in sync with InstCombinerImpl::visitUnreachableInst()!
- does anything over there need changing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, I believe it's covered by #72380 , not quite sure why I split these patches to be separate.