llvm.org GIT mirror llvm / b064c24
ScheduleDAG: Cleanup dumping code; NFC - Instead of having both `SUnit::dump(ScheduleDAG*)` and `ScheduleDAG::dumpNode(ScheduleDAG*)`, just keep the latter around. - Add `ScheduleDAG::dump()` and avoid code duplication in several places. Implement it for different ScheduleDAG variants. - Add `ScheduleDAG::dumpNodeName()` in favor of the `SUnit::print()` functions. They were only ever used for debug dumping and putting the function into ScheduleDAG is consistent with the `dumpNode()` change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342520 91177308-0d34-0410-b5e6-96231b3b80d8 Matthias Braun 1 year, 1 month ago
23 changed file(s) with 172 addition(s) and 163 deletion(s). Raw diff Collapse all Expand all
465465 PressureDiff &getPressureDiff(const SUnit *SU) {
466466 return SUPressureDiffs[SU->NodeNum];
467467 }
468 const PressureDiff &getPressureDiff(const SUnit *SU) const {
469 return SUPressureDiffs[SU->NodeNum];
470 }
468471
469472 /// Compute a DFSResult after DAG building is complete, and before any
470473 /// queue comparisons.
489492
490493 /// Compute the cyclic critical path through the DAG.
491494 unsigned computeCyclicCriticalPath();
495
496 void dump() const override;
492497
493498 protected:
494499 // Top-Level entry points for the schedule() driver...
235235 Contents.Reg = Reg;
236236 }
237237
238 raw_ostream &print(raw_ostream &O,
239 const TargetRegisterInfo *TRI = nullptr) const;
238 void dump(const TargetRegisterInfo *TRI = nullptr) const;
240239 };
241240
242241 template <>
458457 /// edge occurs first.
459458 void biasCriticalPath();
460459
461 void dump(const ScheduleDAG *G) const;
462 void dumpAll(const ScheduleDAG *G) const;
463 raw_ostream &print(raw_ostream &O,
464 const SUnit *Entry = nullptr,
465 const SUnit *Exit = nullptr) const;
466 raw_ostream &print(raw_ostream &O, const ScheduleDAG *G) const;
460 void dumpAttributes() const;
467461
468462 private:
469463 void ComputeDepth();
596590 virtual void viewGraph(const Twine &Name, const Twine &Title);
597591 virtual void viewGraph();
598592
599 virtual void dumpNode(const SUnit *SU) const = 0;
593 virtual void dumpNode(const SUnit &SU) const = 0;
594 virtual void dump() const = 0;
595 void dumpNodeName(const SUnit &SU) const;
600596
601597 /// Returns a label for an SUnit node in a visualization of the ScheduleDAG.
602598 virtual std::string getGraphNodeLabel(const SUnit *SU) const = 0;
612608 /// consistent. Returns the number of scheduled SUnits.
613609 unsigned VerifyScheduledDAG(bool isBottomUp);
614610 #endif
611
612 protected:
613 void dumpNodeAll(const SUnit &SU) const;
615614
616615 private:
617616 /// Returns the MCInstrDesc of this SDNode or NULL.
326326 /// whole MachineFunction. By default does nothing.
327327 virtual void finalizeSchedule() {}
328328
329 void dumpNode(const SUnit *SU) const override;
329 void dumpNode(const SUnit &SU) const override;
330 void dump() const override;
330331
331332 /// Returns a label for a DAG node that points to an instruction.
332333 std::string getGraphNodeLabel(const SUnit *SU) const override;
249249
250250 LLVM_DEBUG({
251251 dbgs() << "Scheduling DAG of the packetize region\n";
252 for (SUnit &SU : VLIWScheduler->SUnits)
253 SU.dumpAll(VLIWScheduler);
252 VLIWScheduler->dump();
254253 });
255254
256255 // Generate MI -> SU map.
144144 LLVM_DUMP_METHOD void LatencyPriorityQueue::dump(ScheduleDAG *DAG) const {
145145 dbgs() << "Latency Priority Queue\n";
146146 dbgs() << " Number of Queue Entries: " << Queue.size() << "\n";
147 for (auto const &SU : Queue) {
147 for (const SUnit *SU : Queue) {
148148 dbgs() << " ";
149 SU->dump(DAG);
149 DAG->dumpNode(*SU);
150150 }
151151 }
152152 #endif
885885 Topo.InitDAGTopologicalSorting();
886886 postprocessDAG();
887887 changeDependences();
888 LLVM_DEBUG({
889 for (unsigned su = 0, e = SUnits.size(); su != e; ++su)
890 SUnits[su].dumpAll(this);
891 });
888 LLVM_DEBUG(dump());
892889
893890 NodeSetType NodeSets;
894891 findCircuits(NodeSets);
16371634 for (ScheduleDAGTopologicalSort::const_iterator I = Topo.begin(),
16381635 E = Topo.end();
16391636 I != E; ++I) {
1640 SUnit *SU = &SUnits[*I];
1641 SU->dump(this);
1637 const SUnit &SU = SUnits[*I];
1638 dumpNode(SU);
16421639 }
16431640 });
16441641
632632 #ifndef NDEBUG
633633 if (SuccSU->NumPredsLeft == 0) {
634634 dbgs() << "*** Scheduling failed! ***\n";
635 SuccSU->dump(this);
635 dumpNode(*SuccSU);
636636 dbgs() << " has been released too many times!\n";
637637 llvm_unreachable(nullptr);
638638 }
669669 #ifndef NDEBUG
670670 if (PredSU->NumSuccsLeft == 0) {
671671 dbgs() << "*** Scheduling failed! ***\n";
672 PredSU->dump(this);
672 dumpNode(*PredSU);
673673 dbgs() << " has been released too many times!\n";
674674 llvm_unreachable(nullptr);
675675 }
763763 SmallVector TopRoots, BotRoots;
764764 findRootsAndBiasEdges(TopRoots, BotRoots);
765765
766 LLVM_DEBUG(if (EntrySU.getInstr() != nullptr) EntrySU.dumpAll(this);
767 for (const SUnit &SU
768 : SUnits) SU.dumpAll(this);
769 if (ExitSU.getInstr() != nullptr) ExitSU.dumpAll(this););
766 LLVM_DEBUG(dump());
770767 if (ViewMISchedDAGs) viewGraph();
771768
772769 // Initialize the strategy before modifying the DAG.
919916 LLVM_DUMP_METHOD void ScheduleDAGMI::dumpSchedule() const {
920917 for (MachineBasicBlock::iterator MI = begin(), ME = end(); MI != ME; ++MI) {
921918 if (SUnit *SU = getSUnit(&(*MI)))
922 SU->dump(this);
919 dumpNode(*SU);
923920 else
924921 dbgs() << "Missing SUnit\n";
925922 }
11701167 }
11711168 }
11721169
1170 void ScheduleDAGMILive::dump() const {
1171 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1172 if (EntrySU.getInstr() != nullptr)
1173 dumpNodeAll(EntrySU);
1174 for (const SUnit &SU : SUnits) {
1175 dumpNodeAll(SU);
1176 if (ShouldTrackPressure) {
1177 dbgs() << " Pressure Diff : ";
1178 getPressureDiff(&SU).dump(*TRI);
1179 }
1180 dbgs() << " Single Issue : ";
1181 if (SchedModel.mustBeginGroup(SU.getInstr()) &&
1182 SchedModel.mustEndGroup(SU.getInstr()))
1183 dbgs() << "true;";
1184 else
1185 dbgs() << "false;";
1186 dbgs() << '\n';
1187 }
1188 if (ExitSU.getInstr() != nullptr)
1189 dumpNodeAll(ExitSU);
1190 #endif
1191 }
1192
11731193 /// schedule - Called back from MachineScheduler::runOnMachineFunction
11741194 /// after setting up the current scheduling region. [RegionBegin, RegionEnd)
11751195 /// only includes instructions that have DAG nodes, not scheduling boundaries.
11961216 // This may initialize a DFSResult to be used for queue priority.
11971217 SchedImpl->initialize(this);
11981218
1199 LLVM_DEBUG(if (EntrySU.getInstr() != nullptr) EntrySU.dumpAll(this);
1200 for (const SUnit &SU
1201 : SUnits) {
1202 SU.dumpAll(this);
1203 if (ShouldTrackPressure) {
1204 dbgs() << " Pressure Diff : ";
1205 getPressureDiff(&SU).dump(*TRI);
1206 }
1207 dbgs() << " Single Issue : ";
1208 if (SchedModel.mustBeginGroup(SU.getInstr()) &&
1209 SchedModel.mustEndGroup(SU.getInstr()))
1210 dbgs() << "true;";
1211 else
1212 dbgs() << "false;";
1213 dbgs() << '\n';
1214 } if (ExitSU.getInstr() != nullptr) ExitSU.dumpAll(this););
1219 LLVM_DEBUG(dump());
12151220 if (ViewMISchedDAGs) viewGraph();
12161221
12171222 // Initialize ready queues now that the DAG and priority data are finalized.
31853190 if (!Copy->isCopy())
31863191 continue;
31873192 LLVM_DEBUG(dbgs() << " Rescheduling physreg copy ";
3188 Dep.getSUnit()->dump(DAG));
3193 DAG->dumpNode(*Dep.getSUnit()));
31893194 DAG->moveInstruction(Copy, InsertPos);
31903195 }
31913196 }
6666 SI.setLatency(0);
6767
6868 LLVM_DEBUG(
69 dbgs() << "Macro fuse: "; FirstSU.print(dbgs(), &DAG); dbgs() << " - ";
70 SecondSU.print(dbgs(), &DAG); dbgs() << " / ";
69 dbgs() << "Macro fuse: "; DAG.dumpNodeName(FirstSU); dbgs() << " - ";
70 DAG.dumpNodeName(SecondSU); dbgs() << " / ";
7171 dbgs() << DAG.TII->getName(FirstSU.getInstr()->getOpcode()) << " - "
7272 << DAG.TII->getName(SecondSU.getInstr()->getOpcode()) << '\n';);
7373
7979 if (SI.isWeak() || isHazard(SI) ||
8080 SU == &DAG.ExitSU || SU == &SecondSU || SU->isPred(&SecondSU))
8181 continue;
82 LLVM_DEBUG(dbgs() << " Bind "; SecondSU.print(dbgs(), &DAG);
83 dbgs() << " - "; SU->print(dbgs(), &DAG); dbgs() << '\n';);
82 LLVM_DEBUG(dbgs() << " Bind "; DAG.dumpNodeName(SecondSU);
83 dbgs() << " - "; DAG.dumpNodeName(*SU); dbgs() << '\n';);
8484 DAG.addEdge(SU, SDep(&SecondSU, SDep::Artificial));
8585 }
8686
9191 SUnit *SU = SI.getSUnit();
9292 if (SI.isWeak() || isHazard(SI) || &FirstSU == SU || FirstSU.isSucc(SU))
9393 continue;
94 LLVM_DEBUG(dbgs() << " Bind "; SU->print(dbgs(), &DAG); dbgs() << " - ";
95 FirstSU.print(dbgs(), &DAG); dbgs() << '\n';);
94 LLVM_DEBUG(dbgs() << " Bind "; DAG.dumpNodeName(*SU); dbgs() << " - ";
95 DAG.dumpNodeName(FirstSU); dbgs() << '\n';);
9696 DAG.addEdge(&FirstSU, SDep(SU, SDep::Artificial));
9797 }
9898 // ExitSU comes last by design, which acts like an implicit dependency
255255 LLVM_DUMP_METHOD void SchedulePostRATDList::dumpSchedule() const {
256256 for (unsigned i = 0, e = Sequence.size(); i != e; i++) {
257257 if (SUnit *SU = Sequence[i])
258 SU->dump(this);
258 dumpNode(*SU);
259259 else
260260 dbgs() << "**** NOOP ****\n";
261261 }
413413 postprocessDAG();
414414
415415 LLVM_DEBUG(dbgs() << "********** List Scheduling **********\n");
416 LLVM_DEBUG(for (const SUnit &SU
417 : SUnits) {
418 SU.dumpAll(this);
419 dbgs() << '\n';
420 });
416 LLVM_DEBUG(dump());
421417
422418 AvailableQueue.initNodes(SUnits);
423419 ListScheduleTopDown();
464460 #ifndef NDEBUG
465461 if (SuccSU->NumPredsLeft == 0) {
466462 dbgs() << "*** Scheduling failed! ***\n";
467 SuccSU->dump(this);
463 dumpNode(*SuccSU);
468464 dbgs() << " has been released too many times!\n";
469465 llvm_unreachable(nullptr);
470466 }
501497 /// the Available queue.
502498 void SchedulePostRATDList::ScheduleNodeTopDown(SUnit *SU, unsigned CurCycle) {
503499 LLVM_DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: ");
504 LLVM_DEBUG(SU->dump(this));
500 LLVM_DEBUG(dumpNode(*SU));
505501
506502 Sequence.push_back(SU);
507503 assert(CurCycle >= SU->getDepth() &&
6767 return &TII->get(Node->getMachineOpcode());
6868 }
6969
70 LLVM_DUMP_METHOD
71 raw_ostream &SDep::print(raw_ostream &OS, const TargetRegisterInfo *TRI) const {
70 LLVM_DUMP_METHOD void SDep::dump(const TargetRegisterInfo *TRI) const {
7271 switch (getKind()) {
73 case Data: OS << "Data"; break;
74 case Anti: OS << "Anti"; break;
75 case Output: OS << "Out "; break;
76 case Order: OS << "Ord "; break;
72 case Data: dbgs() << "Data"; break;
73 case Anti: dbgs() << "Anti"; break;
74 case Output: dbgs() << "Out "; break;
75 case Order: dbgs() << "Ord "; break;
7776 }
7877
7978 switch (getKind()) {
8079 case Data:
81 OS << " Latency=" << getLatency();
80 dbgs() << " Latency=" << getLatency();
8281 if (TRI && isAssignedRegDep())
83 OS << " Reg=" << printReg(getReg(), TRI);
82 dbgs() << " Reg=" << printReg(getReg(), TRI);
8483 break;
8584 case Anti:
8685 case Output:
87 OS << " Latency=" << getLatency();
86 dbgs() << " Latency=" << getLatency();
8887 break;
8988 case Order:
90 OS << " Latency=" << getLatency();
89 dbgs() << " Latency=" << getLatency();
9190 switch(Contents.OrdKind) {
92 case Barrier: OS << " Barrier"; break;
91 case Barrier: dbgs() << " Barrier"; break;
9392 case MayAliasMem:
94 case MustAliasMem: OS << " Memory"; break;
95 case Artificial: OS << " Artificial"; break;
96 case Weak: OS << " Weak"; break;
97 case Cluster: OS << " Cluster"; break;
93 case MustAliasMem: dbgs() << " Memory"; break;
94 case Artificial: dbgs() << " Artificial"; break;
95 case Weak: dbgs() << " Weak"; break;
96 case Cluster: dbgs() << " Cluster"; break;
9897 }
9998 break;
10099 }
101
102 return OS;
103100 }
104101
105102 bool SUnit::addPred(const SDep &D, bool Required) {
336333 }
337334
338335 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
339 LLVM_DUMP_METHOD
340 raw_ostream &SUnit::print(raw_ostream &OS,
341 const SUnit *Entry, const SUnit *Exit) const {
342 if (this == Entry)
343 OS << "EntrySU";
344 else if (this == Exit)
345 OS << "ExitSU";
346 else
347 OS << "SU(" << NodeNum << ")";
348 return OS;
349 }
350
351 LLVM_DUMP_METHOD
352 raw_ostream &SUnit::print(raw_ostream &OS, const ScheduleDAG *G) const {
353 return print(OS, &G->EntrySU, &G->ExitSU);
354 }
355
356 LLVM_DUMP_METHOD
357 void SUnit::dump(const ScheduleDAG *G) const {
358 print(dbgs(), G);
359 dbgs() << ": ";
360 G->dumpNode(this);
361 }
362
363 LLVM_DUMP_METHOD void SUnit::dumpAll(const ScheduleDAG *G) const {
364 dump(G);
365
336 LLVM_DUMP_METHOD void SUnit::dumpAttributes() const {
366337 dbgs() << " # preds left : " << NumPredsLeft << "\n";
367338 dbgs() << " # succs left : " << NumSuccsLeft << "\n";
368339 if (WeakPredsLeft)
373344 dbgs() << " Latency : " << Latency << "\n";
374345 dbgs() << " Depth : " << getDepth() << "\n";
375346 dbgs() << " Height : " << getHeight() << "\n";
376
377 if (Preds.size() != 0) {
347 }
348
349 LLVM_DUMP_METHOD void ScheduleDAG::dumpNodeName(const SUnit &SU) const {
350 if (&SU == &EntrySU)
351 dbgs() << "EntrySU";
352 else if (&SU == &ExitSU)
353 dbgs() << "ExitSU";
354 else
355 dbgs() << "SU(" << SU.NodeNum << ")";
356 }
357
358 LLVM_DUMP_METHOD void ScheduleDAG::dumpNodeAll(const SUnit &SU) const {
359 dumpNode(SU);
360 SU.dumpAttributes();
361 if (SU.Preds.size() > 0) {
378362 dbgs() << " Predecessors:\n";
379 for (const SDep &Dep : Preds) {
363 for (const SDep &Dep : SU.Preds) {
380364 dbgs() << " ";
381 Dep.getSUnit()->print(dbgs(), G); dbgs() << ": ";
382 Dep.print(dbgs(), G->TRI); dbgs() << '\n';
383 }
384 }
385 if (Succs.size() != 0) {
365 dumpNodeName(*Dep.getSUnit());
366 dbgs() << ": ";
367 Dep.dump(TRI);
368 dbgs() << '\n';
369 }
370 }
371 if (SU.Succs.size() > 0) {
386372 dbgs() << " Successors:\n";
387 for (const SDep &Dep : Succs) {
373 for (const SDep &Dep : SU.Succs) {
388374 dbgs() << " ";
389 Dep.getSUnit()->print(dbgs(), G); dbgs() << ": ";
390 Dep.print(dbgs(), G->TRI); dbgs() << '\n';
375 dumpNodeName(*Dep.getSUnit());
376 dbgs() << ": ";
377 Dep.dump(TRI);
378 dbgs() << '\n';
391379 }
392380 }
393381 }
405393 }
406394 if (!AnyNotSched)
407395 dbgs() << "*** Scheduling failed! ***\n";
408 SUnit.dump(this);
396 dumpNode(SUnit);
409397 dbgs() << "has not been scheduled!\n";
410398 AnyNotSched = true;
411399 }
414402 unsigned(std::numeric_limits::max())) {
415403 if (!AnyNotSched)
416404 dbgs() << "*** Scheduling failed! ***\n";
417 SUnit.dump(this);
405 dumpNode(SUnit);
418406 dbgs() << "has an unexpected "
419407 << (isBottomUp ? "Height" : "Depth") << " value!\n";
420408 AnyNotSched = true;
423411 if (SUnit.NumSuccsLeft != 0) {
424412 if (!AnyNotSched)
425413 dbgs() << "*** Scheduling failed! ***\n";
426 SUnit.dump(this);
414 dumpNode(SUnit);
427415 dbgs() << "has successors left!\n";
428416 AnyNotSched = true;
429417 }
431419 if (SUnit.NumPredsLeft != 0) {
432420 if (!AnyNotSched)
433421 dbgs() << "*** Scheduling failed! ***\n";
434 SUnit.dump(this);
422 dumpNode(SUnit);
435423 dbgs() << "has predecessors left!\n";
436424 AnyNotSched = true;
437425 }
10961096 }
10971097 }
10981098
1099 void ScheduleDAGInstrs::dumpNode(const SUnit *SU) const {
1100 // Cannot completely remove virtual function even in release mode.
1099 void ScheduleDAGInstrs::dumpNode(const SUnit &SU) const {
11011100 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1102 SU->getInstr()->dump();
1101 dumpNodeName(SU);
1102 dbgs() << ": ";
1103 SU.getInstr()->dump();
1104 #endif
1105 }
1106
1107 void ScheduleDAGInstrs::dump() const {
1108 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1109 if (EntrySU.getInstr() != nullptr)
1110 dumpNodeAll(EntrySU);
1111 for (const SUnit &SU : SUnits)
1112 dumpNodeAll(SU);
1113 if (ExitSU.getInstr() != nullptr)
1114 dumpNodeAll(ExitSU);
11031115 #endif
11041116 }
11051117
156156
157157 if (!freeUnits) {
158158 LLVM_DEBUG(dbgs() << "*** Hazard in cycle +" << StageCycle << ", ");
159 LLVM_DEBUG(dbgs() << "SU(" << SU->NodeNum << "): ");
160 LLVM_DEBUG(DAG->dumpNode(SU));
159 LLVM_DEBUG(DAG->dumpNode(*SU));
161160 return Hazard;
162161 }
163162 }
124124 // Build the scheduling graph.
125125 BuildSchedGraph(nullptr);
126126
127 LLVM_DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) SUnits[su]
128 .dumpAll(this));
127 LLVM_DEBUG(dump());
129128
130129 // Execute the actual scheduling loop.
131130 ListScheduleBottomUp();
143142 #ifndef NDEBUG
144143 if (PredSU->NumSuccsLeft == 0) {
145144 dbgs() << "*** Scheduling failed! ***\n";
146 PredSU->dump(this);
145 dumpNode(*PredSU);
147146 dbgs() << " has been released too many times!\n";
148147 llvm_unreachable(nullptr);
149148 }
181180 /// the Available queue.
182181 void ScheduleDAGFast::ScheduleNodeBottomUp(SUnit *SU, unsigned CurCycle) {
183182 LLVM_DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: ");
184 LLVM_DEBUG(SU->dump(this));
183 LLVM_DEBUG(dumpNode(*SU));
185184
186185 assert(CurCycle >= SU->getHeight() && "Node scheduled below its height!");
187186 SU->setHeightToAtLeast(CurCycle);
364364 // Build the scheduling graph.
365365 BuildSchedGraph(nullptr);
366366
367 LLVM_DEBUG(for (SUnit &SU : SUnits) SU.dumpAll(this));
367 LLVM_DEBUG(dump());
368368 Topo.InitDAGTopologicalSorting();
369369
370370 AvailableQueue->initNodes(SUnits);
395395 #ifndef NDEBUG
396396 if (PredSU->NumSuccsLeft == 0) {
397397 dbgs() << "*** Scheduling failed! ***\n";
398 PredSU->dump(this);
398 dumpNode(*PredSU);
399399 dbgs() << " has been released too many times!\n";
400400 llvm_unreachable(nullptr);
401401 }
728728 /// the Available queue.
729729 void ScheduleDAGRRList::ScheduleNodeBottomUp(SUnit *SU) {
730730 LLVM_DEBUG(dbgs() << "\n*** Scheduling [" << CurCycle << "]: ");
731 LLVM_DEBUG(SU->dump(this));
731 LLVM_DEBUG(dumpNode(*SU));
732732
733733 #ifndef NDEBUG
734734 if (CurCycle < SU->getHeight())
827827 /// its predecessor states to reflect the change.
828828 void ScheduleDAGRRList::UnscheduleNodeBottomUp(SUnit *SU) {
829829 LLVM_DEBUG(dbgs() << "*** Unscheduling [" << SU->getHeight() << "]: ");
830 LLVM_DEBUG(SU->dump(this));
830 LLVM_DEBUG(dumpNode(*SU));
831831
832832 for (SDep &Pred : SU->Preds) {
833833 CapturePred(&Pred);
11291129 return nullptr;
11301130
11311131 LLVM_DEBUG(dbgs() << "Considering duplicating the SU\n");
1132 LLVM_DEBUG(SU->dump(this));
1132 LLVM_DEBUG(dumpNode(*SU));
11331133
11341134 if (N->getGluedNode() &&
11351135 !TII->canCopyGluedNodeDuringSchedule(N)) {
18871887 while (!DumpQueue.empty()) {
18881888 SUnit *SU = popFromQueue(DumpQueue, DumpPicker, scheduleDAG);
18891889 dbgs() << "Height " << SU->getHeight() << ": ";
1890 SU->dump(DAG);
1890 DAG->dumpNode(*SU);
18911891 }
18921892 }
18931893 #endif
647647 dep.setLatency(Latency);
648648 }
649649
650 void ScheduleDAGSDNodes::dumpNode(const SUnit *SU) const {
651 // Cannot completely remove virtual function even in release mode.
650 void ScheduleDAGSDNodes::dumpNode(const SUnit &SU) const {
652651 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
653 if (!SU->getNode()) {
652 dumpNodeName(SU);
653 dbgs() << ": ";
654
655 if (!SU.getNode()) {
654656 dbgs() << "PHYS REG COPY\n";
655657 return;
656658 }
657659
658 SU->getNode()->dump(DAG);
660 SU.getNode()->dump(DAG);
659661 dbgs() << "\n";
660662 SmallVector GluedNodes;
661 for (SDNode *N = SU->getNode()->getGluedNode(); N; N = N->getGluedNode())
663 for (SDNode *N = SU.getNode()->getGluedNode(); N; N = N->getGluedNode())
662664 GluedNodes.push_back(N);
663665 while (!GluedNodes.empty()) {
664666 dbgs() << " ";
669671 #endif
670672 }
671673
674 void ScheduleDAGSDNodes::dump() const {
675 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
676 if (EntrySU.getNode() != nullptr)
677 dumpNodeAll(EntrySU);
678 for (const SUnit &SU : SUnits)
679 dumpNodeAll(SU);
680 if (ExitSU.getNode() != nullptr)
681 dumpNodeAll(ExitSU);
682 #endif
683 }
684
672685 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
673686 void ScheduleDAGSDNodes::dumpSchedule() const {
674687 for (unsigned i = 0, e = Sequence.size(); i != e; i++) {
675688 if (SUnit *SU = Sequence[i])
676 SU->dump(this);
689 dumpNode(*SU);
677690 else
678691 dbgs() << "**** NOOP ****\n";
679692 }
121121 virtual MachineBasicBlock*
122122 EmitSchedule(MachineBasicBlock::iterator &InsertPos);
123123
124 void dumpNode(const SUnit *SU) const override;
125
124 void dumpNode(const SUnit &SU) const override;
125 void dump() const override;
126126 void dumpSchedule() const;
127127
128128 std::string getGraphNodeLabel(const SUnit *SU) const override;
117117 #ifndef NDEBUG
118118 if (SuccSU->NumPredsLeft == 0) {
119119 dbgs() << "*** Scheduling failed! ***\n";
120 SuccSU->dump(this);
120 dumpNode(*SuccSU);
121121 dbgs() << " has been released too many times!\n";
122122 llvm_unreachable(nullptr);
123123 }
151151 /// the Available queue.
152152 void ScheduleDAGVLIW::scheduleNodeTopDown(SUnit *SU, unsigned CurCycle) {
153153 LLVM_DEBUG(dbgs() << "*** Scheduling [" << CurCycle << "]: ");
154 LLVM_DEBUG(SU->dump(this));
154 LLVM_DEBUG(dumpNode(*SU));
155155
156156 Sequence.push_back(SU);
157157 assert(CurCycle >= SU->getDepth() && "Node scheduled above its depth!");
334334 assert(C);
335335 AvailQueue.remove(*C);
336336 auto SU = C->SU;
337 LLVM_DEBUG(dbgs() << "Selected "; SU->dump(&DAG));
337 LLVM_DEBUG(dbgs() << "Selected "; DAG.dumpNode(*SU));
338338
339339 advanceToCycle(SU->getHeight());
340340
257257 assert(C);
258258 RQ.remove(*C);
259259 auto SU = C->SU;
260 LLVM_DEBUG(dbgs() << "Selected "; SU->dump(&DAG));
260 LLVM_DEBUG(dbgs() << "Selected "; DAG.dumpNode(*SU));
261261
262262 releaseSuccessors(SU, StepNo);
263263 Schedule.push_back(SU);
126126
127127 LLVM_DEBUG(if (SU) {
128128 dbgs() << " ** Pick node **\n";
129 SU->dump(DAG);
129 DAG->dumpNode(*SU);
130130 } else {
131131 dbgs() << "NO NODE \n";
132132 for (unsigned i = 0; i < DAG->SUnits.size(); i++) {
133133 const SUnit &S = DAG->SUnits[i];
134134 if (!S.isScheduled)
135 S.dump(DAG);
135 DAG->dumpNode(S);
136136 }
137137 });
138138
187187 }
188188
189189 void R600SchedStrategy::releaseTopNode(SUnit *SU) {
190 LLVM_DEBUG(dbgs() << "Top Releasing "; SU->dump(DAG););
190 LLVM_DEBUG(dbgs() << "Top Releasing "; DAG->dumpNode(*SU));
191191 }
192192
193193 void R600SchedStrategy::releaseBottomNode(SUnit *SU) {
194 LLVM_DEBUG(dbgs() << "Bottom Releasing "; SU->dump(DAG););
194 LLVM_DEBUG(dbgs() << "Bottom Releasing "; DAG->dumpNode(*SU));
195195 if (isPhysicalRegCopy(SU->getInstr())) {
196196 PhysicalRegCopy.push_back(SU);
197197 return;
470470 #ifndef NDEBUG
471471 if (SuccSU->NumPredsLeft == 0) {
472472 dbgs() << "*** Scheduling failed! ***\n";
473 SuccSU->dump(DAG);
473 DAG->dumpNode(*SuccSU);
474474 dbgs() << " has been released too many times!\n";
475475 llvm_unreachable(nullptr);
476476 }
610610
611611 dbgs() << "\nInstructions:\n";
612612 if (!Scheduled) {
613 for (SUnit* SU : SUnits) {
614 SU->dump(DAG);
615 }
613 for (const SUnit* SU : SUnits)
614 DAG->dumpNode(*SU);
616615 } else {
617 for (SUnit* SU : SUnits) {
618 SU->dump(DAG);
619 }
616 for (const SUnit* SU : SUnits)
617 DAG->dumpNode(*SU);
620618 }
621619
622620 dbgs() << "///////////////////////\n";
19321930 LLVM_DEBUG(dbgs() << "Preparing Scheduling\n");
19331931
19341932 buildDAGWithRegPressure();
1935 LLVM_DEBUG(for (SUnit &SU : SUnits) SU.dumpAll(this));
1933 LLVM_DEBUG(dump());
19361934
19371935 topologicalSort();
19381936 findRootsAndBiasEdges(TopRoots, BotRoots);
214214 ++su) if (SUnits[su].getDepth() > maxD) maxD =
215215 SUnits[su].getDepth();
216216 dbgs() << "Max Depth " << maxD << "\n";);
217 LLVM_DEBUG(for (unsigned su = 0, e = SUnits.size(); su != e; ++su) SUnits[su]
218 .dumpAll(this));
217 LLVM_DEBUG(dump());
219218
220219 initQueues(TopRoots, BotRoots);
221220
488487 else
489488 dbgs() << " ";
490489 dbgs() << "cost(" << Cost << ")\t";
491 SU->dump(DAG);
490 DAG->dumpNode(*SU);
492491 }
493492
494493 // Very detailed queue dump, to be used with higher verbosity levels.
981980 << " Scheduling instruction in cycle "
982981 << (IsTopNode ? Top.CurrCycle : Bot.CurrCycle) << " ("
983982 << reportPackets() << ")\n";
984 SU->dump(DAG));
983 DAG->dumpNode(*SU));
985984 return SU;
986985 }
987986
179179 CurGroup.clear();
180180 CurSlots = CurBranches = 0;
181181 } else {
182 LLVM_DEBUG(dbgs() << "**** Adding to dispatch group: SU(" << SU->NodeNum
183 << "): ");
184 LLVM_DEBUG(DAG->dumpNode(SU));
182 LLVM_DEBUG(dbgs() << "**** Adding to dispatch group: ");
183 LLVM_DEBUG(DAG->dumpNode(*SU));
185184
186185 unsigned NSlots;
187186 bool MustBeFirst = mustComeFirst(MCID, NSlots);