From 59447e53056d8fb6682b79accccffa176d0b44d1 Mon Sep 17 00:00:00 2001 From: mlugg Date: Sat, 24 Feb 2024 04:29:42 +0000 Subject: compiler: decide dbg_var scoping based on AIR blocks This commit eliminates the `dbg_block_{begin,end}` instructions from both ZIR and AIR. Instead, lexical scoping of `dbg_var_{ptr,val}` instructions is decided based on the AIR block they exist within. This is a much more robust system, and also results in a huge drop in ZIR bytes - around 7% for Sema.zig. This required some enhancements to Sema to prevent elision of blocks when they are required for debug variable scoping. This can be observed by looking at the AIR for the following simple test program with and without `-fstrip`: ```zig export fn f() void { { var a: u32 = 0; _ = &a; } { var a: u32 = 0; _ = &a; } } ``` When `-fstrip` is passed, no AIR blocks are generated. When `-fno-strip` is passed, the ZIR blocks are lowered to true AIR blocks to give correct lexical scoping to the debug vars. The changes here incidentally reolve #19060. A corresponding behavior test has been added. Resolves: #19060 --- src/Liveness.zig | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/Liveness.zig') diff --git a/src/Liveness.zig b/src/Liveness.zig index d1283c502b..3b29c20ceb 100644 --- a/src/Liveness.zig +++ b/src/Liveness.zig @@ -329,8 +329,6 @@ pub fn categorizeOperand( .dbg_stmt, .dbg_inline_begin, .dbg_inline_end, - .dbg_block_begin, - .dbg_block_end, .unreach, .ret_addr, .frame_addr, @@ -967,8 +965,6 @@ fn analyzeInst( .dbg_stmt, .dbg_inline_begin, .dbg_inline_end, - .dbg_block_begin, - .dbg_block_end, .fence, .ret_addr, .frame_addr, -- cgit v1.2.3