| ... | @@ -1826,7 +1826,7 @@ fn astgenAndSemaDecl(mod: *Module, decl: *Decl) !bool { | ... | @@ -1826,7 +1826,7 @@ fn astgenAndSemaDecl(mod: *Module, decl: *Decl) !bool { |
| 1826 | | 1826 | |
| 1827 | const code = try gen_scope.finish(); | 1827 | const code = try gen_scope.finish(); |
| 1828 | if (std.builtin.mode == .Debug and mod.comp.verbose_ir) { | 1828 | if (std.builtin.mode == .Debug and mod.comp.verbose_ir) { |
| 1829 | zir.dumpZir(mod.gpa, "comptime_block", decl.name, code) catch {}; | 1829 | code.dump(mod.gpa, "comptime_block", decl.name) catch {}; |
| 1830 | } | 1830 | } |
| 1831 | break :blk code; | 1831 | break :blk code; |
| 1832 | }; | 1832 | }; |
| ... | @@ -1836,13 +1836,11 @@ fn astgenAndSemaDecl(mod: *Module, decl: *Decl) !bool { | ... | @@ -1836,13 +1836,11 @@ fn astgenAndSemaDecl(mod: *Module, decl: *Decl) !bool { |
| 1836 | .gpa = mod.gpa, | 1836 | .gpa = mod.gpa, |
| 1837 | .arena = &analysis_arena.allocator, | 1837 | .arena = &analysis_arena.allocator, |
| 1838 | .code = code, | 1838 | .code = code, |
| 1839 | .inst_map = try mod.gpa.alloc(*ir.Inst, code.instructions.len), | 1839 | .inst_map = try analysis_arena.allocator.alloc(*ir.Inst, code.instructions.len), |
| 1840 | .owner_decl = decl, | 1840 | .owner_decl = decl, |
| 1841 | .func = null, | 1841 | .func = null, |
| 1842 | .param_inst_list = &.{}, | 1842 | .param_inst_list = &.{}, |
| 1843 | }; | 1843 | }; |
| 1844 | defer mod.gpa.free(sema.inst_map); | | |
| 1845 | | | |
| 1846 | var block_scope: Scope.Block = .{ | 1844 | var block_scope: Scope.Block = .{ |
| 1847 | .parent = null, | 1845 | .parent = null, |
| 1848 | .sema = &sema, | 1846 | .sema = &sema, |
| ... | @@ -2049,7 +2047,7 @@ fn astgenAndSemaFn( | ... | @@ -2049,7 +2047,7 @@ fn astgenAndSemaFn( |
| 2049 | | 2047 | |
| 2050 | const fn_type_code = try fn_type_scope.finish(); | 2048 | const fn_type_code = try fn_type_scope.finish(); |
| 2051 | if (std.builtin.mode == .Debug and mod.comp.verbose_ir) { | 2049 | if (std.builtin.mode == .Debug and mod.comp.verbose_ir) { |
| 2052 | zir.dumpZir(mod.gpa, "fn_type", decl.name, fn_type_code) catch {}; | 2050 | fn_type_code.dump(mod.gpa, "fn_type", decl.name) catch {}; |
| 2053 | } | 2051 | } |
| 2054 | | 2052 | |
| 2055 | var fn_type_sema: Sema = .{ | 2053 | var fn_type_sema: Sema = .{ |
| ... | @@ -2057,13 +2055,11 @@ fn astgenAndSemaFn( | ... | @@ -2057,13 +2055,11 @@ fn astgenAndSemaFn( |
| 2057 | .gpa = mod.gpa, | 2055 | .gpa = mod.gpa, |
| 2058 | .arena = &decl_arena.allocator, | 2056 | .arena = &decl_arena.allocator, |
| 2059 | .code = fn_type_code, | 2057 | .code = fn_type_code, |
| 2060 | .inst_map = try mod.gpa.alloc(*ir.Inst, fn_type_code.instructions.len), | 2058 | .inst_map = try fn_type_scope_arena.allocator.alloc(*ir.Inst, fn_type_code.instructions.len), |
| 2061 | .owner_decl = decl, | 2059 | .owner_decl = decl, |
| 2062 | .func = null, | 2060 | .func = null, |
| 2063 | .param_inst_list = &.{}, | 2061 | .param_inst_list = &.{}, |
| 2064 | }; | 2062 | }; |
| 2065 | defer mod.gpa.free(fn_type_sema.inst_map); | | |
| 2066 | | | |
| 2067 | var block_scope: Scope.Block = .{ | 2063 | var block_scope: Scope.Block = .{ |
| 2068 | .parent = null, | 2064 | .parent = null, |
| 2069 | .sema = &fn_type_sema, | 2065 | .sema = &fn_type_sema, |
| ... | @@ -2174,7 +2170,7 @@ fn astgenAndSemaFn( | ... | @@ -2174,7 +2170,7 @@ fn astgenAndSemaFn( |
| 2174 | | 2170 | |
| 2175 | const code = try gen_scope.finish(); | 2171 | const code = try gen_scope.finish(); |
| 2176 | if (std.builtin.mode == .Debug and mod.comp.verbose_ir) { | 2172 | if (std.builtin.mode == .Debug and mod.comp.verbose_ir) { |
| 2177 | zir.dumpZir(mod.gpa, "fn_body", decl.name, code) catch {}; | 2173 | code.dump(mod.gpa, "fn_body", decl.name) catch {}; |
| 2178 | } | 2174 | } |
| 2179 | | 2175 | |
| 2180 | break :blk code; | 2176 | break :blk code; |
| ... | @@ -2351,7 +2347,7 @@ fn astgenAndSemaVarDecl( | ... | @@ -2351,7 +2347,7 @@ fn astgenAndSemaVarDecl( |
| 2351 | ); | 2347 | ); |
| 2352 | const code = try gen_scope.finish(); | 2348 | const code = try gen_scope.finish(); |
| 2353 | if (std.builtin.mode == .Debug and mod.comp.verbose_ir) { | 2349 | if (std.builtin.mode == .Debug and mod.comp.verbose_ir) { |
| 2354 | zir.dumpZir(mod.gpa, "var_init", decl.name, code) catch {}; | 2350 | code.dump(mod.gpa, "var_init", decl.name) catch {}; |
| 2355 | } | 2351 | } |
| 2356 | | 2352 | |
| 2357 | var sema: Sema = .{ | 2353 | var sema: Sema = .{ |
| ... | @@ -2359,13 +2355,11 @@ fn astgenAndSemaVarDecl( | ... | @@ -2359,13 +2355,11 @@ fn astgenAndSemaVarDecl( |
| 2359 | .gpa = mod.gpa, | 2355 | .gpa = mod.gpa, |
| 2360 | .arena = &gen_scope_arena.allocator, | 2356 | .arena = &gen_scope_arena.allocator, |
| 2361 | .code = code, | 2357 | .code = code, |
| 2362 | .inst_map = try mod.gpa.alloc(*ir.Inst, code.instructions.len), | 2358 | .inst_map = try gen_scope_arena.allocator.alloc(*ir.Inst, code.instructions.len), |
| 2363 | .owner_decl = decl, | 2359 | .owner_decl = decl, |
| 2364 | .func = null, | 2360 | .func = null, |
| 2365 | .param_inst_list = &.{}, | 2361 | .param_inst_list = &.{}, |
| 2366 | }; | 2362 | }; |
| 2367 | defer mod.gpa.free(sema.inst_map); | | |
| 2368 | | | |
| 2369 | var block_scope: Scope.Block = .{ | 2363 | var block_scope: Scope.Block = .{ |
| 2370 | .parent = null, | 2364 | .parent = null, |
| 2371 | .sema = &sema, | 2365 | .sema = &sema, |
| ... | @@ -2415,7 +2409,7 @@ fn astgenAndSemaVarDecl( | ... | @@ -2415,7 +2409,7 @@ fn astgenAndSemaVarDecl( |
| 2415 | const var_type = try astgen.typeExpr(mod, &type_scope.base, var_decl.ast.type_node); | 2409 | const var_type = try astgen.typeExpr(mod, &type_scope.base, var_decl.ast.type_node); |
| 2416 | const code = try type_scope.finish(); | 2410 | const code = try type_scope.finish(); |
| 2417 | if (std.builtin.mode == .Debug and mod.comp.verbose_ir) { | 2411 | if (std.builtin.mode == .Debug and mod.comp.verbose_ir) { |
| 2418 | zir.dumpZir(mod.gpa, "var_type", decl.name, code) catch {}; | 2412 | code.dump(mod.gpa, "var_type", decl.name) catch {}; |
| 2419 | } | 2413 | } |
| 2420 | | 2414 | |
| 2421 | var sema: Sema = .{ | 2415 | var sema: Sema = .{ |
| ... | @@ -2423,13 +2417,11 @@ fn astgenAndSemaVarDecl( | ... | @@ -2423,13 +2417,11 @@ fn astgenAndSemaVarDecl( |
| 2423 | .gpa = mod.gpa, | 2417 | .gpa = mod.gpa, |
| 2424 | .arena = &type_scope_arena.allocator, | 2418 | .arena = &type_scope_arena.allocator, |
| 2425 | .code = code, | 2419 | .code = code, |
| 2426 | .inst_map = try mod.gpa.alloc(*ir.Inst, code.instructions.len), | 2420 | .inst_map = try type_scope_arena.allocator.alloc(*ir.Inst, code.instructions.len), |
| 2427 | .owner_decl = decl, | 2421 | .owner_decl = decl, |
| 2428 | .func = null, | 2422 | .func = null, |
| 2429 | .param_inst_list = &.{}, | 2423 | .param_inst_list = &.{}, |
| 2430 | }; | 2424 | }; |
| 2431 | defer mod.gpa.free(sema.inst_map); | | |
| 2432 | | | |
| 2433 | var block_scope: Scope.Block = .{ | 2425 | var block_scope: Scope.Block = .{ |
| 2434 | .parent = null, | 2426 | .parent = null, |
| 2435 | .sema = &sema, | 2427 | .sema = &sema, |
| ... | @@ -2985,9 +2977,6 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) !void { | ... | @@ -2985,9 +2977,6 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) !void { |
| 2985 | var arena = decl.typed_value.most_recent.arena.?.promote(mod.gpa); | 2977 | var arena = decl.typed_value.most_recent.arena.?.promote(mod.gpa); |
| 2986 | defer decl.typed_value.most_recent.arena.?.* = arena.state; | 2978 | defer decl.typed_value.most_recent.arena.?.* = arena.state; |
| 2987 | | 2979 | |
| 2988 | const inst_map = try mod.gpa.alloc(*ir.Inst, func.zir.instructions.len); | | |
| 2989 | defer mod.gpa.free(inst_map); | | |
| 2990 | | | |
| 2991 | const fn_ty = decl.typed_value.most_recent.typed_value.ty; | 2980 | const fn_ty = decl.typed_value.most_recent.typed_value.ty; |
| 2992 | const param_inst_list = try mod.gpa.alloc(*ir.Inst, fn_ty.fnParamLen()); | 2981 | const param_inst_list = try mod.gpa.alloc(*ir.Inst, fn_ty.fnParamLen()); |
| 2993 | defer mod.gpa.free(param_inst_list); | 2982 | defer mod.gpa.free(param_inst_list); |
| ... | @@ -3012,11 +3001,12 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) !void { | ... | @@ -3012,11 +3001,12 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) !void { |
| 3012 | .gpa = mod.gpa, | 3001 | .gpa = mod.gpa, |
| 3013 | .arena = &arena.allocator, | 3002 | .arena = &arena.allocator, |
| 3014 | .code = func.zir, | 3003 | .code = func.zir, |
| 3015 | .inst_map = inst_map, | 3004 | .inst_map = try mod.gpa.alloc(*ir.Inst, func.zir.instructions.len), |
| 3016 | .owner_decl = decl, | 3005 | .owner_decl = decl, |
| 3017 | .func = func, | 3006 | .func = func, |
| 3018 | .param_inst_list = param_inst_list, | 3007 | .param_inst_list = param_inst_list, |
| 3019 | }; | 3008 | }; |
| | 3009 | defer mod.gpa.free(sema.inst_map); |
| 3020 | | 3010 | |
| 3021 | var inner_block: Scope.Block = .{ | 3011 | var inner_block: Scope.Block = .{ |
| 3022 | .parent = null, | 3012 | .parent = null, |