Skip to content

Commit b0dba46

Browse files
cfillionVexu
authored andcommitted
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 parent ff17b11 commit b0dba46

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Sema.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

0 commit comments

Comments
 (0)