authorgravatar for cfillion@users.noreply.github.comcfillion <cfillion@users.noreply.github.com> 2023-12-08 13:59:15-05:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-12-28 14:44:26+02:00
logb0dba4680012e47ffc99f87bab4b53a976cb8b8e
treed558f189ae44138be9608882caf943dc1275d195
parentff17b11692f6a87b55470b7fc03babd382460886

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

1 files changed, 8 insertions(+), 8 deletions(-)

src/Sema.zig+8-8
......@@ -4783,11 +4783,9 @@ fn validateStructInit(
47834783
47844784 const field_ptr_ref = sema.inst_map.get(field_ptr).?;
47854785
4786 //std.debug.print("validateStructInit (field_ptr_air_inst=%{d}):\n", .{
4787 // field_ptr_air_inst,
4788 //});
4786 //std.debug.print("validateStructInit (field_ptr_ref=%{d}):\n", .{field_ptr_ref});
47894787 //for (block.instructions.items) |item| {
4790 // std.debug.print(" %{d} = {s}\n", .{item, @tagName(air_tags[item])});
4788 // std.debug.print(" %{d} = {s}\n", .{item, @tagName(air_tags[@intFromEnum(item)])});
47914789 //}
47924790
47934791 // We expect to see something like this in the current block AIR:
......@@ -4804,8 +4802,9 @@ fn validateStructInit(
48044802
48054803 // Possible performance enhancement: save the `block_index` between iterations
48064804 // of the for loop.
4807 var block_index = block.instructions.items.len -| 1;
4808 while (block_index > 0) : (block_index -= 1) {
4805 var block_index = block.instructions.items.len;
4806 while (block_index > 0) {
4807 block_index -= 1;
48094808 const store_inst = block.instructions.items[block_index];
48104809 if (store_inst.toRef() == field_ptr_ref) {
48114810 struct_is_comptime = false;
......@@ -5060,8 +5059,9 @@ fn zirValidatePtrArrayInit(
50605059
50615060 // Possible performance enhancement: save the `block_index` between iterations
50625061 // of the for loop.
5063 var block_index = block.instructions.items.len -| 1;
5064 while (block_index > 0) : (block_index -= 1) {
5062 var block_index = block.instructions.items.len;
5063 while (block_index > 0) {
5064 block_index -= 1;
50655065 const store_inst = block.instructions.items[block_index];
50665066 if (store_inst.toRef() == elem_ptr_ref) {
50675067 array_is_comptime = false;