stage2: implement liveness analysis

This commit is contained in:
Andrew Kelley
2020-06-29 21:58:34 -04:00
parent abcd4ea5d8
commit 8fb392dbb4
4 changed files with 207 additions and 11 deletions

View File

@@ -18,6 +18,7 @@ const Inst = ir.Inst;
const Body = ir.Body;
const ast = std.zig.ast;
const trace = @import("tracy.zig").trace;
const liveness = @import("liveness.zig");
/// General-purpose allocator.
allocator: *Allocator,
@@ -986,6 +987,11 @@ pub fn performAllTheWork(self: *Module) error{OutOfMemory}!void {
.sema_failure, .dependency_failure => continue,
.success => {},
}
// Here we tack on additional allocations to the Decl's arena. The allocations are
// lifetime annotations in the ZIR.
var decl_arena = decl.typed_value.most_recent.arena.?.promote(self.allocator);
defer decl.typed_value.most_recent.arena.?.* = decl_arena.state;
try liveness.analyze(self.allocator, &decl_arena.allocator, payload.func.analysis.success);
}
assert(decl.typed_value.most_recent.typed_value.ty.hasCodeGenBits());