[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Jan 11 14:04:01 PST 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.10 -> 1.11
---
Log message:

add an assertion, avoid creating copyfromreg/copytoreg pairs that are the
same for PHI nodes.


---
Diffs of the changes:  (+5 -2)

Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.10 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.11
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.10	Mon Jan 10 23:56:49 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	Tue Jan 11 16:03:46 2005
@@ -762,7 +762,10 @@
 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 @@
   // 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);






More information about the llvm-commits mailing list