From: Chris Lattner Date: Tue, 11 Jan 2005 22:03:46 +0000 (+0000) Subject: add an assertion, avoid creating copyfromreg/copytoreg pairs that are the X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=f1fdacae8c1bd9e5ff4619546b3a28e93fb75ab5;p=oota-llvm.git add an assertion, avoid creating copyfromreg/copytoreg pairs that are the same for PHI nodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19484 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 916943f30b1..9ccf87cfd84 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -762,7 +762,10 @@ bool SelectionDAGISel::runOnFunction(Function &Fn) { void SelectionDAGISel::CopyValueToVirtualRegister(SelectionDAGLowering &SDL, Value *V, unsigned Reg) { SelectionDAG &DAG = SDL.DAG; - DAG.setRoot(DAG.getCopyToReg(DAG.getRoot(), SDL.getValue(V), Reg)); + SDOperand Op = SDL.getValue(V); + if (CopyRegSDNode *CR = dyn_cast(Op)) + assert(CR->getReg() != Reg && "Copy from a reg to the same reg!"); + DAG.setRoot(DAG.getCopyToReg(DAG.getRoot(), Op, Reg)); } void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB, @@ -798,7 +801,7 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB, // Ensure that all instructions which are used outside of their defining // blocks are available as virtual registers. for (BasicBlock::iterator I = LLVMBB->begin(), E = LLVMBB->end(); I != E;++I) - if (!I->use_empty()) { + if (!I->use_empty() && !isa(I)) { std::map::iterator VMI =FuncInfo.ValueMap.find(I); if (VMI != FuncInfo.ValueMap.end()) CopyValueToVirtualRegister(SDL, I, VMI->second);