authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-11-28 13:06:35+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-09 14:44:53-07:00
log3357425b8786a0fcde44bd52675200999efe4eb3
tree40bf921c34062664ca05553270c9a8248fe40e97
parent5404d06ea9fe5f2c40e41adf7b8c15322c365ca8

llvm: improve emitted debug info

* ensure parameter debug info is in the subroutine di scope * slit sub file path into basename and dirname Closes #12257 Closes #12665

1 files changed, 4 insertions(+), 4 deletions(-)

src/codegen/llvm.zig+4-4
...@@ -1179,8 +1179,7 @@ pub const Object = struct {...@@ -1179,8 +1179,7 @@ pub const Object = struct {
11791179
1180 llvm_func.fnSetSubprogram(subprogram);1180 llvm_func.fnSetSubprogram(subprogram);
11811181
1182 const lexical_block = dib.createLexicalBlock(subprogram.toScope(), di_file.?, line_number, 1);1182 di_scope = subprogram.toScope();
1183 di_scope = lexical_block.toScope();
1184 }1183 }
11851184
1186 var fg: FuncGen = .{1185 var fg: FuncGen = .{
...@@ -1393,9 +1392,10 @@ pub const Object = struct {...@@ -1393,9 +1392,10 @@ pub const Object = struct {
1393 return @ptrCast(*llvm.DIFile, gop.value_ptr.*);1392 return @ptrCast(*llvm.DIFile, gop.value_ptr.*);
1394 }1393 }
1395 const dir_path = file.pkg.root_src_directory.path orelse ".";1394 const dir_path = file.pkg.root_src_directory.path orelse ".";
1396 const sub_file_path_z = try gpa.dupeZ(u8, file.sub_file_path);1395 const sub_file_path_z = try gpa.dupeZ(u8, std.fs.path.basename(file.sub_file_path));
1397 defer gpa.free(sub_file_path_z);1396 defer gpa.free(sub_file_path_z);
1398 const dir_path_z = try gpa.dupeZ(u8, dir_path);1397 const stage1_workaround = std.fs.path.dirname(file.sub_file_path) orelse "";
1398 const dir_path_z = try std.fs.path.joinZ(gpa, &.{ dir_path, stage1_workaround });
1399 defer gpa.free(dir_path_z);1399 defer gpa.free(dir_path_z);
1400 const di_file = o.di_builder.?.createFile(sub_file_path_z, dir_path_z);1400 const di_file = o.di_builder.?.createFile(sub_file_path_z, dir_path_z);
1401 gop.value_ptr.* = di_file.toNode();1401 gop.value_ptr.* = di_file.toNode();