authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-03-17 13:31:28+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-03-17 14:42:12+02:00
log436c72e89a6e402b6920ab03207b95d0ca709ee9
treea3388f0414101b608f48e54420c9ef3254b5d423
parentfec4b7ef5c6a9fc2da1708be6e5be0a619d4b948

Sema: allow param instructions to clobber inst_map

Closes #18840

2 files changed, 10 insertions(+), 4 deletions(-)

src/Sema.zig+4-4
...@@ -9919,7 +9919,7 @@ fn zirParam(...@@ -9919,7 +9919,7 @@ fn zirParam(
9919 .is_comptime = comptime_syntax,9919 .is_comptime = comptime_syntax,
9920 .name = param_name,9920 .name = param_name,
9921 });9921 });
9922 sema.inst_map.putAssumeCapacityNoClobber(inst, .generic_poison);9922 sema.inst_map.putAssumeCapacity(inst, .generic_poison);
9923 return;9923 return;
9924 },9924 },
9925 else => |e| return e,9925 else => |e| return e,
...@@ -9936,7 +9936,7 @@ fn zirParam(...@@ -9936,7 +9936,7 @@ fn zirParam(
9936 .is_comptime = comptime_syntax,9936 .is_comptime = comptime_syntax,
9937 .name = param_name,9937 .name = param_name,
9938 });9938 });
9939 sema.inst_map.putAssumeCapacityNoClobber(inst, .generic_poison);9939 sema.inst_map.putAssumeCapacity(inst, .generic_poison);
9940 return;9940 return;
9941 },9941 },
9942 else => |e| return e,9942 else => |e| return e,
...@@ -9951,7 +9951,7 @@ fn zirParam(...@@ -9951,7 +9951,7 @@ fn zirParam(
9951 if (is_comptime) {9951 if (is_comptime) {
9952 // If this is a comptime parameter we can add a constant generic_poison9952 // If this is a comptime parameter we can add a constant generic_poison
9953 // since this is also a generic parameter.9953 // since this is also a generic parameter.
9954 sema.inst_map.putAssumeCapacityNoClobber(inst, .generic_poison);9954 sema.inst_map.putAssumeCapacity(inst, .generic_poison);
9955 } else {9955 } else {
9956 // Otherwise we need a dummy runtime instruction.9956 // Otherwise we need a dummy runtime instruction.
9957 const result_index: Air.Inst.Index = @enumFromInt(sema.air_instructions.len);9957 const result_index: Air.Inst.Index = @enumFromInt(sema.air_instructions.len);
...@@ -9959,7 +9959,7 @@ fn zirParam(...@@ -9959,7 +9959,7 @@ fn zirParam(
9959 .tag = .alloc,9959 .tag = .alloc,
9960 .data = .{ .ty = param_ty },9960 .data = .{ .ty = param_ty },
9961 });9961 });
9962 sema.inst_map.putAssumeCapacityNoClobber(inst, result_index.toRef());9962 sema.inst_map.putAssumeCapacity(inst, result_index.toRef());
9963 }9963 }
9964}9964}
99659965
test/behavior/generics.zig+6
...@@ -578,3 +578,9 @@ test "call generic function that uses capture from function declaration's scope"...@@ -578,3 +578,9 @@ test "call generic function that uses capture from function declaration's scope"
578 const s = S.foo(123);578 const s = S.foo(123);
579 try expectEqual(123.0, s[0]);579 try expectEqual(123.0, s[0]);
580}580}
581
582comptime {
583 // The same function parameter instruction being analyzed multiple times
584 // should override the result of the previous analysis.
585 for (0..2) |_| _ = fn (void) void;
586}