aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MIRPrinter.cpp
diff options
context:
space:
mode:
authorStephen Tozer <stephen.tozer@sony.com>2024-04-04 10:20:14 +0100
committerGitHub <noreply@github.com>2024-04-04 10:20:14 +0100
commit708ce8569067c2aabd3cc669b0db90f23e53b3b0 (patch)
treed618dbea1c20fcc16f11db83b58fd05d499a2c2c /llvm/lib/CodeGen/MIRPrinter.cpp
parent3cf539fb046457a444e93cefc87cca10cbd3b807 (diff)
downloadllvm-708ce8569067c2aabd3cc669b0db90f23e53b3b0.zip
llvm-708ce8569067c2aabd3cc669b0db90f23e53b3b0.tar.gz
llvm-708ce8569067c2aabd3cc669b0db90f23e53b3b0.tar.bz2
[RemoveDIs][NFC] Use ScopedDbgInfoFormatSetter in more places (#87380)
The class `ScopedDbgInfoFormatSetter` was added as a convenient way to temporarily change the debug info format of a function or module, as part of IR printing; since this process is repeated in a number of other places, this patch uses the format-setter class in those places as well.
Diffstat (limited to 'llvm/lib/CodeGen/MIRPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/MIRPrinter.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index bbc6d39..bf3aee6 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -69,6 +69,8 @@ static cl::opt<bool> SimplifyMIR(
static cl::opt<bool> PrintLocations("mir-debug-loc", cl::Hidden, cl::init(true),
cl::desc("Print MIR debug-locations"));
+extern cl::opt<bool> WriteNewDbgInfoFormat;
+
namespace {
/// This structure describes how to print out stack object references.
@@ -986,29 +988,19 @@ void MIRFormatter::printIRValue(raw_ostream &OS, const Value &V,
}
void llvm::printMIR(raw_ostream &OS, const Module &M) {
- // RemoveDIs: as there's no textual form for DbgRecords yet, print debug-info
- // in dbg.value format.
- bool IsNewDbgInfoFormat = M.IsNewDbgInfoFormat;
- if (IsNewDbgInfoFormat)
- const_cast<Module &>(M).convertFromNewDbgValues();
+ ScopedDbgInfoFormatSetter FormatSetter(const_cast<Module &>(M),
+ WriteNewDbgInfoFormat);
yaml::Output Out(OS);
Out << const_cast<Module &>(M);
-
- if (IsNewDbgInfoFormat)
- const_cast<Module &>(M).convertToNewDbgValues();
}
void llvm::printMIR(raw_ostream &OS, const MachineFunction &MF) {
// RemoveDIs: as there's no textual form for DbgRecords yet, print debug-info
// in dbg.value format.
- bool IsNewDbgInfoFormat = MF.getFunction().IsNewDbgInfoFormat;
- if (IsNewDbgInfoFormat)
- const_cast<Function &>(MF.getFunction()).convertFromNewDbgValues();
+ ScopedDbgInfoFormatSetter FormatSetter(
+ const_cast<Function &>(MF.getFunction()), WriteNewDbgInfoFormat);
MIRPrinter Printer(OS);
Printer.print(MF);
-
- if (IsNewDbgInfoFormat)
- const_cast<Function &>(MF.getFunction()).convertToNewDbgValues();
}