authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-05-25 23:47:44-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:47:55-07:00
log5d0d5893fd39047e4fdbb6623e4d69babf0b2ed4
tree1ee6e3c66906d7b5485c2e35dcccf1009799d365
parent70cc68e9994f7dca53904075e15b2b6f87342539

Sema: fix some issues with the inferred alloc tag change


1 files changed, 20 insertions(+), 14 deletions(-)

src/Sema.zig+20-14
......@@ -1999,15 +1999,17 @@ fn resolveMaybeUndefValAllowVariablesMaybeRuntime(
19991999 return opv;
20002000 }
20012001 const air_datas = sema.air_instructions.items(.data);
2002 switch (air_tags[i]) {
2003 .interned => {
2004 const val = air_datas[i].interned.toValue();
2005 if (val.isRuntimeValue(sema.mod)) make_runtime.* = true;
2006 if (val.isPtrToThreadLocal(sema.mod)) make_runtime.* = true;
2007 return val;
2002 const val = switch (air_tags[i]) {
2003 .inferred_alloc, .inferred_alloc_comptime => val: {
2004 const ty_pl = sema.air_instructions.items(.data)[i].ty_pl;
2005 break :val sema.air_values.items[ty_pl.payload];
20082006 },
2007 .interned => air_datas[i].interned.toValue(),
20092008 else => return null,
2010 }
2009 };
2010 if (val.isRuntimeValue(sema.mod)) make_runtime.* = true;
2011 if (val.isPtrToThreadLocal(sema.mod)) make_runtime.* = true;
2012 return val;
20112013}
20122014
20132015fn failWithNeededComptime(sema: *Sema, block: *Block, src: LazySrcLoc, reason: []const u8) CompileError {
......@@ -3762,13 +3764,17 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
37623764 sema.air_instructions.items(.data)[ptr_inst].ty_pl.ty = final_ptr_ty_inst;
37633765
37643766 try sema.maybeQueueFuncBodyAnalysis(decl_index);
3765 sema.air_values.items[value_index] = (try sema.mod.intern(.{ .ptr = .{
3766 .ty = final_ptr_ty.toIntern(),
3767 .addr = if (var_is_mut) .{ .mut_decl = .{
3768 .decl = decl_index,
3769 .runtime_index = block.runtime_index,
3770 } } else .{ .decl = decl_index },
3771 } })).toValue();
3767 // Change it to an interned.
3768 sema.air_instructions.set(ptr_inst, .{
3769 .tag = .interned,
3770 .data = .{ .interned = try sema.mod.intern(.{ .ptr = .{
3771 .ty = final_ptr_ty.toIntern(),
3772 .addr = if (var_is_mut) .{ .mut_decl = .{
3773 .decl = decl_index,
3774 .runtime_index = block.runtime_index,
3775 } } else .{ .decl = decl_index },
3776 } }) },
3777 });
37723778 },
37733779 .inferred_alloc => {
37743780 assert(sema.unresolved_inferred_allocs.remove(ptr_inst));