diff options
| author | cfillion <cfillion@users.noreply.github.com> | 2023-12-08 13:59:15 -0500 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-12-28 14:44:26 +0200 |
| commit | b0dba4680012e47ffc99f87bab4b53a976cb8b8e (patch) | |
| tree | d558f189ae44138be9608882caf943dc1275d195 /src/Sema.zig | |
| parent | ff17b11692f6a87b55470b7fc03babd382460886 (diff) | |
| download | zig-b0dba4680012e47ffc99f87bab4b53a976cb8b8e.tar.gz zig-b0dba4680012e47ffc99f87bab4b53a976cb8b8e.zip | |
Sema: fix merging stores instructions from a comptime struct value with `-fstrip`
The first instruction in the block was never checked resulting in `struct_is_comptime` being incorrectly cleared if there are no instructions before the first field of the comptime struct.
Fixes #17119
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index ee9fa5b062..f54966f33f 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -4783,11 +4783,9 @@ fn validateStructInit( const field_ptr_ref = sema.inst_map.get(field_ptr).?; - //std.debug.print("validateStructInit (field_ptr_air_inst=%{d}):\n", .{ - // field_ptr_air_inst, - //}); + //std.debug.print("validateStructInit (field_ptr_ref=%{d}):\n", .{field_ptr_ref}); //for (block.instructions.items) |item| { - // std.debug.print(" %{d} = {s}\n", .{item, @tagName(air_tags[item])}); + // std.debug.print(" %{d} = {s}\n", .{item, @tagName(air_tags[@intFromEnum(item)])}); //} // We expect to see something like this in the current block AIR: @@ -4804,8 +4802,9 @@ fn validateStructInit( // Possible performance enhancement: save the `block_index` between iterations // of the for loop. - var block_index = block.instructions.items.len -| 1; - while (block_index > 0) : (block_index -= 1) { + var block_index = block.instructions.items.len; + while (block_index > 0) { + block_index -= 1; const store_inst = block.instructions.items[block_index]; if (store_inst.toRef() == field_ptr_ref) { struct_is_comptime = false; @@ -5060,8 +5059,9 @@ fn zirValidatePtrArrayInit( // Possible performance enhancement: save the `block_index` between iterations // of the for loop. - var block_index = block.instructions.items.len -| 1; - while (block_index > 0) : (block_index -= 1) { + var block_index = block.instructions.items.len; + while (block_index > 0) { + block_index -= 1; const store_inst = block.instructions.items[block_index]; if (store_inst.toRef() == elem_ptr_ref) { array_is_comptime = false; |
