summaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriterPass.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/Bitcode/Writer/BitcodeWriterPass.cpp
parent3cf539fb046457a444e93cefc87cca10cbd3b807 (diff)
[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/Bitcode/Writer/BitcodeWriterPass.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
index de2396f31f66..4f2486c963e9 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
@@ -21,19 +21,14 @@ using namespace llvm;
extern bool WriteNewDbgInfoFormatToBitcode;
PreservedAnalyses BitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) {
- bool ConvertToOldDbgFormatForWrite =
- M.IsNewDbgInfoFormat && !WriteNewDbgInfoFormatToBitcode;
- if (ConvertToOldDbgFormatForWrite)
- M.convertFromNewDbgValues();
+ ScopedDbgInfoFormatSetter FormatSetter(M, M.IsNewDbgInfoFormat &&
+ WriteNewDbgInfoFormatToBitcode);
const ModuleSummaryIndex *Index =
EmitSummaryIndex ? &(AM.getResult<ModuleSummaryIndexAnalysis>(M))
: nullptr;
WriteBitcodeToFile(M, OS, ShouldPreserveUseListOrder, Index, EmitModuleHash);
- if (ConvertToOldDbgFormatForWrite)
- M.convertToNewDbgValues();
-
return PreservedAnalyses::all();
}
@@ -57,16 +52,12 @@ namespace {
StringRef getPassName() const override { return "Bitcode Writer"; }
bool runOnModule(Module &M) override {
- bool ConvertToOldDbgFormatForWrite =
- M.IsNewDbgInfoFormat && !WriteNewDbgInfoFormatToBitcode;
- if (ConvertToOldDbgFormatForWrite)
- M.convertFromNewDbgValues();
+ ScopedDbgInfoFormatSetter FormatSetter(
+ M, M.IsNewDbgInfoFormat && WriteNewDbgInfoFormatToBitcode);
WriteBitcodeToFile(M, OS, ShouldPreserveUseListOrder, /*Index=*/nullptr,
/*EmitModuleHash=*/false);
- if (ConvertToOldDbgFormatForWrite)
- M.convertToNewDbgValues();
return false;
}
void getAnalysisUsage(AnalysisUsage &AU) const override {