From 93ae386f560e7a3464df31b7c9bc9acdc231bc3f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 24 Jul 2022 14:31:00 -0700 Subject: stage2: don't skip liveness or codegen if -femit-asm is supplied Fixes Godbolt's CLI usage of Zig. --- src/Module.zig | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index fd97e5c948..c144c9acbd 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4122,13 +4122,21 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void { }; defer air.deinit(gpa); - if (mod.comp.bin_file.options.emit == null) return; + const comp = mod.comp; + + if (comp.bin_file.options.emit == null and + comp.emit_asm == null and + comp.emit_llvm_ir == null and + comp.emit_llvm_bc == null) + { + return; + } log.debug("analyze liveness of {s}", .{decl.name}); var liveness = try Liveness.analyze(gpa, air); defer liveness.deinit(gpa); - if (builtin.mode == .Debug and mod.comp.verbose_air) { + if (builtin.mode == .Debug and comp.verbose_air) { const fqn = try decl.getFullyQualifiedName(mod); defer mod.gpa.free(fqn); @@ -4137,7 +4145,7 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void { std.debug.print("# End Function AIR: {s}\n\n", .{fqn}); } - mod.comp.bin_file.updateFunc(mod, func, air, liveness) catch |err| switch (err) { + comp.bin_file.updateFunc(mod, func, air, liveness) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, error.AnalysisFail => { decl.analysis = .codegen_failure; -- cgit v1.2.3