Fix the SD scheduler to avoid gluing the same node twice.
DAGCombine strangeness may result in multiple loads from the same
offset. They both may try to glue themselves to another load. We could
insist that the redundant loads glue themselves to each other, but the
beter fix is to bail out from bad gluing at the time we detect it.
Fixes rdar://11314175: BuildSchedUnits assert.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155668 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
index 69dd813..8ec1ae8 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
@@ -138,9 +138,11 @@
// Don't add glue from a node to itself.
if (GlueDestNode == N) return;
- // Don't add glue to something which already has glue.
- if (N->getValueType(N->getNumValues() - 1) == MVT::Glue) return;
-
+ // Don't add glue to something that already has it, either as a use or value.
+ if (N->getOperand(N->getNumOperands()-1).getValueType() == MVT::Glue ||
+ N->getValueType(N->getNumValues() - 1) == MVT::Glue) {
+ return;
+ }
for (unsigned I = 0, E = N->getNumValues(); I != E; ++I)
VTs.push_back(N->getValueType(I));