From 1dfb06d0b40e875d524b2b43fc95ce81a41ce014 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Thu, 18 Feb 2021 08:50:00 -0800 Subject: [PATCH] [regalloc] Add a couple of dump routines for ease of debugging [NFC] --- llvm/lib/CodeGen/SpillPlacement.cpp | 24 ++++++++++++++++++++++++ llvm/lib/CodeGen/SpillPlacement.h | 3 +++ llvm/lib/CodeGen/SplitKit.cpp | 13 +++++++++++++ llvm/lib/CodeGen/SplitKit.h | 3 +++ 4 files changed, 43 insertions(+) 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 @@ public: /// 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 @@ public: bool isOneInstr() const { return SlotIndex::isSameInstr(FirstInstr, LastInstr); } + + void print(raw_ostream &OS) const; + void dump() const; }; private: