aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-07-15 15:52:06 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-07-20 12:19:16 -0700
commiteadbee2041bba1cd03b24d8f30161025af8e3590 (patch)
treeaebad285c7cd852fcc1c9d62f3beeb4395c6d04e /src/Module.zig
parent12c10139e3e0166e91d2dbb1801c2054ca12d413 (diff)
downloadzig-eadbee2041bba1cd03b24d8f30161025af8e3590.tar.gz
zig-eadbee2041bba1cd03b24d8f30161025af8e3590.zip
stage2: first pass at printing AIR/Liveness to text
* some instructions are not implemented yet * fix off-by-1 in Air.getMainBody * Compilation: use `@import("builtin")` rather than `std.builtin` for the values that are different for different build configurations. * Sema: avoid calling `addType` in between air_instructions.ensureUnusedCapacity and corresponding appendAssumeCapacity because it can possibly add an instruction. * Value: functions print their names
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Module.zig b/src/Module.zig
index fb514ccbd2..f452824d33 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -3551,7 +3551,8 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) SemaError!Air {
try sema.analyzeFnBody(&inner_block, func.zir_body_inst);
// Copy the block into place and mark that as the main block.
- try sema.air_extra.ensureUnusedCapacity(gpa, inner_block.instructions.items.len + 1);
+ try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len +
+ inner_block.instructions.items.len);
const main_block_index = sema.addExtraAssumeCapacity(Air.Block{
.body_len = @intCast(u32, inner_block.instructions.items.len),
});