Reapply bottom-up fast-isel, with several fixes for x86-32:
[oota-llvm.git] / lib / CodeGen / SelectionDAG / InstrEmitter.cpp
index d7d63d3dc67b78c48ed1ad3d6e9c9830205ea316..40fb3a46985ca6b332ea8d54a2df6e499f0ec127 100644 (file)
@@ -734,8 +734,13 @@ EmitMachineNode(SDNode *Node, bool IsClone, bool IsCloned,
   if (II.usesCustomInsertionHook()) {
     // Insert this instruction into the basic block using a target
     // specific inserter which may returns a new basic block.
-    MBB = TLI->EmitInstrWithCustomInserter(MI, MBB);
-    InsertPos = MBB->end();
+    bool AtEnd = InsertPos == MBB->end();
+    MachineBasicBlock *NewMBB = TLI->EmitInstrWithCustomInserter(MI, MBB);
+    if (NewMBB != MBB) {
+      if (AtEnd)
+        InsertPos = NewMBB->end();
+      MBB = NewMBB;
+    }
     return;
   }