authorgravatar for rpkak@noreply.codeberg.orgrpkak <rpkak@noreply.codeberg.org> 2026-08-14 11:25:26+02:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-10-17 03:55:33+02:00
log1ab08d09cb123352ebc33e3510196ce95c9b7aa4
treebae091abdb76804cddc2de3e65cfc6512e3aed07
parentf72a1d4e161e290f2791b5d6f7b746d66e181e59

-femit-llvm-bc: output optimized llvm bc


1 files changed, 4 insertions(+), 14 deletions(-)

src/codegen/llvm.zig+4-14
......@@ -336,7 +336,7 @@ pub const Object = struct {
336336 bin_path: ?[:0]const u8,
337337 asm_path: ?[:0]const u8,
338338 post_ir_path: ?[:0]const u8,
339 post_bc_path: ?[]const u8,
339 post_bc_path: ?[:0]const u8,
340340
341341 is_debug: bool,
342342 is_small: bool,
......@@ -543,24 +543,13 @@ pub const Object = struct {
543543 return diags.fail("failed to create '{s}': {t}", .{ path, err });
544544 defer file.close(io);
545545
546 const ptr: [*]const u8 = @ptrCast(bitcode.ptr);
547 file.writeStreamingAll(io, ptr[0..(bitcode.len * 4)]) catch |err|
546 file.writeStreamingAll(io, @ptrCast(bitcode)) catch |err|
548547 return diags.fail("failed to write to '{s}': {t}", .{ path, err });
549548 }
550549
551550 if (options.asm_path == null and options.bin_path == null and
552551 options.post_ir_path == null and options.post_bc_path == null) return;
553552
554 if (options.post_bc_path) |path| {
555 var file = Io.Dir.cwd().createFile(io, path, .{}) catch |err|
556 return diags.fail("failed to create '{s}': {t}", .{ path, err });
557 defer file.close(io);
558
559 const ptr: [*]const u8 = @ptrCast(bitcode.ptr);
560 file.writeStreamingAll(io, ptr[0..(bitcode.len * 4)]) catch |err|
561 return diags.fail("failed to write to '{s}': {t}", .{ path, err });
562 }
563
564553 if (!build_options.have_llvm or !comp.config.use_lib_llvm) {
565554 return diags.fail("emitting without libllvm not implemented", .{});
566555 }
......@@ -663,7 +652,7 @@ pub const Object = struct {
663652 .asm_filename = null,
664653 .bin_filename = if (options.bin_path) |x| x.ptr else null,
665654 .llvm_ir_filename = if (options.post_ir_path) |x| x.ptr else null,
666 .bitcode_filename = null,
655 .bitcode_filename = if (options.post_bc_path) |x| x.ptr else null,
667656
668657 // `.coverage` value is only used when `.sancov` is enabled.
669658 .sancov = options.fuzz or comp.config.san_cov_trace_pc_guard,
......@@ -702,6 +691,7 @@ pub const Object = struct {
702691 }
703692 lowered_options.bin_filename = null;
704693 lowered_options.llvm_ir_filename = null;
694 lowered_options.bitcode_filename = null;
705695 }
706696
707697 var time_report_c_str: [*:0]u8 = undefined;