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

Chris Lattner lattner at cs.uiuc.edu
Mon Jan 23 21:48:33 PST 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.275 -> 1.276
SelectionDAG.cpp updated: 1.242 -> 1.243
---
Log message:

Fix an infinite loop I caused by making sure to legalize the flag operand
of CALLSEQ_* nodes


---
Diffs of the changes:  (+22 -1)

 LegalizeDAG.cpp  |   10 +++++++++-
 SelectionDAG.cpp |   13 +++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.275 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.276
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.275	Mon Jan 23 01:30:46 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Mon Jan 23 23:48:21 2006
@@ -823,6 +823,13 @@
     Tmp2 = Node->getOperand(0);
     if (Tmp1 != Tmp2)
       Node->setAdjCallChain(Tmp1);
+    
+    // If this has a flag input, do legalize it.
+    if (Node->getOperand(Node->getNumOperands()-1).getValueType() == MVT::Flag){
+      Tmp1 = LegalizeOp(Node->getOperand(Node->getNumOperands()-1));
+      if (Tmp1 != Node->getOperand(Node->getNumOperands()-1))
+        Node->setAdjCallFlag(Tmp1);
+    }
       
     // Note that we do not create new CALLSEQ_DOWN/UP nodes here.  These
     // nodes are treated specially and are mutated in place.  This makes the dag
@@ -1365,7 +1372,8 @@
                              Tmp2,
                              Node->getOperand(3));
       }
-      Node = Result.Val;
+      Result = LegalizeOp(Result);
+      break;
     }
 
     switch (getTypeAction(Node->getOperand(1).getValueType())) {


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.242 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.243
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.242	Mon Jan 23 15:51:14 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Mon Jan 23 23:48:21 2006
@@ -1276,6 +1276,19 @@
   OperandList[0].Val->Uses.push_back(this);
 }
 
+// setAdjCallFlag - This method changes the flag input of an
+// CALLSEQ_START/END node to be the specified operand.
+void SDNode::setAdjCallFlag(SDOperand N) {
+  assert(N.getValueType() == MVT::Flag);
+  assert((getOpcode() == ISD::CALLSEQ_START ||
+          getOpcode() == ISD::CALLSEQ_END) && "Cannot adjust this node!");
+  
+  SDOperand &FlagOp = OperandList[getNumOperands()-1];
+  assert(FlagOp.getValueType() == MVT::Flag);
+  FlagOp.Val->removeUser(this);
+  FlagOp = N;
+  FlagOp.Val->Uses.push_back(this);
+}
 
 
 SDOperand SelectionDAG::getLoad(MVT::ValueType VT,






More information about the llvm-commits mailing list