Fix fast-isel's handling of atomic instructions. They may
authorDan Gohman <gohman@apple.com>
Sat, 4 Oct 2008 00:56:36 +0000 (00:56 +0000)
committerDan Gohman <gohman@apple.com>
Sat, 4 Oct 2008 00:56:36 +0000 (00:56 +0000)
expand to multiple basic blocks, in which case fast-isel
needs to informed of which block to use as it resumes
inserting instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57040 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/FastISel.h
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index 2b112c878c8a81375bc2e23cac1193616bfe0c56..8bf8827481ca24770f5fca8afa1a343cd1ab7136 100644 (file)
@@ -55,12 +55,20 @@ protected:
   const TargetLowering &TLI;
 
 public:
+  /// startNewBlock - Set the current block, to which generated
+  /// machine instructions will be appended, and clear the local
+  /// CSE map.
+  ///
+  void startNewBlock(MachineBasicBlock *mbb) {
+    setCurrentBlock(mbb);
+    LocalValueMap.clear();
+  }
+
   /// setCurrentBlock - Set the current block, to which generated
   /// machine instructions will be appended.
   ///
   void setCurrentBlock(MachineBasicBlock *mbb) {
     MBB = mbb;
-    LocalValueMap.clear();
   }
 
   /// SelectInstruction - Do "fast" instruction selection for the given
index f2f14490b165f067d6d867f6870c323da144fc5b..dce46ab414b940d2383d8035856da69d7cc0fb51 100644 (file)
@@ -756,7 +756,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
         CodeGenAndEmitDAG();
         SDL->clear();
       }
-      FastIS->setCurrentBlock(BB);
+      FastIS->startNewBlock(BB);
       // Do FastISel on as many instructions as possible.
       for (; BI != End; ++BI) {
         // Just before the terminator instruction, insert instructions to
@@ -794,6 +794,9 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, MachineFunction &MF,
           }
 
           SelectBasicBlock(LLVMBB, BI, next(BI));
+          // If the instruction was codegen'd with multiple blocks,
+          // inform the FastISel object where to resume inserting.
+          FastIS->setCurrentBlock(BB);
           continue;
         }