aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-11 22:03:46 +0000
committerChris Lattner <sabre@nondot.org>2005-01-11 22:03:46 +0000
commitf1fdacae8c1bd9e5ff4619546b3a28e93fb75ab5 (patch)
tree18405b86dd9cf2580c6fc457190f239063650bea
parenta5ade060db50a61ee383ea45f3205b3a697d54ff (diff)
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
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 916943f30b..9ccf87cfd8 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<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);