Skip to content

[CodeGen][CodeLayout] Fix segfault on access to deleted block in MBP. #142357

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 5 additions & 10 deletions llvm/lib/CodeGen/MachineBlockPlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3212,13 +3212,9 @@ bool MachineBlockPlacement::maybeTailDuplicateBlock(
// Signal to outer function
Removed = true;

// Conservative default.
bool InWorkList = true;
// Remove from the Chain and Chain Map
if (auto It = BlockToChain.find(RemBB); It != BlockToChain.end()) {
BlockChain *Chain = It->second;
InWorkList = Chain->UnscheduledPredecessors == 0;
Chain->remove(RemBB);
It->second->remove(RemBB);
BlockToChain.erase(It);
}

Expand All @@ -3228,11 +3224,10 @@ bool MachineBlockPlacement::maybeTailDuplicateBlock(
}

// Handle the Work Lists
if (InWorkList) {
SmallVectorImpl<MachineBasicBlock *> &RemoveList = BlockWorkList;
if (RemBB->isEHPad())
RemoveList = EHPadWorkList;
llvm::erase(RemoveList, RemBB);
if (RemBB->isEHPad()) {
llvm::erase(EHPadWorkList, RemBB);
} else {
llvm::erase(BlockWorkList, RemBB);
}

// Handle the filter set
Expand Down
Loading