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

Chris Lattner lattner at cs.uiuc.edu
Wed May 17 11:00:20 PDT 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.376 -> 1.377
---
Log message:

When we legalize target nodes, do not use getNode to create a new node,
use UpdateNodeOperands to just update the operands!  This is important because
getNode will allocate a new node if the node returns a flag and this breaks
assumptions in the legalizer that you can legalize some things multiple times
and get exactly the same results.

This latent bug was exposed by my ppc patch last night, and this fixes
gsm/toast.


---
Diffs of the changes:  (+4 -13)

 LegalizeDAG.cpp |   17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.376 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.377
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.376	Wed May 17 12:55:45 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Wed May 17 13:00:08 2006
@@ -529,19 +529,10 @@
       // If this is a target node, legalize it by legalizing the operands then
       // passing it through.
       std::vector<SDOperand> Ops;
-      bool Changed = false;
-      for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) {
+      for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i)
         Ops.push_back(LegalizeOp(Node->getOperand(i)));
-        Changed = Changed || Node->getOperand(i) != Ops.back();
-      }
-      if (Changed)
-        if (Node->getNumValues() == 1)
-          Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Ops);
-        else {
-          std::vector<MVT::ValueType> VTs(Node->value_begin(),
-                                          Node->value_end());
-          Result = DAG.getNode(Node->getOpcode(), VTs, Ops);
-        }
+
+      Result = DAG.UpdateNodeOperands(Result.getValue(0), Ops);
 
       for (unsigned i = 0, e = Node->getNumValues(); i != e; ++i)
         AddLegalizedOperand(Op.getValue(i), Result.getValue(i));
@@ -1058,7 +1049,7 @@
 
     // Merge in the last call, to ensure that this call start after the last
     // call ended.
-    if (LastCALLSEQ_END.getOpcode() != ISD::EntryNode) {
+    if (LastCALLSEQ_END.getOpcode() != ISD::EntryToken) {
       Tmp1 = DAG.getNode(ISD::TokenFactor, MVT::Other, Tmp1, LastCALLSEQ_END);
       Tmp1 = LegalizeOp(Tmp1);
     }






More information about the llvm-commits mailing list