aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-04-28 22:07:13 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-04-28 22:07:13 +0000
commit80cb49ea90ad34a368bba08c09c3ad026e4ce898 (patch)
treeda57facaaf6ffc4f3918df9fa81f3e5981e303c7 /lib/CodeGen
parent267e470bb607ee261035b5665c1927a978f387ce (diff)
downloadexternal_llvm-80cb49ea90ad34a368bba08c09c3ad026e4ce898.zip
external_llvm-80cb49ea90ad34a368bba08c09c3ad026e4ce898.tar.gz
external_llvm-80cb49ea90ad34a368bba08c09c3ad026e4ce898.tar.bz2
Fix a bug in RegsForValue::getCopyToRegs() that causes cyclical scheduling units. If it's creating multiple CopyToReg nodes that are "flagged" together, it should not create a TokenFactor for it's chain outputs:
c1, f1 = CopyToReg c2, f2 = CopyToReg c3 = TokenFactor c1, c2 ... = user c3, ..., f2 Now that the two CopyToReg's and the user are "flagged" together. They effectively forms a single scheduling unit. The TokenFactor is now both an operand and a successor of the Flagged nodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50376 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 496051f..2d65a33 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -3455,8 +3455,18 @@ void RegsForValue::getCopyToRegs(SDOperand Val, SelectionDAG &DAG,
Chains[i] = Part.getValue(0);
}
- if (NumRegs == 1)
- Chain = Chains[0];
+ if (NumRegs == 1 || Flag)
+ // If NumRegs > 1 && Flag is used then the use of the last CopyToReg is
+ // flagged to it. That is the CopyToReg nodes and the user are considered
+ // a single scheduling unit. If we create a TokenFactor and return it as
+ // chain, then the TokenFactor is both a predecessor (operand) of the
+ // user as well as a successor (the TF operands are flagged to the user).
+ // c1, f1 = CopyToReg
+ // c2, f2 = CopyToReg
+ // c3 = TokenFactor c1, c2
+ // ...
+ // = op c3, ..., f2
+ Chain = Chains[NumRegs-1];
else
Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, &Chains[0], NumRegs);
}