[llvm] 862d822 - [CodeGen] Don't renumber invalid domtree (#102427)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 23:53:48 PDT 2024


Author: Alexis Engelke
Date: 2024-08-08T08:53:45+02:00
New Revision: 862d822d83a5422e6cc966c3244e766dee6d45ba

URL: https://github.com/llvm/llvm-project/commit/862d822d83a5422e6cc966c3244e766dee6d45ba
DIFF: https://github.com/llvm/llvm-project/commit/862d822d83a5422e6cc966c3244e766dee6d45ba.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/CodeGen/MachineBlockPlacement.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index 9010c3cfc42477..be783bc4e29738 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -3649,7 +3649,11 @@ void MachineBlockPlacement::assignBlockOrder(
     const std::vector<const MachineBasicBlock *> &NewBlockOrder) {
   assert(F->size() == NewBlockOrder.size() && "Incorrect size of block order");
   F->RenumberBlocks();
-  MPDT->updateBlockNumbers();
+  // At this point, we possibly removed blocks from the function, so we can't
+  // renumber the domtree. At this point, we don't need it anymore, though.
+  // TODO: move this to the point where the dominator tree is actually
+  // invalidated (i.e., where blocks are removed without updating the domtree).
+  MPDT = nullptr;
 
   bool HasChanges = false;
   for (size_t I = 0; I < NewBlockOrder.size(); I++) {


        


More information about the llvm-commits mailing list