Skip to content

Commit 034458b

Browse files
committed
[CodeGen][CodeLayout] Fix segfault on access to deleted block in MBP.
1 parent cd5c555 commit 034458b

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

llvm/lib/CodeGen/MachineBlockPlacement.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,13 +3212,9 @@ bool MachineBlockPlacement::maybeTailDuplicateBlock(
32123212
// Signal to outer function
32133213
Removed = true;
32143214

3215-
// Conservative default.
3216-
bool InWorkList = true;
32173215
// Remove from the Chain and Chain Map
32183216
if (auto It = BlockToChain.find(RemBB); It != BlockToChain.end()) {
3219-
BlockChain *Chain = It->second;
3220-
InWorkList = Chain->UnscheduledPredecessors == 0;
3221-
Chain->remove(RemBB);
3217+
It->second->remove(RemBB);
32223218
BlockToChain.erase(It);
32233219
}
32243220

@@ -3228,11 +3224,10 @@ bool MachineBlockPlacement::maybeTailDuplicateBlock(
32283224
}
32293225

32303226
// Handle the Work Lists
3231-
if (InWorkList) {
3232-
SmallVectorImpl<MachineBasicBlock *> &RemoveList = BlockWorkList;
3233-
if (RemBB->isEHPad())
3234-
RemoveList = EHPadWorkList;
3235-
llvm::erase(RemoveList, RemBB);
3227+
if (RemBB->isEHPad()) {
3228+
llvm::erase(EHPadWorkList, RemBB);
3229+
} else {
3230+
llvm::erase(BlockWorkList, RemBB);
32363231
}
32373232

32383233
// Handle the filter set

0 commit comments

Comments
 (0)