Skip to content

Commit 862d822

Browse files
authored
[CodeGen] Don't renumber invalid domtree (#102427)
Machine block placement might remove nodes from the function but does not update the dominator tree accordingly. Instead of renumbering (which might crash due to accessing removed blocks), set the domtree to null to make clear that it is invalid at this point. Fixup of #102107.
1 parent 3606d69 commit 862d822

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/lib/CodeGen/MachineBlockPlacement.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3649,7 +3649,11 @@ void MachineBlockPlacement::assignBlockOrder(
36493649
const std::vector<const MachineBasicBlock *> &NewBlockOrder) {
36503650
assert(F->size() == NewBlockOrder.size() && "Incorrect size of block order");
36513651
F->RenumberBlocks();
3652-
MPDT->updateBlockNumbers();
3652+
// At this point, we possibly removed blocks from the function, so we can't
3653+
// renumber the domtree. At this point, we don't need it anymore, though.
3654+
// TODO: move this to the point where the dominator tree is actually
3655+
// invalidated (i.e., where blocks are removed without updating the domtree).
3656+
MPDT = nullptr;
36533657

36543658
bool HasChanges = false;
36553659
for (size_t I = 0; I < NewBlockOrder.size(); I++) {

0 commit comments

Comments
 (0)