diff options
| author | Ziv Dunkelman <ziv.dunkelman@nextsilicon.com> | 2022-06-08 17:30:16 +0300 |
|---|---|---|
| committer | Ziv Dunkelman <ziv.dunkelman@nextsilicon.com> | 2022-07-14 22:21:26 +0300 |
| commit | 724c91234dd49b88d70ebead406d09105695c3e5 (patch) | |
| tree | 9ec0f63fb06cfab879d0939d3e467d63decffa59 /compiler/rustc_llvm/llvm-wrapper | |
| parent | 0ed9c64c3e63acac9bd77abce62501696c390450 (diff) | |
| download | rust-724c91234dd49b88d70ebead406d09105695c3e5.tar.gz rust-724c91234dd49b88d70ebead406d09105695c3e5.zip | |
rustc: add ability to output regular LTO bitcode modules
Adding the option to control from rustc CLI if the resulted ".o" bitcode module files are with thinLTO info or regular LTO info. Allows using "-lto-embed-bitcode=optimized" during linkage correctly. Signed-off-by: Ziv Dunkelman <ziv.dunkelman@nextsilicon.com>
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper')
| -rw-r--r-- | compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 0f4973ebf71..3aac4d83716 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -34,6 +34,7 @@ #include "llvm/Transforms/Utils/AddDiscriminators.h" #include "llvm/Transforms/Utils/FunctionImportUtils.h" #include "llvm/LTO/LTO.h" +#include "llvm/Bitcode/BitcodeWriterPass.h" #include "llvm-c/Transforms/PassManagerBuilder.h" #include "llvm/Transforms/Instrumentation.h" @@ -1638,13 +1639,17 @@ struct LLVMRustThinLTOBuffer { }; extern "C" LLVMRustThinLTOBuffer* -LLVMRustThinLTOBufferCreate(LLVMModuleRef M) { +LLVMRustThinLTOBufferCreate(LLVMModuleRef M, bool is_thin) { auto Ret = std::make_unique<LLVMRustThinLTOBuffer>(); { raw_string_ostream OS(Ret->data); { legacy::PassManager PM; - PM.add(createWriteThinLTOBitcodePass(OS)); + if (is_thin) { + PM.add(createWriteThinLTOBitcodePass(OS)); + } else { + PM.add(createBitcodeWriterPass(OS)); + } PM.run(*unwrap(M)); } } |
