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(...@@ -1999,15 +1999,17 @@ fn resolveMaybeUndefValAllowVariablesMaybeRuntime(
1999 return opv;1999 return opv;
2000 }2000 }
2001 const air_datas = sema.air_instructions.items(.data);2001 const air_datas = sema.air_instructions.items(.data);
2002 switch (air_tags[i]) {2002 const val = switch (air_tags[i]) {
2003 .interned => {2003 .inferred_alloc, .inferred_alloc_comptime => val: {
2004 const val = air_datas[i].interned.toValue();2004 const ty_pl = sema.air_instructions.items(.data)[i].ty_pl;
2005 if (val.isRuntimeValue(sema.mod)) make_runtime.* = true;2005 break :val sema.air_values.items[ty_pl.payload];
2006 if (val.isPtrToThreadLocal(sema.mod)) make_runtime.* = true;
2007 return val;
2008 },2006 },
2007 .interned => air_datas[i].interned.toValue(),
2009 else => return null,2008 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;
2011}2013}
20122014
2013fn failWithNeededComptime(sema: *Sema, block: *Block, src: LazySrcLoc, reason: []const u8) CompileError {2015fn 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...@@ -3762,13 +3764,17 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
3762 sema.air_instructions.items(.data)[ptr_inst].ty_pl.ty = final_ptr_ty_inst;3764 sema.air_instructions.items(.data)[ptr_inst].ty_pl.ty = final_ptr_ty_inst;
37633765
3764 try sema.maybeQueueFuncBodyAnalysis(decl_index);3766 try sema.maybeQueueFuncBodyAnalysis(decl_index);
3765 sema.air_values.items[value_index] = (try sema.mod.intern(.{ .ptr = .{3767 // Change it to an interned.
3766 .ty = final_ptr_ty.toIntern(),3768 sema.air_instructions.set(ptr_inst, .{
3767 .addr = if (var_is_mut) .{ .mut_decl = .{3769 .tag = .interned,
3768 .decl = decl_index,3770 .data = .{ .interned = try sema.mod.intern(.{ .ptr = .{
3769 .runtime_index = block.runtime_index,3771 .ty = final_ptr_ty.toIntern(),
3770 } } else .{ .decl = decl_index },3772 .addr = if (var_is_mut) .{ .mut_decl = .{
3771 } })).toValue();3773 .decl = decl_index,
3774 .runtime_index = block.runtime_index,
3775 } } else .{ .decl = decl_index },
3776 } }) },
3777 });
3772 },3778 },
3773 .inferred_alloc => {3779 .inferred_alloc => {
3774 assert(sema.unresolved_inferred_allocs.remove(ptr_inst));3780 assert(sema.unresolved_inferred_allocs.remove(ptr_inst));