Skip to content
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

[DebugInfo][RemoveDIs] Assert if we mix PHIs and debug-info #84054

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions llvm/lib/IR/Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ void Instruction::insertBefore(BasicBlock &BB,
if (!InsertAtHead) {
DPMarker *SrcMarker = BB.getMarker(InsertPos);
if (SrcMarker && !SrcMarker->empty()) {
// If this assertion fires, the calling code is about to insert a PHI
// after debug-records, which would form a sequence like:
// %0 = PHI
// #dbg_value
// %1 = PHI
// Which is de-normalised and undesired -- hence the assertion. To avoid
// this, you must insert at that position using an iterator, and it must
// be aquired by calling getFirstNonPHIIt / begin or similar methods on
// the block. This will signal to this behind-the-scenes debug-info
// maintenence code that you intend the PHI to be ahead of everything,
// including any debug-info.
assert(!isa<PHINode>(this) && "Inserting PHI after debug-records!");
adoptDbgValues(&BB, InsertPos, false);
}
}
Expand Down
Loading