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
This commit is contained in:
Chris Lattner 2005-01-11 22:03:46 +00:00
parent a5ade060db
commit f1fdacae8c

View File

@ -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<CopyRegSDNode>(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<PHINode>(I)) {
std::map<const Value*, unsigned>::iterator VMI =FuncInfo.ValueMap.find(I);
if (VMI != FuncInfo.ValueMap.end())
CopyValueToVirtualRegister(SDL, I, VMI->second);