Skip to content

Commit d6318de

Browse files
committed
Never use legacy PM for writing bitcode
1 parent 38e0e8f commit d6318de

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@
3131
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
3232
#include "llvm/Transforms/IPO/AlwaysInliner.h"
3333
#include "llvm/Transforms/IPO/FunctionImport.h"
34-
#if LLVM_VERSION_GE(15, 0)
3534
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
36-
#endif
3735
#include "llvm/Transforms/Utils/AddDiscriminators.h"
3836
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
3937
#include "llvm/LTO/LTO.h"
40-
#include "llvm/Bitcode/BitcodeWriterPass.h"
38+
#include "llvm/Bitcode/BitcodeWriter.h"
4139
#include "llvm-c/Transforms/PassManagerBuilder.h"
4240

4341
#include "llvm/Transforms/Instrumentation.h"
@@ -1377,11 +1375,6 @@ LLVMRustThinLTOBufferCreate(LLVMModuleRef M, bool is_thin) {
13771375
raw_string_ostream OS(Ret->data);
13781376
{
13791377
if (is_thin) {
1380-
#if LLVM_VERSION_LT(15, 0)
1381-
legacy::PassManager PM;
1382-
PM.add(createWriteThinLTOBitcodePass(OS));
1383-
PM.run(*unwrap(M));
1384-
#else
13851378
PassBuilder PB;
13861379
LoopAnalysisManager LAM;
13871380
FunctionAnalysisManager FAM;
@@ -1395,11 +1388,8 @@ LLVMRustThinLTOBufferCreate(LLVMModuleRef M, bool is_thin) {
13951388
ModulePassManager MPM;
13961389
MPM.addPass(ThinLTOBitcodeWriterPass(OS, nullptr));
13971390
MPM.run(*unwrap(M), MAM);
1398-
#endif
13991391
} else {
1400-
legacy::PassManager PM;
1401-
PM.add(createBitcodeWriterPass(OS));
1402-
PM.run(*unwrap(M));
1392+
WriteBitcodeToFile(*unwrap(M), OS);
14031393
}
14041394
}
14051395
}

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "llvm/Object/COFFImportFile.h"
1313
#include "llvm/Object/ObjectFile.h"
1414
#include "llvm/Pass.h"
15-
#include "llvm/Bitcode/BitcodeWriterPass.h"
15+
#include "llvm/Bitcode/BitcodeWriter.h"
1616
#include "llvm/Support/Signals.h"
1717
#include "llvm/ADT/Optional.h"
1818

@@ -1709,11 +1709,7 @@ LLVMRustModuleBufferCreate(LLVMModuleRef M) {
17091709
auto Ret = std::make_unique<LLVMRustModuleBuffer>();
17101710
{
17111711
raw_string_ostream OS(Ret->data);
1712-
{
1713-
legacy::PassManager PM;
1714-
PM.add(createBitcodeWriterPass(OS));
1715-
PM.run(*unwrap(M));
1716-
}
1712+
WriteBitcodeToFile(*unwrap(M), OS);
17171713
}
17181714
return Ret.release();
17191715
}

0 commit comments

Comments
 (0)