[llvm] [CodeGen] Fix stale LiveIntervals regmask tables after MachineBasicBl… (PR #209610)

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 29 14:48:44 PDT 2026


================
@@ -281,11 +281,20 @@ class LiveIntervals {
     return Indexes->getMBBFromIndex(index);
   }
 
-  void insertMBBInMaps(MachineBasicBlock *MBB) {
-    Indexes->insertMBBInMaps(MBB);
-    assert(unsigned(MBB->getNumber()) == RegMaskBlocks.size() &&
-           "Blocks must be added in order.");
-    RegMaskBlocks.push_back(std::make_pair(RegMaskSlots.size(), 0));
+  /// Add \p MBB to the SlotIndexes and regmask maps. \p MBB is normally a
+  /// fresh, empty block and is recorded as having no regmask slots. A caller
+  /// that inserts a block already populated with regmask-bearing instructions
+  /// should call splitAt() instead (which also fixes up the regmask table), or
+  /// pass \p AssumeRegMaskEmpty = false and fix up the table itself.
+  void insertMBBInMaps(MachineBasicBlock *MBB, bool AssumeRegMaskEmpty = true);
----------------
qcolombet wrote:

My ask was slightly different:
I don't want external users to use the `AssumeRegMaskEmpty` argument.
Hence, we keep the unchanged `insertMBBInMaps` as in and introduce a `insertMBBInMapsImpl` that is private and that has this additional argument.

https://github.com/llvm/llvm-project/pull/209610


More information about the llvm-commits mailing list