[PATCH] D76377: Correctly initialize the DW_AT_comp_dir attribute of Clang module skeleton CUs

Adrian Prantl via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 18 11:57:40 PDT 2020


aprantl created this revision.
aprantl added reviewers: friss, JDevlieghere.
Herald added a reviewer: jdoerfert.

Before this patch a  Clang module skeleton CU would have a DW_AT_comp_dir pointing to the directory of the module map file, and this information was not used by anyone. Even worse, LLDB actually resolves relative DWO paths by appending it to DW_AT_comp_dir. This patch sets it to the same directory that is used as the main CU's compilation directory, which would make the LLDB code work.


https://reviews.llvm.org/D76377

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/Modules/debug-info-moduleimport.m


Index: clang/test/Modules/debug-info-moduleimport.m
===================================================================
--- clang/test/Modules/debug-info-moduleimport.m
+++ clang/test/Modules/debug-info-moduleimport.m
@@ -28,5 +28,7 @@
 // RUN:   -fmodule-format=obj -dwarf-ext-refs \
 // RUN:   %s -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -o - \
 // RUN:     | FileCheck %s --check-prefix=SKEL-CHECK
-// SKEL-CHECK: distinct !DICompileUnit
-// SKEL-CHECK: distinct !DICompileUnit{{.*}}dwoId
+// SKEL-CHECK: distinct !DICompileUnit({{.*}}file: ![[CUFILE:[0-9]+]]
+// SKEL-CHECK: ![[CUFILE]] = !DIFile({{.*}}directory: "[[COMP_DIR:.*]]"
+// SKEL-CHECK: distinct !DICompileUnit({{.*}}file: ![[DWOFILE:[0-9]+]]{{.*}}dwoId
+// SKEL-CHECK: ![[DWOFILE]] = !DIFile({{.*}}directory: "[[COMP_DIR]]"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2492,12 +2492,12 @@
             ? (uint64_t)Mod.getSignature()[1] << 32 | Mod.getSignature()[0]
             : ~1ULL;
     llvm::DIBuilder DIB(CGM.getModule());
-    DIB.createCompileUnit(TheCU->getSourceLanguage(),
-                          // TODO: Support "Source" from external AST providers?
-                          DIB.createFile(Mod.getModuleName(), Mod.getPath()),
-                          TheCU->getProducer(), true, StringRef(), 0,
-                          Mod.getASTFile(), llvm::DICompileUnit::FullDebug,
-                          Signature);
+    DIB.createCompileUnit(
+        TheCU->getSourceLanguage(),
+        // TODO: Support "Source" from external AST providers?
+        DIB.createFile(Mod.getModuleName(), TheCU->getDirectory()),
+        TheCU->getProducer(), false, StringRef(), 0, Mod.getASTFile(),
+        llvm::DICompileUnit::FullDebug, Signature);
     DIB.finalize();
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76377.251142.patch
Type: text/x-patch
Size: 1902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200318/1586f92c/attachment.bin>


More information about the cfe-commits mailing list