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

Jianjian Guan via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 19 23:12:44 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;
+    }
----------------
jacquesguan wrote:

Would it insert more than 1 MBB? I am not sure how should we set the MF iterator to make it at the first inserted MBB's iteration.

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


More information about the llvm-commits mailing list