r353578 - -gmodules: Don't emit incomplete breadcrumbs pointing to nonexistant PCM files.

Adrian Prantl via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 8 15:15:42 PST 2019


Author: adrian
Date: Fri Feb  8 15:15:42 2019
New Revision: 353578

URL: http://llvm.org/viewvc/llvm-project?rev=353578&view=rev
Log:
-gmodules: Don't emit incomplete breadcrumbs pointing to nonexistant PCM files.

When a module name is specified as -fmodule-name, that module gets a
clang::Module object, but it won't actually be built or imported; it
will be textual. CGDebugInfo wouldn't detect this and them emit a
DICompileUnit that had a hash but no name and that confused both
dsymutil, LLDB, and myself.

rdar://problem/47926508

Differential Revision: https://reviews.llvm.org/D57976

Added:
    cfe/trunk/test/Modules/DebugInfo-fmodule-name.c
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=353578&r1=353577&r2=353578&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Feb  8 15:15:42 2019
@@ -2296,7 +2296,14 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   }
 
   bool IsRootModule = M ? !M->Parent : true;
-  if (CreateSkeletonCU && IsRootModule) {
+  // When a module name is specified as -fmodule-name, that module gets a
+  // clang::Module object, but it won't actually be built or imported; it will
+  // be textual.
+  if (CreateSkeletonCU && IsRootModule && Mod.getASTFile().empty())
+    assert((!M || (M->Name == CGM.getLangOpts().ModuleName)) &&
+           "clang module without ASTFile must be specified by -fmodule-name");
+
+  if (CreateSkeletonCU && IsRootModule && !Mod.getASTFile().empty()) {
     // PCH files don't have a signature field in the control block,
     // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
     // We use the lower 64 bits for debug info.
@@ -2313,6 +2320,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern
                           Signature);
     DIB.finalize();
   }
+
   llvm::DIModule *Parent =
       IsRootModule ? nullptr
                    : getOrCreateModuleRef(

Added: cfe/trunk/test/Modules/DebugInfo-fmodule-name.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/DebugInfo-fmodule-name.c?rev=353578&view=auto
==============================================================================
--- cfe/trunk/test/Modules/DebugInfo-fmodule-name.c (added)
+++ cfe/trunk/test/Modules/DebugInfo-fmodule-name.c Fri Feb  8 15:15:42 2019
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-format=obj -fmodule-name=F \
+// RUN:     -debug-info-kind=limited -dwarf-ext-refs \
+// RUN:     -fimplicit-module-maps -x c -fmodules-cache-path=%t -F %S/Inputs \
+// RUN:     %s -S -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s
+
+#include "F/F.h"
+
+// CHECK: !DICompileUnit
+// CHECK-NOT: dwoId:
+
+// We still want the import, but no skeleton CU, since no PCM was built.
+
+// CHECK: !DIModule({{.*}}, name: "F"
+// CHECK-NOT: !DICompileUnit
+// CHECK-NOT: dwoId:




More information about the cfe-commits mailing list