authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-30 15:50:44+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-30 17:00:50+02:00
log67316e2eab68f19778af82018eb32af1d1b575b3
tree2577dbd8220646d6362657cc5f59c648e36e5ec0
parent4e64373fc07a1e24735bcbdfd463e11839c8c273

AstGen: fix `dbg_block_end` being inserted before last instruction in block

Closes #14125

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

src/AstGen.zig+8-2
...@@ -6942,7 +6942,13 @@ fn switchExpr(...@@ -6942,7 +6942,13 @@ fn switchExpr(
6942 // it as the break operand.6942 // it as the break operand.
6943 if (body_len < 2)6943 if (body_len < 2)
6944 break :blk;6944 break :blk;
6945 const store_inst = payloads.items[end_index - 2];6945
6946 var store_index = end_index - 2;
6947 while (true) : (store_index -= 1) switch (zir_tags[payloads.items[store_index]]) {
6948 .dbg_block_end, .dbg_block_begin, .dbg_stmt, .dbg_var_val, .dbg_var_ptr => {},
6949 else => break,
6950 };
6951 const store_inst = payloads.items[store_index];
6946 if (zir_tags[store_inst] != .store_to_block_ptr or6952 if (zir_tags[store_inst] != .store_to_block_ptr or
6947 zir_datas[store_inst].bin.lhs != block_scope.rl_ptr)6953 zir_datas[store_inst].bin.lhs != block_scope.rl_ptr)
6948 break :blk;6954 break :blk;
...@@ -12150,7 +12156,7 @@ const GenZir = struct {...@@ -12150,7 +12156,7 @@ const GenZir = struct {
1215012156
12151 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);12157 const new_index = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
12152 try gz.astgen.instructions.append(gpa, .{ .tag = .dbg_block_end, .data = undefined });12158 try gz.astgen.instructions.append(gpa, .{ .tag = .dbg_block_end, .data = undefined });
12153 try gz.instructions.insert(gpa, gz.instructions.items.len - 1, new_index);12159 try gz.instructions.append(gpa, new_index);
12154 }12160 }
12155};12161};
1215612162