[llvm] [FinalizelSel] Re-scan the MachineFunction if we insert a new MBB by custom insertion (PR #96046)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 02:15:04 PDT 2024


================
@@ -66,13 +67,19 @@ static std::pair<bool, bool> runImpl(MachineFunction &MF) {
         // The expansion may involve new basic blocks.
         if (NewMBB != MBB) {
           PreserveCFG = false;
-          MBB = NewMBB;
-          I = NewMBB->getIterator();
-          MBBI = NewMBB->begin();
-          MBBE = NewMBB->end();
+          InsertNewMBB = true;
+          break;
         }
       }
     }
+
+    ++I;
+
+    // If we insert a new MBB, we should re-scan to avoid missing some MI.
+    if (InsertNewMBB) {
+      I = MF.begin();
+      InsertNewMBB = false;
+    }
----------------
paperchalice wrote:

I'm not familiar with RISCV, IIUC the old behavior may skip the rest MIs in `I` if new blocks are inserted after `I`, and skipped MIs may need expansion. If so, can we check the next BB is the new BB to set iterators correctly?

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


More information about the llvm-commits mailing list