summaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2011-10-29 00:41:52 +0000
committerDan Gohman <gohman@apple.com>2011-10-29 00:41:52 +0000
commit6f3ddef7c51f03945644ad0e69068dfb24d4b092 (patch)
tree55c5e829eb07e614dae3c5e99d7c250c95eda141 /lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
parent29ceb7c104155b5ce107a7defa89fd4457dbbdb5 (diff)
downloadllvm-6f3ddef7c51f03945644ad0e69068dfb24d4b092.tar.gz
llvm-6f3ddef7c51f03945644ad0e69068dfb24d4b092.tar.bz2
llvm-6f3ddef7c51f03945644ad0e69068dfb24d4b092.tar.xz
Revert r143206, as there are still some failing tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143262 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp165
1 files changed, 2 insertions, 163 deletions
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
index b8cf9984f1..a1abdb4d9b 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
@@ -315,10 +315,8 @@ void ScheduleDAGRRList::Schedule() {
IssueCount = 0;
MinAvailableCycle = DisableSchedCycles ? 0 : UINT_MAX;
NumLiveRegs = 0;
- // Allocate slots for each physical register, plus one for a special register
- // to track the virtual resource of a calling sequence.
- LiveRegDefs.resize(TRI->getNumRegs() + 1, NULL);
- LiveRegGens.resize(TRI->getNumRegs() + 1, NULL);
+ LiveRegDefs.resize(TRI->getNumRegs(), NULL);
+ LiveRegGens.resize(TRI->getNumRegs(), NULL);
// Build the scheduling graph.
BuildSchedGraph(NULL);
@@ -388,90 +386,6 @@ void ScheduleDAGRRList::ReleasePred(SUnit *SU, const SDep *PredEdge) {
}
}
-/// IsChainDependent - Test if Outer is reachable from Inner through
-/// chain dependencies.
-static bool IsChainDependent(SDNode *Outer, SDNode *Inner) {
- SDNode *N = Outer;
- for (;;) {
- if (N == Inner)
- return true;
- if (N->getOpcode() == ISD::TokenFactor) {
- for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
- if (IsChainDependent(N->getOperand(i).getNode(), Inner))
- return true;
- return false;
- }
- for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
- if (N->getOperand(i).getValueType() == MVT::Other) {
- N = N->getOperand(i).getNode();
- goto found_chain_operand;
- }
- return false;
- found_chain_operand:;
- if (N->getOpcode() == ISD::EntryToken)
- return false;
- }
-}
-
-/// FindCallSeqStart - Starting from the (lowered) CALLSEQ_END node, locate
-/// the corresponding (lowered) CALLSEQ_BEGIN node.
-///
-/// NestLevel and MaxNested are used in recursion to indcate the current level
-/// of nesting of CALLSEQ_BEGIN and CALLSEQ_END pairs, as well as the maximum
-/// level seen so far.
-///
-/// TODO: It would be better to give CALLSEQ_END an explicit operand to point
-/// to the corresponding CALLSEQ_BEGIN to avoid needing to search for it.
-static SDNode *
-FindCallSeqStart(SDNode *N, unsigned &NestLevel, unsigned &MaxNest,
- const TargetInstrInfo *TII) {
- for (;;) {
- // For a TokenFactor, examine each operand. There may be multiple ways
- // to get to the CALLSEQ_BEGIN, but we need to find the path with the
- // most nesting in order to ensure that we find the corresponding match.
- if (N->getOpcode() == ISD::TokenFactor) {
- SDNode *Best = 0;
- unsigned BestMaxNest = MaxNest;
- for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
- unsigned MyNestLevel = NestLevel;
- unsigned MyMaxNest = MaxNest;
- if (SDNode *New = FindCallSeqStart(N->getOperand(i).getNode(),
- MyNestLevel, MyMaxNest, TII))
- if (!Best || (MyMaxNest > BestMaxNest)) {
- Best = New;
- BestMaxNest = MyMaxNest;
- }
- }
- assert(Best);
- MaxNest = BestMaxNest;
- return Best;
- }
- // Check for a lowered CALLSEQ_BEGIN or CALLSEQ_END.
- if (N->isMachineOpcode()) {
- if (N->getMachineOpcode() ==
- (unsigned)TII->getCallFrameDestroyOpcode()) {
- ++NestLevel;
- MaxNest = std::max(MaxNest, NestLevel);
- } else if (N->getMachineOpcode() ==
- (unsigned)TII->getCallFrameSetupOpcode()) {
- --NestLevel;
- if (NestLevel == 0)
- return N;
- }
- }
- // Otherwise, find the chain and continue climbing.
- for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
- if (N->getOperand(i).getValueType() == MVT::Other) {
- N = N->getOperand(i).getNode();
- goto found_chain_operand;
- }
- return 0;
- found_chain_operand:;
- if (N->getOpcode() == ISD::EntryToken)
- return 0;
- }
-}
-
/// Call ReleasePred for each predecessor, then update register live def/gen.
/// Always update LiveRegDefs for a register dependence even if the current SU
/// also defines the register. This effectively create one large live range
@@ -509,25 +423,6 @@ void ScheduleDAGRRList::ReleasePredecessors(SUnit *SU) {
}
}
}
-
- // If we're scheduling a lowered CALLSEQ_END, find the corresponding CALLSEQ_BEGIN.
- // Inject an artificial physical register dependence between these nodes, to
- // prevent other calls from being interscheduled with them.
- unsigned CallResource = TRI->getNumRegs();
- if (!LiveRegDefs[CallResource])
- for (SDNode *Node = SU->getNode(); Node; Node = Node->getGluedNode())
- if (Node->isMachineOpcode() &&
- Node->getMachineOpcode() == (unsigned)TII->getCallFrameDestroyOpcode()) {
- unsigned NestLevel = 0;
- unsigned MaxNest = 0;
- SDNode *N = FindCallSeqStart(Node, NestLevel, MaxNest, TII);
-
- SUnit *Def = &SUnits[N->getNodeId()];
- ++NumLiveRegs;
- LiveRegDefs[CallResource] = Def;
- LiveRegGens[CallResource] = SU;
- break;
- }
}
/// Check to see if any of the pending instructions are ready to issue. If
@@ -710,20 +605,6 @@ void ScheduleDAGRRList::ScheduleNodeBottomUp(SUnit *SU) {
LiveRegGens[I->getReg()] = NULL;
}
}
- // Release the special call resource dependence, if this is the beginning
- // of a call.
- unsigned CallResource = TRI->getNumRegs();
- if (LiveRegDefs[CallResource] == SU)
- for (const SDNode *SUNode = SU->getNode(); SUNode;
- SUNode = SUNode->getGluedNode()) {
- if (SUNode->isMachineOpcode() &&
- SUNode->getMachineOpcode() == (unsigned)TII->getCallFrameSetupOpcode()) {
- assert(NumLiveRegs > 0 && "NumLiveRegs is already zero!");
- --NumLiveRegs;
- LiveRegDefs[CallResource] = NULL;
- LiveRegGens[CallResource] = NULL;
- }
- }
resetVRegCycle(SU);
@@ -780,33 +661,6 @@ void ScheduleDAGRRList::UnscheduleNodeBottomUp(SUnit *SU) {
}
}
- // Reclaim the special call resource dependence, if this is the beginning
- // of a call.
- unsigned CallResource = TRI->getNumRegs();
- for (const SDNode *SUNode = SU->getNode(); SUNode;
- SUNode = SUNode->getGluedNode()) {
- if (SUNode->isMachineOpcode() &&
- SUNode->getMachineOpcode() == (unsigned)TII->getCallFrameSetupOpcode()) {
- ++NumLiveRegs;
- LiveRegDefs[CallResource] = SU;
- LiveRegGens[CallResource] = NULL;
- }
- }
-
- // Release the special call resource dependence, if this is the end
- // of a call.
- if (LiveRegGens[CallResource] == SU)
- for (const SDNode *SUNode = SU->getNode(); SUNode;
- SUNode = SUNode->getGluedNode()) {
- if (SUNode->isMachineOpcode() &&
- SUNode->getMachineOpcode() == (unsigned)TII->getCallFrameDestroyOpcode()) {
- assert(NumLiveRegs > 0 && "NumLiveRegs is already zero!");
- --NumLiveRegs;
- LiveRegDefs[CallResource] = NULL;
- LiveRegGens[CallResource] = NULL;
- }
- }
-
for (SUnit::succ_iterator I = SU->Succs.begin(), E = SU->Succs.end();
I != E; ++I) {
if (I->isAssignedRegDep()) {
@@ -1229,21 +1083,6 @@ DelayForLiveRegsBottomUp(SUnit *SU, SmallVector<unsigned, 4> &LRegs) {
if (!Node->isMachineOpcode())
continue;
- // If we're in the middle of scheduling a call, don't begin scheduling
- // another call. Also, don't allow any physical registers to be live across
- // the call.
- if (Node->getMachineOpcode() == (unsigned)TII->getCallFrameDestroyOpcode()) {
- // Add one here so that we include the special calling-sequence resource.
- for (unsigned i = 0, e = TRI->getNumRegs() + 1; i != e; ++i)
- if (LiveRegDefs[i]) {
- SDNode *Gen = LiveRegGens[i]->getNode();
- while (SDNode *Glued = Gen->getGluedNode())
- Gen = Glued;
- if (!IsChainDependent(Gen, Node) && RegAdded.insert(i))
- LRegs.push_back(i);
- }
- continue;
- }
const MCInstrDesc &MCID = TII->get(Node->getMachineOpcode());
if (!MCID.ImplicitDefs)
continue;