diff options
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/c.zig | 4 | ||||
| -rw-r--r-- | src/codegen/llvm.zig | 22 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index b814be4445..88d26789cf 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -1786,6 +1786,10 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO .dbg_inline_end, => try airDbgInline(f, inst), + .dbg_block_begin, + .dbg_block_end, + => CValue{ .none = {} }, + .call => try airCall(f, inst, .auto), .call_always_tail => try airCall(f, inst, .always_tail), .call_never_tail => try airCall(f, inst, .never_tail), diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 5a231ddc6e..2d5b38eb17 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -3220,6 +3220,10 @@ pub const FuncGen = struct { /// Stack of locations where a call was inlined. dbg_inlined: std.ArrayListUnmanaged(DbgState) = .{}, + /// Stack of `DILexicalBlock`s. dbg_block instructions cannot happend accross + /// dbg_inline instructions so no special handling there is required. + dbg_block_stack: std.ArrayListUnmanaged(*llvm.DIScope) = .{}, + /// This stores the LLVM values used in a function, such that they can be referred to /// in other instructions. This table is cleared before every function is generated. func_inst_table: std.AutoHashMapUnmanaged(Air.Inst.Ref, *const llvm.Value), @@ -3254,6 +3258,7 @@ pub const FuncGen = struct { fn deinit(self: *FuncGen) void { self.builder.dispose(); self.dbg_inlined.deinit(self.gpa); + self.dbg_block_stack.deinit(self.gpa); self.func_inst_table.deinit(self.gpa); self.blocks.deinit(self.gpa); } @@ -3475,6 +3480,8 @@ pub const FuncGen = struct { .dbg_stmt => self.airDbgStmt(inst), .dbg_inline_begin => try self.airDbgInlineBegin(inst), .dbg_inline_end => try self.airDbgInlineEnd(inst), + .dbg_block_begin => try self.airDbgBlockBegin(), + .dbg_block_end => try self.airDbgBlockEnd(), .dbg_var_ptr => try self.airDbgVarPtr(inst), .dbg_var_val => try self.airDbgVarVal(inst), // zig fmt: on @@ -4256,6 +4263,21 @@ pub const FuncGen = struct { return null; } + fn airDbgBlockBegin(self: *FuncGen) !?*const llvm.Value { + const dib = self.dg.object.di_builder orelse return null; + const old_scope = self.di_scope.?; + try self.dbg_block_stack.append(self.gpa, old_scope); + const lexical_block = dib.createLexicalBlock(old_scope, self.di_file.?, self.prev_dbg_line, self.prev_dbg_column); + self.di_scope = lexical_block.toScope(); + return null; + } + + fn airDbgBlockEnd(self: *FuncGen) !?*const llvm.Value { + if (self.dg.object.di_builder == null) return null; + self.di_scope = self.dbg_block_stack.pop(); + return null; + } + fn airDbgVarPtr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { const dib = self.dg.object.di_builder orelse return null; const pl_op = self.air.instructions.items(.data)[inst].pl_op; |
