[regalloc] Add a couple of dump routines for ease of debugging [NFC]
GitOrigin-RevId: 1dfb06d0b40e875d524b2b43fc95ce81a41ce014
diff --git a/lib/CodeGen/SpillPlacement.cpp b/lib/CodeGen/SpillPlacement.cpp
index 4bb50a2..b159751 100644
--- a/lib/CodeGen/SpillPlacement.cpp
+++ b/lib/CodeGen/SpillPlacement.cpp
@@ -377,3 +377,27 @@
ActiveNodes = nullptr;
return Perfect;
}
+
+void SpillPlacement::BlockConstraint::print(raw_ostream &OS) const {
+ auto toString = [](BorderConstraint C) -> StringRef {
+ switch(C) {
+ case DontCare: return "DontCare";
+ case PrefReg: return "PrefReg";
+ case PrefSpill: return "PrefSpill";
+ case PrefBoth: return "PrefBoth";
+ case MustSpill: return "MustSpill";
+ default:
+ llvm_unreachable("uncovered switch");
+ };
+ };
+
+ dbgs() << "{" << Number << ", "
+ << toString(Entry) << ", "
+ << toString(Exit) << ", "
+ << (ChangesValue ? "changes" : "no change") << "}";
+}
+
+void SpillPlacement::BlockConstraint::dump() const {
+ print(dbgs());
+ dbgs() << "\n";
+}
diff --git a/lib/CodeGen/SpillPlacement.h b/lib/CodeGen/SpillPlacement.h
index aa0e07e..d2273a1 100644
--- a/lib/CodeGen/SpillPlacement.h
+++ b/lib/CodeGen/SpillPlacement.h
@@ -95,6 +95,9 @@
/// the block has a non-PHI def. When this is false, a live-in value on
/// the stack can be live-out on the stack without inserting a spill.
bool ChangesValue;
+
+ void print(raw_ostream &OS) const;
+ void dump() const;
};
/// prepare - Reset state and prepare for a new spill placement computation.
diff --git a/lib/CodeGen/SplitKit.cpp b/lib/CodeGen/SplitKit.cpp
index 8ffba4a..ff993b4 100644
--- a/lib/CodeGen/SplitKit.cpp
+++ b/lib/CodeGen/SplitKit.cpp
@@ -1812,3 +1812,16 @@
SlotIndex From = enterIntvBefore(std::min(Idx, BI.FirstInstr));
useIntv(From, Idx);
}
+
+void SplitAnalysis::BlockInfo::print(raw_ostream &OS) const {
+ OS << "{" << printMBBReference(*MBB) << ", "
+ << "uses " << FirstInstr << " to " << LastInstr << ", "
+ << "1st def " << FirstDef << ", "
+ << (LiveIn ? "live in" : "dead in") << ", "
+ << (LiveOut ? "live out" : "dead out") << "}";
+}
+
+void SplitAnalysis::BlockInfo::dump() const {
+ print(dbgs());
+ dbgs() << "\n";
+}
diff --git a/lib/CodeGen/SplitKit.h b/lib/CodeGen/SplitKit.h
index a94518f..ec51014 100644
--- a/lib/CodeGen/SplitKit.h
+++ b/lib/CodeGen/SplitKit.h
@@ -131,6 +131,9 @@
bool isOneInstr() const {
return SlotIndex::isSameInstr(FirstInstr, LastInstr);
}
+
+ void print(raw_ostream &OS) const;
+ void dump() const;
};
private: