}
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);
void LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool IsTailCall,
MachineBasicBlock *LandingPad = NULL);
- void HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB);
-
private:
// Terminator instructions.
void visitRet(const ReturnInst &I);
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
// 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());