authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-11-28 13:06:35+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-11-28 21:58:41+02:00
loga660df4900520c505a0865707552dcc777f4b791
treea4ebdc4aa4ce45b0971d39ca3cc287d2d0c3c218
parentda9c530d9937abd1c17b9eeabec199076428a177

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();