Skip to content

Commit 1b2324d

Browse files
committed
Cleanup in preparation for misched: Move DAG visualization logic.
Soon, ScheduleDAG will not refer to the BB. llvm-svn: 152177
1 parent 320c703 commit 1b2324d

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

llvm/include/llvm/CodeGen/ScheduleDAG.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ namespace llvm {
519519
/// viewGraph - Pop up a GraphViz/gv window with the ScheduleDAG rendered
520520
/// using 'dot'.
521521
///
522+
void viewGraph(const Twine &Name, const Twine &Title);
522523
void viewGraph();
523524

524525
/// EmitSchedule - Insert MachineInstrs into the MachineBasicBlock
@@ -534,6 +535,9 @@ namespace llvm {
534535
/// of the ScheduleDAG.
535536
virtual std::string getGraphNodeLabel(const SUnit *SU) const = 0;
536537

538+
/// getDAGLabel - Return a label for the region of code covered by the DAG.
539+
virtual std::string getDAGName() const = 0;
540+
537541
/// addCustomGraphFeatures - Add custom features for a visualization of
538542
/// the ScheduleDAG.
539543
virtual void addCustomGraphFeatures(GraphWriter<ScheduleDAG*> &) const {}

llvm/lib/CodeGen/ScheduleDAGInstrs.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,12 @@ std::string ScheduleDAGInstrs::getGraphNodeLabel(const SUnit *SU) const {
808808
return oss.str();
809809
}
810810

811+
/// Return the basic block label. It is not necessarilly unique because a block
812+
/// contains multiple scheduling regions. But it is fine for visualization.
813+
std::string ScheduleDAGInstrs::getDAGName() const {
814+
return "dag." + BB->getFullName();
815+
}
816+
811817
// EmitSchedule - Emit the machine code in scheduled order.
812818
MachineBasicBlock *ScheduleDAGInstrs::EmitSchedule() {
813819
Begin = InsertPos;

llvm/lib/CodeGen/ScheduleDAGInstrs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ namespace llvm {
285285

286286
virtual std::string getGraphNodeLabel(const SUnit *SU) const;
287287

288+
virtual std::string getDAGName() const;
289+
288290
protected:
289291
SUnit *getSUnit(MachineInstr *MI) const {
290292
DenseMap<MachineInstr*, SUnit*>::const_iterator I = MISUnitMap.find(MI);

llvm/lib/CodeGen/ScheduleDAGPrinter.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,17 @@ std::string DOTGraphTraits<ScheduleDAG*>::getNodeLabel(const SUnit *SU,
8181
/// viewGraph - Pop up a ghostview window with the reachable parts of the DAG
8282
/// rendered using 'dot'.
8383
///
84-
void ScheduleDAG::viewGraph() {
85-
// This code is only for debugging!
84+
void ScheduleDAG::viewGraph(const Twine &Name, const Twine &Title) {
85+
// This code is only for debugging!
8686
#ifndef NDEBUG
87-
if (BB->getBasicBlock())
88-
ViewGraph(this, "dag." + MF.getFunction()->getName(), false,
89-
"Scheduling-Units Graph for " + MF.getFunction()->getName() +
90-
":" + BB->getBasicBlock()->getName());
91-
else
92-
ViewGraph(this, "dag." + MF.getFunction()->getName(), false,
93-
"Scheduling-Units Graph for " + MF.getFunction()->getName());
87+
ViewGraph(this, Name, false, Title);
9488
#else
9589
errs() << "ScheduleDAG::viewGraph is only available in debug builds on "
9690
<< "systems with Graphviz or gv!\n";
9791
#endif // NDEBUG
9892
}
93+
94+
/// Out-of-line implementation with no arguments is handy for gdb.
95+
void ScheduleDAG::viewGraph() {
96+
viewGraph(getDAGName(), "Scheduling-Units Graph for " + getDAGName());
97+
}

llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,3 +800,8 @@ MachineBasicBlock *ScheduleDAGSDNodes::EmitSchedule() {
800800
InsertPos = Emitter.getInsertPos();
801801
return BB;
802802
}
803+
804+
/// Return the basic block label.
805+
std::string ScheduleDAGSDNodes::getDAGName() const {
806+
return "sunit-dag." + BB->getFullName();
807+
}

llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ namespace llvm {
115115

116116
virtual std::string getGraphNodeLabel(const SUnit *SU) const;
117117

118+
virtual std::string getDAGName() const;
119+
118120
virtual void getCustomGraphFeatures(GraphWriter<ScheduleDAG*> &GW) const;
119121

120122
/// RegDefIter - In place iteration over the values defined by an

0 commit comments

Comments
 (0)