diff options
Diffstat (limited to 'src/zig_llvm.cpp')
| -rw-r--r-- | src/zig_llvm.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp index 51af5e06d1..280920ac74 100644 --- a/src/zig_llvm.cpp +++ b/src/zig_llvm.cpp @@ -22,6 +22,7 @@ #include <llvm/Analysis/TargetLibraryInfo.h> #include <llvm/Analysis/TargetTransformInfo.h> +#include <llvm/Bitcode/BitcodeWriter.h> #include <llvm/IR/DIBuilder.h> #include <llvm/IR/DiagnosticInfo.h> #include <llvm/IR/IRBuilder.h> @@ -184,7 +185,7 @@ unsigned ZigLLVMDataLayoutGetProgramAddressSpace(LLVMTargetDataRef TD) { bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, char **error_message, bool is_debug, - bool is_small, bool time_report, bool tsan, + bool is_small, bool time_report, bool tsan, bool lto, const char *asm_filename, const char *bin_filename, const char *llvm_ir_filename) { TimePassesIsEnabled = time_report; @@ -234,7 +235,7 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM PMBuilder->VerifyInput = assertions_on; PMBuilder->VerifyOutput = assertions_on; PMBuilder->MergeFunctions = !is_debug; - PMBuilder->PrepareForLTO = false; + PMBuilder->PrepareForLTO = lto; PMBuilder->PrepareForThinLTO = false; PMBuilder->PerformThinLTO = false; @@ -272,7 +273,7 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM PMBuilder->populateModulePassManager(MPM); // Set output passes. - if (dest_bin) { + if (dest_bin && !lto) { if (target_machine->addPassesToEmitFile(MPM, *dest_bin, nullptr, CGFT_ObjectFile)) { *error_message = strdup("TargetMachine can't emit an object file"); return true; @@ -299,6 +300,9 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM return true; } } + if (dest_bin && lto) { + WriteBitcodeToFile(*module, *dest_bin); + } if (time_report) { TimerGroup::printAll(errs()); |
