Merge pull request #13719 from Vexu/debug

Improve debuggability of programs built by the self hosted compiler
This commit is contained in:
Veikka Tuominen
2022-11-30 22:51:39 +02:00
committed by Andrew Kelley
parent c2ad78922a
commit aa7e65d5ba
5 changed files with 33 additions and 3 deletions

View File

@@ -6090,6 +6090,12 @@ pub const FuncGen = struct {
const insert_block = self.builder.getInsertBlock();
if (isByRef(operand_ty)) {
_ = dib.insertDeclareAtEnd(operand, di_local_var, debug_loc, insert_block);
} else if (self.dg.module.comp.bin_file.options.optimize_mode == .Debug) {
const alignment = operand_ty.abiAlignment(self.dg.module.getTarget());
const alloca = self.buildAlloca(operand.typeOf(), alignment);
const store_inst = self.builder.buildStore(operand, alloca);
store_inst.setAlignment(alignment);
_ = dib.insertDeclareAtEnd(alloca, di_local_var, debug_loc, insert_block);
} else {
_ = dib.insertDbgValueIntrinsicAtEnd(operand, di_local_var, debug_loc, insert_block);
}
@@ -8028,6 +8034,12 @@ pub const FuncGen = struct {
const insert_block = self.builder.getInsertBlock();
if (isByRef(inst_ty)) {
_ = dib.insertDeclareAtEnd(arg_val, di_local_var, debug_loc, insert_block);
} else if (self.dg.module.comp.bin_file.options.optimize_mode == .Debug) {
const alignment = inst_ty.abiAlignment(self.dg.module.getTarget());
const alloca = self.buildAlloca(arg_val.typeOf(), alignment);
const store_inst = self.builder.buildStore(arg_val, alloca);
store_inst.setAlignment(alignment);
_ = dib.insertDeclareAtEnd(alloca, di_local_var, debug_loc, insert_block);
} else {
_ = dib.insertDbgValueIntrinsicAtEnd(arg_val, di_local_var, debug_loc, insert_block);
}