From c7f98332383d71a57699426027e82c435e91addc Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sat, 15 Oct 2022 02:34:34 -0400 Subject: Module: fix early exit conditions during compilation * `--verbose-llvm-ir` should trigger analysis and codegen * `-femit-asm` etc should trigger codegen even with `-fno-emit-bin` Closes #12588 --- src/Module.zig | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index fd5cf29516..4edba007e9 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4319,10 +4319,9 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void { comp.emit_llvm_bc == null); const dump_air = builtin.mode == .Debug and comp.verbose_air; + const dump_llvm_ir = builtin.mode == .Debug and comp.verbose_llvm_ir; - if (no_bin_file and !dump_air) { - return; - } + if (no_bin_file and !dump_air and !dump_llvm_ir) return; log.debug("analyze liveness of {s}", .{decl.name}); var liveness = try Liveness.analyze(gpa, air); @@ -4337,9 +4336,7 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void { std.debug.print("# End Function AIR: {s}\n\n", .{fqn}); } - if (no_bin_file) { - return; - } + if (no_bin_file and !dump_llvm_ir) return; comp.bin_file.updateFunc(mod, func, air, liveness) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, @@ -6484,7 +6481,14 @@ pub fn populateTestFunctions(mod: *Module) !void { pub fn linkerUpdateDecl(mod: *Module, decl_index: Decl.Index) !void { const comp = mod.comp; - if (comp.bin_file.options.emit == null) return; + const no_bin_file = (comp.bin_file.options.emit == null and + comp.emit_asm == null and + comp.emit_llvm_ir == null and + comp.emit_llvm_bc == null); + + const dump_llvm_ir = builtin.mode == .Debug and comp.verbose_llvm_ir; + + if (no_bin_file and !dump_llvm_ir) return; const decl = mod.declPtr(decl_index); -- cgit v1.2.3