aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2022-10-15 02:34:34 -0400
committerAndrew Kelley <andrew@ziglang.org>2022-10-15 14:18:35 -0400
commitc7f98332383d71a57699426027e82c435e91addc (patch)
treeb6a97bb72808d47a001085403254c0fc9d75b82b /src/Module.zig
parentcb0e22db4e18dd803e1edd681c836fadbae0ea6f (diff)
downloadzig-c7f98332383d71a57699426027e82c435e91addc.tar.gz
zig-c7f98332383d71a57699426027e82c435e91addc.zip
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
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig18
1 files changed, 11 insertions, 7 deletions
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);