Move FastISel's HandlePHINodesInSuccessorBlocks call down into FastISel
authorDan Gohman <gohman@apple.com>
Fri, 23 Apr 2010 15:29:50 +0000 (15:29 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 23 Apr 2010 15:29:50 +0000 (15:29 +0000)
itself too.

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

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

index 8c8698cdc006584f2e197b23a909597a06bea1be..2eb2df2f60176eff9005d8c6c277c91c37bb2f4b 100644 (file)
@@ -107,14 +107,6 @@ public:
   /// index value.
   unsigned getRegForGEPIndex(const Value *V);
 
-  /// HandlePHINodesInSuccessorBlocks - Handle PHI nodes in successor blocks.
-  /// Emit code to ensure constants are copied into registers when needed.
-  /// Remember the virtual registers that need to be added to the Machine PHI
-  /// nodes as input.  We cannot just directly add them, because expansion
-  /// might result in multiple MBB's for one BB.  As such, the start of the
-  /// BB might correspond to a different MBB than the end.
-  bool HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB);
-
   virtual ~FastISel();
 
 protected:
@@ -311,6 +303,14 @@ private:
   bool SelectBitCast(const User *I);
   
   bool SelectCast(const User *I, unsigned Opcode);
+
+  /// HandlePHINodesInSuccessorBlocks - Handle PHI nodes in successor blocks.
+  /// Emit code to ensure constants are copied into registers when needed.
+  /// Remember the virtual registers that need to be added to the Machine PHI
+  /// nodes as input.  We cannot just directly add them, because expansion
+  /// might result in multiple MBB's for one BB.  As such, the start of the
+  /// BB might correspond to a different MBB than the end.
+  bool HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB);
 };
 
 }
index 132c42ef0d71eb951f454831b4651a66d2ce107b..c40eaf629289d86b5ae8dd7f86694c1577caab6e 100644 (file)
@@ -553,6 +553,12 @@ bool FastISel::SelectBitCast(const User *I) {
 
 bool
 FastISel::SelectInstruction(const Instruction *I) {
+  // Just before the terminator instruction, insert instructions to
+  // feed PHI nodes in successor blocks.
+  if (isa<TerminatorInst>(I))
+    if (!HandlePHINodesInSuccessorBlocks(I->getParent()))
+      return false;
+
   DL = I->getDebugLoc();
 
   // First, try doing target-independent selection.
index 875672e4e103fd822750af4a9669fa92a1c74c64..2cdd1cc9783b90464e5d65a730c7a220b8bf07f3 100644 (file)
@@ -751,20 +751,6 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) {
       FastIS->startNewBlock(BB);
       // Do FastISel on as many instructions as possible.
       for (; BI != End; ++BI) {
-        // Just before the terminator instruction, insert instructions to
-        // feed PHI nodes in successor blocks.
-        if (isa<TerminatorInst>(BI))
-          if (!FastIS->HandlePHINodesInSuccessorBlocks(LLVMBB)) {
-            ++NumFastIselFailures;
-            if (EnableFastISelVerbose || EnableFastISelAbort) {
-              dbgs() << "FastISel miss: ";
-              BI->dump();
-            }
-            assert(!EnableFastISelAbort &&
-                   "FastISel didn't handle a PHI in a successor");
-            break;
-          }
-
         // Try to select the instruction with FastISel.
         if (FastIS->SelectInstruction(BI))
           continue;