aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-09-09 10:26:17 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-09-09 10:26:17 -0700
commit37cdb5dbf90acd61584bae4a6661d0a6f9b54295 (patch)
tree6b369bbd58603d40b17b0e16e157a757b4a01616 /src/Module.zig
parentb7900de1684021ff86c67105e14e34968821ea02 (diff)
parent9e070b653c89a9216f9dd9f78ed7c78c11460ac7 (diff)
downloadzig-37cdb5dbf90acd61584bae4a6661d0a6f9b54295.tar.gz
zig-37cdb5dbf90acd61584bae4a6661d0a6f9b54295.zip
Merge remote-tracking branch 'origin/master' into llvm15
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/Module.zig b/src/Module.zig
index c63fe43158..ea89225537 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -345,6 +345,15 @@ pub const CaptureScope = struct {
/// During sema, this map is backed by the gpa. Once sema completes,
/// it is reallocated using the value_arena.
captures: std.AutoHashMapUnmanaged(Zir.Inst.Index, TypedValue) = .{},
+
+ pub fn failed(noalias self: *const @This()) bool {
+ return self.captures.available == 0 and self.captures.size == std.math.maxInt(u32);
+ }
+
+ pub fn fail(noalias self: *@This()) void {
+ self.captures.available = 0;
+ self.captures.size = std.math.maxInt(u32);
+ }
};
pub const WipCaptureScope = struct {
@@ -383,6 +392,7 @@ pub const WipCaptureScope = struct {
pub fn deinit(noalias self: *@This()) void {
if (!self.finalized) {
self.scope.captures.deinit(self.gpa);
+ self.scope.fail();
}
self.* = undefined;
}
@@ -4274,11 +4284,14 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void {
const comp = mod.comp;
- if (comp.bin_file.options.emit == null and
+ 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)
- {
+ comp.emit_llvm_bc == null);
+
+ const dump_air = builtin.mode == .Debug and comp.verbose_air;
+
+ if (no_bin_file and !dump_air) {
return;
}
@@ -4286,7 +4299,7 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void {
var liveness = try Liveness.analyze(gpa, air);
defer liveness.deinit(gpa);
- if (builtin.mode == .Debug and comp.verbose_air) {
+ if (dump_air) {
const fqn = try decl.getFullyQualifiedName(mod);
defer mod.gpa.free(fqn);
@@ -4295,6 +4308,10 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void {
std.debug.print("# End Function AIR: {s}\n\n", .{fqn});
}
+ if (no_bin_file) {
+ return;
+ }
+
comp.bin_file.updateFunc(mod, func, air, liveness) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
error.AnalysisFail => {