Sink SelectionDAGBuilder's HandlePHINodesInSuccessorBlocks down
authorDan Gohman <gohman@apple.com>
Thu, 22 Apr 2010 20:55:53 +0000 (20:55 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 22 Apr 2010 20:55:53 +0000 (20:55 +0000)
into SelectionDAGBuilder itself.

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

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index a1842d7a1e58a99bed51d4f8b6f059c9942c51ec..9db760531606025d679e8c007b727c50c6a68246 100644 (file)
@@ -615,6 +615,10 @@ void SelectionDAGBuilder::AssignOrderingToNode(const SDNode *Node) {
 }
 
 void SelectionDAGBuilder::visit(const Instruction &I) {
+  // Set up outgoing PHI node register values before emitting the terminator.
+  if (isa<TerminatorInst>(&I))
+    HandlePHINodesInSuccessorBlocks(I.getParent());
+
   CurDebugLoc = I.getDebugLoc();
 
   visit(I.getOpcode(), I);
index c71e60a315f0d7971dddac6bf1f398e3edae405c..d9495fb01ea67abbc3adba4f2274fbe533f95f69 100644 (file)
@@ -369,8 +369,6 @@ public:
   void LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool IsTailCall,
                    MachineBasicBlock *LandingPad = NULL);
 
-  void HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB);
-
 private:
   // Terminator instructions.
   void visitRet(const ReturnInst &I);
@@ -495,6 +493,8 @@ private:
   
   const char *implVisitBinaryAtomic(const CallInst& I, ISD::NodeType Op);
   const char *implVisitAluOverflow(const CallInst &I, ISD::NodeType Op);
+
+  void HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB);
 };
 
 } // end namespace llvm
index 8353c18d602768f7be281e8e2a40744c36ac1c3c..875672e4e103fd822750af4a9669fa92a1c74c64 100644 (file)
@@ -233,21 +233,9 @@ SelectionDAGISel::SelectBasicBlock(MachineBasicBlock *BB,
   // Lower all of the non-terminator instructions. If a call is emitted
   // as a tail call, cease emitting nodes for this block. Terminators
   // are handled below.
-  for (BasicBlock::const_iterator I = Begin;
-       I != End && !SDB->HasTailCall && !isa<TerminatorInst>(I);
-       ++I)
+  for (BasicBlock::const_iterator I = Begin; I != End && !SDB->HasTailCall; ++I)
     SDB->visit(*I);
 
-  if (!SDB->HasTailCall) {
-    // Handle PHI nodes in successor blocks.
-    if (End == LLVMBB->end()) {
-      SDB->HandlePHINodesInSuccessorBlocks(LLVMBB);
-
-      // Lower the terminator after the copies are emitted.
-      SDB->visit(*LLVMBB->getTerminator());
-    }
-  }
-
   // Make sure the root of the DAG is up-to-date.
   CurDAG->setRoot(SDB->getControlRoot());