aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-01-14 22:41:46 +0000
committerChris Lattner <sabre@nondot.org>2006-01-14 22:41:46 +0000
commitc0ab5226cc92b8d33104374a21896b8331f3fee1 (patch)
tree6ee3448b715c02d7bebc5e5468e587de8e68526d
parentbc0f46097d4a16929e8501948e1083a225f0555f (diff)
Token chain results are not always the first or last result. Consider copyfromreg nodes, where they are the middle result (the flag result is last)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25325 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 9dae31d6d7..57a9b1d776 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -3016,6 +3016,7 @@ SDOperand SelectionDAGLegalize::PromoteOp(SDOperand Op) {
Tmp2 = LegalizeOp(Node->getOperand(1));
Result = DAG.getNode(ISD::SRL, NVT, Tmp1, Tmp2);
break;
+
case ISD::LOAD:
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the pointer.
@@ -3374,11 +3375,24 @@ static SDNode *FindCallSeqEnd(SDNode *Node) {
if (Node->use_empty())
return 0; // No CallSeqEnd
+ // The chain is usually at the end.
SDOperand TheChain(Node, Node->getNumValues()-1);
- if (TheChain.getValueType() != MVT::Other)
+ if (TheChain.getValueType() != MVT::Other) {
+ // Sometimes it's at the beginning.
TheChain = SDOperand(Node, 0);
- if (TheChain.getValueType() != MVT::Other)
- return 0;
+ if (TheChain.getValueType() != MVT::Other) {
+ // Otherwise, hunt for it.
+ for (unsigned i = 1, e = Node->getNumValues(); i != e; ++i)
+ if (Node->getValueType(i) == MVT::Other) {
+ TheChain = SDOperand(Node, i);
+ break;
+ }
+
+ // Otherwise, we walked into a node without a chain.
+ if (TheChain.getValueType() != MVT::Other)
+ return 0;
+ }
+ }
for (SDNode::use_iterator UI = Node->use_begin(),
E = Node->use_end(); UI != E; ++UI) {