From f9a1e3aadcbc7239ec59ce37325542b6484358df Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 24 Jan 2006 05:48:21 +0000 Subject: [PATCH] Fix an infinite loop I caused by making sure to legalize the flag operand of CALLSEQ_* nodes llvm-svn: 25582 --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 10 +++++++++- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 77e721e8b76d..e5dd538eb459 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -823,6 +823,13 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { 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 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { Tmp2, Node->getOperand(3)); } - Node = Result.Val; + Result = LegalizeOp(Result); + break; } switch (getTypeAction(Node->getOperand(1).getValueType())) { diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index c1ba5ebc4ab9..ed96bd61ae2b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1276,6 +1276,19 @@ void SDNode::setAdjCallChain(SDOperand N) { 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,