]> granicus.if.org Git - clang/commitdiff
Module Debugging: Use a nonzero DWO id for precompiled headers.
authorAdrian Prantl <aprantl@apple.com>
Fri, 22 Jan 2016 17:43:43 +0000 (17:43 +0000)
committerAdrian Prantl <aprantl@apple.com>
Fri, 22 Jan 2016 17:43:43 +0000 (17:43 +0000)
PCH files don't have a module signature and LLVM uses a nonzero DWO id as
an indicator for skeleton / module CUs. This change pins the DWO id for PCH
files to a known constant value.
The correct long-term solution here is to implement a module signature
that is an actual dterministic hash (at the moment module signatures are
just random nonzero numbers) and then enable this for PCH files as well.

<rdar://problem/24290667>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258507 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/ObjectFilePCHContainerOperations.cpp
test/Modules/ExtDebugInfo.cpp
test/Modules/ModuleDebugInfo.cpp

index 28e28489681e31b66e9ac652ba44a197eca82919..4e0cc3f8574edd4f8220c612d71cb28b0eafcad8 100644 (file)
@@ -1740,11 +1740,14 @@ CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
 
   bool IsRootModule = M ? !M->Parent : true;
   if (CreateSkeletonCU && IsRootModule) {
+    // 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.
+    uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1U;
     llvm::DIBuilder DIB(CGM.getModule());
     DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
                           Mod.getPath(), TheCU->getProducer(), true,
                           StringRef(), 0, Mod.getASTFile(),
-                          llvm::DIBuilder::FullDebug, Mod.getSignature());
+                          llvm::DIBuilder::FullDebug, Signature);
     DIB.finalize();
   }
   llvm::DIModule *Parent =
index cd17832554d7faa7cee39dffb92be31626696a71..2178ec21c7a27ea63cb8cabcbc8cf0b3c44a4468 100644 (file)
@@ -219,7 +219,11 @@ public:
 
     M->setTargetTriple(Ctx.getTargetInfo().getTriple().getTriple());
     M->setDataLayout(Ctx.getTargetInfo().getDataLayoutString());
-    Builder->getModuleDebugInfo()->setDwoId(Buffer->Signature);
+
+    // PCH files don't have a signature field in the control block,
+    // but LLVM detects DWO CUs by looking for a non-zero DWO id.
+    uint64_t Signature = Buffer->Signature ? Buffer->Signature : ~1U;
+    Builder->getModuleDebugInfo()->setDwoId(Signature);
 
     // Finalize the Builder.
     if (Builder)
index b9eae12dedae3b9c8b300d8f105bcfe5d21d311b..c4c6a298234e26a393b337ab85b69515b5325f87 100644 (file)
@@ -102,3 +102,7 @@ void foo() {
 
 
 // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !"_ZTSN8DebugCXX6StructE", line: 24)
+
+// CHECK: !DICompileUnit(
+// CHECK-SAME:           splitDebugFilename:
+// CHECK-SAME:           dwoId:
index a2b735b3b7073196f8e92abb155eae46b014375f..73443972409f9145a20a9f2546db1d41fb692f2f 100644 (file)
@@ -8,7 +8,6 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
-// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-DWO %s
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
@@ -22,7 +21,7 @@
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 // CHECK-SAME:                    isOptimized: false,
 // CHECK-SAME-NOT:                splitDebugFilename:
-// CHECK-DWO:                     dwoId:
+// CHECK:                         dwoId:
 
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum"
 // CHECK-SAME:             identifier: "_ZTSN8DebugCXX4EnumE")