[llvm] 1dfb06d - [regalloc] Add a couple of dump routines for ease of debugging [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 18 08:50:43 PST 2021
Author: Philip Reames
Date: 2021-02-18T08:50:00-08:00
New Revision: 1dfb06d0b40e875d524b2b43fc95ce81a41ce014
URL: https://github.com/llvm/llvm-project/commit/1dfb06d0b40e875d524b2b43fc95ce81a41ce014
DIFF: https://github.com/llvm/llvm-project/commit/1dfb06d0b40e875d524b2b43fc95ce81a41ce014.diff
LOG: [regalloc] Add a couple of dump routines for ease of debugging [NFC]
Added:
Modified:
llvm/lib/CodeGen/SpillPlacement.cpp
llvm/lib/CodeGen/SpillPlacement.h
llvm/lib/CodeGen/SplitKit.cpp
llvm/lib/CodeGen/SplitKit.h
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SpillPlacement.cpp b/llvm/lib/CodeGen/SpillPlacement.cpp
index 4bb50a285497..b1597519f6bc 100644
--- a/llvm/lib/CodeGen/SpillPlacement.cpp
+++ b/llvm/lib/CodeGen/SpillPlacement.cpp
@@ -377,3 +377,27 @@ SpillPlacement::finish() {
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/llvm/lib/CodeGen/SpillPlacement.h b/llvm/lib/CodeGen/SpillPlacement.h
index aa0e07ef92e3..d2273a163025 100644
--- a/llvm/lib/CodeGen/SpillPlacement.h
+++ b/llvm/lib/CodeGen/SpillPlacement.h
@@ -95,6 +95,9 @@ class SpillPlacement : public MachineFunctionPass {
/// 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/llvm/lib/CodeGen/SplitKit.cpp b/llvm/lib/CodeGen/SplitKit.cpp
index 8ffba4a47a46..ff993b4654d2 100644
--- a/llvm/lib/CodeGen/SplitKit.cpp
+++ b/llvm/lib/CodeGen/SplitKit.cpp
@@ -1812,3 +1812,16 @@ void SplitEditor::splitRegOutBlock(const SplitAnalysis::BlockInfo &BI,
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/llvm/lib/CodeGen/SplitKit.h b/llvm/lib/CodeGen/SplitKit.h
index a94518f5a4fc..ec51014f6fcd 100644
--- a/llvm/lib/CodeGen/SplitKit.h
+++ b/llvm/lib/CodeGen/SplitKit.h
@@ -131,6 +131,9 @@ class LLVM_LIBRARY_VISIBILITY SplitAnalysis {
bool isOneInstr() const {
return SlotIndex::isSameInstr(FirstInstr, LastInstr);
}
+
+ void print(raw_ostream &OS) const;
+ void dump() const;
};
private:
More information about the llvm-commits
mailing list