[clang] [Clang][DebugInfo] Use CGDebugInfo::createFile in CGDebugInfo::CreateCompileUnit (#83174) (PR #83175)

2024-03-11 Thread Aleksei Vetrov via cfe-commits

https://github.com/noxwell closed 
https://github.com/llvm/llvm-project/pull/83175
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][DebugInfo] Use CGDebugInfo::createFile in CGDebugInfo::CreateCompileUnit (#83174) (PR #83175)

2024-03-11 Thread Aleksei Vetrov via cfe-commits

noxwell wrote:

Closing this PR, because these changes are incompatible to DWARF standard, see 
[83175#issuecomment-1969473992](https://github.com/llvm/llvm-project/pull/83175#issuecomment-1969473992)

https://github.com/llvm/llvm-project/pull/83175
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][DebugInfo] Use CGDebugInfo::createFile in CGDebugInfo::CreateCompileUnit (#83174) (PR #83175)

2024-02-27 Thread Aleksei Vetrov via cfe-commits

https://github.com/noxwell created 
https://github.com/llvm/llvm-project/pull/83175

Use `CGDebugInfo::createFile` wrapper that handles file remapping and corner 
cases instead of directly using `DBuilder.createFile` in 
`CGDebugInfo::CreateCompileUnit`.

Fixes #83174

>From 704f9042bb357cb600894c2a5caf19d0a53cf059 Mon Sep 17 00:00:00 2001
From: Aleksei Vetrov 
Date: Tue, 27 Feb 2024 19:50:13 +
Subject: [PATCH] [Clang][DebugInfo] Use CGDebugInfo::createFile in
 CGDebugInfo::CreateCompileUnit (#83174)

Use `CGDebugInfo::createFile` wrapper that handles file remapping and
corner cases instead of directly using `DBuilder.createFile` in
`CGDebugInfo::CreateCompileUnit`.

Fixes #83174
---
 clang/lib/CodeGen/CGDebugInfo.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index c2c01439f2dc99..2a24cc1a9dc020 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -628,9 +628,8 @@ void CGDebugInfo::CreateCompileUnit() {
   // file was specified with an absolute path.
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
-  llvm::DIFile *CUFile = DBuilder.createFile(
-  remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
-  getSource(SM, SM.getMainFileID()));
+  llvm::DIFile *CUFile = createFile(
+  MainFileName, CSInfo, getSource(SM, SM.getMainFileID()));
 
   StringRef Sysroot, SDK;
   if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB) {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][DebugInfo] Use CGDebugInfo::createFile in CGDebugInfo::CreateCompileUnit (#83174) (PR #83175)

2024-02-27 Thread Aleksei Vetrov via cfe-commits

https://github.com/noxwell updated 
https://github.com/llvm/llvm-project/pull/83175

>From 237264fded2b9806d273d7bc5d593a7dd0011850 Mon Sep 17 00:00:00 2001
From: Aleksei Vetrov 
Date: Tue, 27 Feb 2024 19:50:13 +
Subject: [PATCH] [Clang][DebugInfo] Use CGDebugInfo::createFile in
 CGDebugInfo::CreateCompileUnit (#83174)

Use `CGDebugInfo::createFile` wrapper that handles file remapping and
corner cases instead of directly using `DBuilder.createFile` in
`CGDebugInfo::CreateCompileUnit`.

Fixes #83174
---
 clang/lib/CodeGen/CGDebugInfo.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index c2c01439f2dc99..22cb3492ebe11a 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -628,9 +628,8 @@ void CGDebugInfo::CreateCompileUnit() {
   // file was specified with an absolute path.
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
-  llvm::DIFile *CUFile = DBuilder.createFile(
-  remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
-  getSource(SM, SM.getMainFileID()));
+  llvm::DIFile *CUFile =
+  createFile(MainFileName, CSInfo, getSource(SM, SM.getMainFileID()));
 
   StringRef Sysroot, SDK;
   if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB) {

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][DebugInfo] Use CGDebugInfo::createFile in CGDebugInfo::CreateCompileUnit (#83174) (PR #83175)

2024-02-28 Thread Aleksei Vetrov via cfe-commits


@@ -628,9 +628,8 @@ void CGDebugInfo::CreateCompileUnit() {
   // file was specified with an absolute path.
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
-  llvm::DIFile *CUFile = DBuilder.createFile(
-  remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
-  getSource(SM, SM.getMainFileID()));
+  llvm::DIFile *CUFile =
+  createFile(MainFileName, CSInfo, getSource(SM, SM.getMainFileID()));

noxwell wrote:

`CGDebugInfo::createFile` takes care of remapping, see `std::string 
RemappedFile = remapDIPath(FileName)`.

https://github.com/llvm/llvm-project/pull/83175
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][DebugInfo] Use CGDebugInfo::createFile in CGDebugInfo::CreateCompileUnit (#83174) (PR #83175)

2024-02-28 Thread Aleksei Vetrov via cfe-commits

https://github.com/noxwell updated 
https://github.com/llvm/llvm-project/pull/83175

>From 731463e1134b0821e518a3e8e521a2d44dd18a8e Mon Sep 17 00:00:00 2001
From: Aleksei Vetrov 
Date: Tue, 27 Feb 2024 19:50:13 +
Subject: [PATCH] [Clang][DebugInfo] Use CGDebugInfo::createFile in
 CGDebugInfo::CreateCompileUnit

Use `CGDebugInfo::createFile` wrapper that handles file remapping and
corner cases instead of directly using `DBuilder.createFile` in
`CGDebugInfo::CreateCompileUnit`.

Add test to check corner case with remapping absolute path to relative.

Fixes #83174
---
 clang/lib/CodeGen/CGDebugInfo.cpp |  5 ++---
 clang/test/CodeGen/debug-info-abspath-remap.c | 20 +++
 2 files changed, 22 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/CodeGen/debug-info-abspath-remap.c

diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index c2c01439f2dc99..22cb3492ebe11a 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -628,9 +628,8 @@ void CGDebugInfo::CreateCompileUnit() {
   // file was specified with an absolute path.
   if (CSKind)
 CSInfo.emplace(*CSKind, Checksum);
-  llvm::DIFile *CUFile = DBuilder.createFile(
-  remapDIPath(MainFileName), remapDIPath(getCurrentDirname()), CSInfo,
-  getSource(SM, SM.getMainFileID()));
+  llvm::DIFile *CUFile =
+  createFile(MainFileName, CSInfo, getSource(SM, SM.getMainFileID()));
 
   StringRef Sysroot, SDK;
   if (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB) {
diff --git a/clang/test/CodeGen/debug-info-abspath-remap.c 
b/clang/test/CodeGen/debug-info-abspath-remap.c
new file mode 100644
index 00..9a4f146c3254f9
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-abspath-remap.c
@@ -0,0 +1,20 @@
+// RUN: mkdir -p %t/src
+// RUN: cp %s %t/src/debug-info-debug-prefix-map.c
+
+// RUN: mkdir -p %t/out
+// RUN: cd %t/out
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN:   -fdebug-prefix-map="%t/=./" %t/src/debug-info-debug-prefix-map.c \
+// RUN:   -emit-llvm -o - | FileCheck %s
+
+void foo(void) {}
+
+// Compile unit filename is transformed from absolute path %t/src... to
+// a relative path ./src... But it should not be relative to directory "./out".
+
+// CHECK: = distinct !DICompileUnit({{.*}}file: ![[#CUFILE:]]
+// CHECK: ![[#CUFILE]] = !DIFile(
+// CHECK-NOT:directory: "./out"
+// CHECK-SAME:   filename: "./src{{[^"]+}}"
+// CHECK-NOT:directory: "./out"
+// CHECK-SAME: )

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][DebugInfo] Use CGDebugInfo::createFile in CGDebugInfo::CreateCompileUnit (#83174) (PR #83175)

2024-02-28 Thread Aleksei Vetrov via cfe-commits

noxwell wrote:

> Can you add a test for this?

I added a test for remapping of absolute path. It passes with this PR and fails 
on trunk.

However, I found much bigger problem. This fix fails test 
`debug-info-abspath.c`, more specifically the last case, which checks that CU 
file has absolute path to source file _as well as absolute path to current 
working directory_. @adrian-prantl should now better, but I think it is done to 
satisfy DWARF standard:

> A DW_AT_name attribute whose value is a null-terminated string containing the 
> full or relative path name (relative to the value of the DW_AT_comp_dir 
> attribute, see below) of the primary source file from which the compilation 
> unit was derived.
> A DW_AT_comp_dir attribute whose value is a null-terminated string containing 
> the current working directory of the compilation command

It looks like there may be a problem in the standard: you can't have 
DW_TAG_compile_unit that references file by relative path, but not relative to 
DW_AT_comp_dir. What do you think?

https://github.com/llvm/llvm-project/pull/83175
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits