summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
diff options
context:
space:
mode:
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 {