Skip to content

Commit 0345d88

Browse files
committed
[NFC][ScheduleDAG] Remove unused EntrySU SUnit
EntrySU doesn't seem to be used at all when building the ScheduleDAG. Differential Revision: https://reviews.llvm.org/D87867
1 parent cab6f5b commit 0345d88

13 files changed

+25
-48
lines changed

llvm/include/llvm/CodeGen/MachineScheduler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class MachineSchedStrategy {
234234
virtual void leaveMBB() {};
235235

236236
/// Notify this strategy that all roots have been released (including those
237-
/// that depend on EntrySU or ExitSU).
237+
/// that depend on ExitSU).
238238
virtual void registerRoots() {}
239239

240240
/// Pick the next node to schedule, or return NULL. Set IsTopNode to true to

llvm/include/llvm/CodeGen/ScheduleDAG.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ class TargetRegisterInfo;
560560
MachineFunction &MF; ///< Machine function
561561
MachineRegisterInfo &MRI; ///< Virtual/real register map
562562
std::vector<SUnit> SUnits; ///< The scheduling units.
563-
SUnit EntrySU; ///< Special node for the region entry.
564563
SUnit ExitSU; ///< Special node for the region exit.
565564

566565
#ifdef NDEBUG

llvm/lib/CodeGen/MachineScheduler.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ void ScheduleDAGMI::releasePred(SUnit *SU, SDep *PredEdge) {
680680
PredSU->BotReadyCycle = SU->BotReadyCycle + PredEdge->getLatency();
681681

682682
--PredSU->NumSuccsLeft;
683-
if (PredSU->NumSuccsLeft == 0 && PredSU != &EntrySU)
683+
if (PredSU->NumSuccsLeft == 0)
684684
SchedImpl->releaseBottomNode(PredSU);
685685
}
686686

@@ -853,7 +853,7 @@ void ScheduleDAGMI::initQueues(ArrayRef<SUnit*> TopRoots,
853853
NextClusterSucc = nullptr;
854854
NextClusterPred = nullptr;
855855

856-
// Release all DAG roots for scheduling, not including EntrySU/ExitSU.
856+
// Release all DAG roots for scheduling, not including ExitSU.
857857
//
858858
// Nodes with unreleased weak edges can still be roots.
859859
// Release top roots in forward order.
@@ -867,7 +867,6 @@ void ScheduleDAGMI::initQueues(ArrayRef<SUnit*> TopRoots,
867867
SchedImpl->releaseBottomNode(*I);
868868
}
869869

870-
releaseSuccessors(&EntrySU);
871870
releasePredecessors(&ExitSU);
872871

873872
SchedImpl->registerRoots();
@@ -1168,8 +1167,6 @@ void ScheduleDAGMILive::updatePressureDiffs(
11681167

11691168
void ScheduleDAGMILive::dump() const {
11701169
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1171-
if (EntrySU.getInstr() != nullptr)
1172-
dumpNodeAll(EntrySU);
11731170
for (const SUnit &SU : SUnits) {
11741171
dumpNodeAll(SU);
11751172
if (ShouldTrackPressure) {

llvm/lib/CodeGen/MacroFusion.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,21 @@ static bool fuseInstructionPair(ScheduleDAGInstrs &DAG, SUnit &FirstSU,
109109

110110
// Make the FirstSU also dependent on the dependencies of the SecondSU to
111111
// prevent them from being scheduled between the FirstSU and the SecondSU.
112-
if (&FirstSU != &DAG.EntrySU) {
113-
for (const SDep &SI : SecondSU.Preds) {
114-
SUnit *SU = SI.getSUnit();
115-
if (SI.isWeak() || isHazard(SI) || &FirstSU == SU || FirstSU.isSucc(SU))
116-
continue;
117-
LLVM_DEBUG(dbgs() << " Bind "; DAG.dumpNodeName(*SU); dbgs() << " - ";
118-
DAG.dumpNodeName(FirstSU); dbgs() << '\n';);
119-
DAG.addEdge(&FirstSU, SDep(SU, SDep::Artificial));
120-
}
121-
// ExitSU comes last by design, which acts like an implicit dependency
122-
// between ExitSU and any bottom root in the graph. We should transfer
123-
// this to FirstSU as well.
124-
if (&SecondSU == &DAG.ExitSU) {
125-
for (SUnit &SU : DAG.SUnits) {
126-
if (SU.Succs.empty())
127-
DAG.addEdge(&FirstSU, SDep(&SU, SDep::Artificial));
128-
}
112+
for (const SDep &SI : SecondSU.Preds) {
113+
SUnit *SU = SI.getSUnit();
114+
if (SI.isWeak() || isHazard(SI) || &FirstSU == SU || FirstSU.isSucc(SU))
115+
continue;
116+
LLVM_DEBUG(dbgs() << " Bind "; DAG.dumpNodeName(*SU); dbgs() << " - ";
117+
DAG.dumpNodeName(FirstSU); dbgs() << '\n';);
118+
DAG.addEdge(&FirstSU, SDep(SU, SDep::Artificial));
119+
}
120+
// ExitSU comes last by design, which acts like an implicit dependency
121+
// between ExitSU and any bottom root in the graph. We should transfer
122+
// this to FirstSU as well.
123+
if (&SecondSU == &DAG.ExitSU) {
124+
for (SUnit &SU : DAG.SUnits) {
125+
if (SU.Succs.empty())
126+
DAG.addEdge(&FirstSU, SDep(&SU, SDep::Artificial));
129127
}
130128
}
131129

llvm/lib/CodeGen/PostRASchedulerList.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,6 @@ void SchedulePostRATDList::ListScheduleTopDown() {
527527
// blocks are a single region).
528528
HazardRec->Reset();
529529

530-
// Release any successors of the special Entry node.
531-
ReleaseSuccessors(&EntrySU);
532-
533530
// Add all leaves to Available queue.
534531
for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
535532
// It is available if it has no predecessors.

llvm/lib/CodeGen/ScheduleDAG.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ ScheduleDAG::~ScheduleDAG() = default;
6363

6464
void ScheduleDAG::clearDAG() {
6565
SUnits.clear();
66-
EntrySU = SUnit();
6766
ExitSU = SUnit();
6867
}
6968

@@ -352,9 +351,7 @@ LLVM_DUMP_METHOD void SUnit::dumpAttributes() const {
352351
}
353352

354353
LLVM_DUMP_METHOD void ScheduleDAG::dumpNodeName(const SUnit &SU) const {
355-
if (&SU == &EntrySU)
356-
dbgs() << "EntrySU";
357-
else if (&SU == &ExitSU)
354+
if (&SU == &ExitSU)
358355
dbgs() << "ExitSU";
359356
else
360357
dbgs() << "SU(" << SU.NodeNum << ")";
@@ -656,7 +653,7 @@ std::vector<int> ScheduleDAGTopologicalSort::GetSubGraph(const SUnit &StartSU,
656653
for (int I = SU->Preds.size()-1; I >= 0; --I) {
657654
const SUnit *Pred = SU->Preds[I].getSUnit();
658655
unsigned s = Pred->NodeNum;
659-
// Edges to non-SUnits are allowed but ignored (e.g. EntrySU).
656+
// Edges to non-SUnits are allowed but ignored (e.g. ExitSU).
660657
if (Pred->isBoundaryNode())
661658
continue;
662659
if (Node2Index[s] == LowerBound) {

llvm/lib/CodeGen/ScheduleDAGInstrs.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,6 @@ void ScheduleDAGInstrs::dumpNode(const SUnit &SU) const {
11671167

11681168
void ScheduleDAGInstrs::dump() const {
11691169
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1170-
if (EntrySU.getInstr() != nullptr)
1171-
dumpNodeAll(EntrySU);
11721170
for (const SUnit &SU : SUnits)
11731171
dumpNodeAll(SU);
11741172
if (ExitSU.getInstr() != nullptr)
@@ -1179,9 +1177,7 @@ void ScheduleDAGInstrs::dump() const {
11791177
std::string ScheduleDAGInstrs::getGraphNodeLabel(const SUnit *SU) const {
11801178
std::string s;
11811179
raw_string_ostream oss(s);
1182-
if (SU == &EntrySU)
1183-
oss << "<entry>";
1184-
else if (SU == &ExitSU)
1180+
if (SU == &ExitSU)
11851181
oss << "<exit>";
11861182
else
11871183
SU->getInstr()->print(oss, /*SkipOpers=*/true);

llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ void ScheduleDAGFast::ReleasePred(SUnit *SU, SDep *PredEdge) {
150150
--PredSU->NumSuccsLeft;
151151

152152
// If all the node's successors are scheduled, this node is ready
153-
// to be scheduled. Ignore the special EntrySU node.
154-
if (PredSU->NumSuccsLeft == 0 && PredSU != &EntrySU) {
153+
// to be scheduled.
154+
if (PredSU->NumSuccsLeft == 0) {
155155
PredSU->isAvailable = true;
156156
AvailableQueue.push(PredSU);
157157
}

llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ void ScheduleDAGRRList::ReleasePred(SUnit *SU, const SDep *PredEdge) {
415415
}
416416

417417
// If all the node's successors are scheduled, this node is ready
418-
// to be scheduled. Ignore the special EntrySU node.
419-
if (PredSU->NumSuccsLeft == 0 && PredSU != &EntrySU) {
418+
// to be scheduled.
419+
if (PredSU->NumSuccsLeft == 0) {
420420
PredSU->isAvailable = true;
421421

422422
unsigned Height = PredSU->getHeight();

llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,6 @@ void ScheduleDAGSDNodes::dumpNode(const SUnit &SU) const {
696696

697697
void ScheduleDAGSDNodes::dump() const {
698698
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
699-
if (EntrySU.getNode() != nullptr)
700-
dumpNodeAll(EntrySU);
701699
for (const SUnit &SU : SUnits)
702700
dumpNodeAll(SU);
703701
if (ExitSU.getNode() != nullptr)

llvm/lib/CodeGen/SelectionDAG/ScheduleDAGVLIW.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ void ScheduleDAGVLIW::scheduleNodeTopDown(SUnit *SU, unsigned CurCycle) {
166166
void ScheduleDAGVLIW::listScheduleTopDown() {
167167
unsigned CurCycle = 0;
168168

169-
// Release any successors of the special Entry node.
170-
releaseSuccessors(&EntrySU);
171-
172169
// All leaves to AvailableQueue.
173170
for (unsigned i = 0, e = SUnits.size(); i != e; ++i) {
174171
// It is available if it has no predecessors.

llvm/lib/Target/AMDGPU/GCNMinRegStrategy.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ GCNMinRegScheduler::schedule(ArrayRef<const SUnit*> TopRoots,
248248
for (auto SU : TopRoots) {
249249
RQ.push_back(*new (Alloc.Allocate()) Candidate(SU, StepNo));
250250
}
251-
releaseSuccessors(&DAG.EntrySU, StepNo);
252251

253252
while (!RQ.empty()) {
254253
LLVM_DEBUG(dbgs() << "\n=== Picking candidate, Step = " << StepNo

llvm/lib/Target/AMDGPU/SIMachineScheduler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ class SIScheduleDAGMI final : public ScheduleDAGMILive {
455455
MachineRegisterInfo *getMRI() { return &MRI; }
456456
const TargetRegisterInfo *getTRI() { return TRI; }
457457
ScheduleDAGTopologicalSort *GetTopo() { return &Topo; }
458-
SUnit& getEntrySU() { return EntrySU; }
459458
SUnit& getExitSU() { return ExitSU; }
460459

461460
void restoreSULinksLeft();

0 commit comments

Comments
 (0)