aboutsummaryrefslogtreecommitdiff
path: root/src/zig_llvm.cpp
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-07-23 17:06:19 +0200
committerJakub Konka <kubkon@jakubkonka.com>2021-07-23 17:06:19 +0200
commit5533f77054acad376f2fce0d529569a7449e9949 (patch)
treeeba6945383fefa59a8858f7eec8beee3cfca7731 /src/zig_llvm.cpp
parent1beda818e1c10bde98b35759b3c131a864be58d9 (diff)
parente5b476209a1215a03164890d331e2013f20882a6 (diff)
downloadzig-5533f77054acad376f2fce0d529569a7449e9949.tar.gz
zig-5533f77054acad376f2fce0d529569a7449e9949.zip
Merge remote-tracking branch 'origin/master' into zld-incremental-2
Diffstat (limited to 'src/zig_llvm.cpp')
-rw-r--r--src/zig_llvm.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp
index 6d40f4089a..d5d6f9f670 100644
--- a/src/zig_llvm.cpp
+++ b/src/zig_llvm.cpp
@@ -229,12 +229,14 @@ struct TimeTracerRAII {
bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref,
char **error_message, bool is_debug,
bool is_small, bool time_report, bool tsan, bool lto,
- const char *asm_filename, const char *bin_filename, const char *llvm_ir_filename)
+ const char *asm_filename, const char *bin_filename,
+ const char *llvm_ir_filename, const char *bitcode_filename)
{
TimePassesIsEnabled = time_report;
raw_fd_ostream *dest_asm_ptr = nullptr;
raw_fd_ostream *dest_bin_ptr = nullptr;
+ raw_fd_ostream *dest_bitcode_ptr = nullptr;
if (asm_filename) {
std::error_code EC;
@@ -252,9 +254,19 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM
return true;
}
}
+ if (bitcode_filename) {
+ std::error_code EC;
+ dest_bitcode_ptr = new(std::nothrow) raw_fd_ostream(bitcode_filename, EC, sys::fs::F_None);
+ if (EC) {
+ *error_message = strdup((const char *)StringRef(EC.message()).bytes_begin());
+ return true;
+ }
+ }
std::unique_ptr<raw_fd_ostream> dest_asm(dest_asm_ptr),
- dest_bin(dest_bin_ptr);
+ dest_bin(dest_bin_ptr),
+ dest_bitcode(dest_bitcode_ptr);
+
auto PID = sys::Process::getProcessId();
std::string ProcName = "zig-";
@@ -389,6 +401,9 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM
if (dest_bin && lto) {
WriteBitcodeToFile(module, *dest_bin);
}
+ if (dest_bitcode) {
+ WriteBitcodeToFile(module, *dest_bitcode);
+ }
if (time_report) {
TimerGroup::printAll(errs());