<div dir="ltr">Is this a workaround for now with the intent to fix this to allow such implicit specializations to have their debug info modularized? I believe this does work correctly in modular debug info with expliict modules, would probably be sort of nice to have these things be consistent/similar?</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 23, 2018 at 5:08 PM Adrian Prantl via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Tue Oct 23 17:06:02 2018<br>
New Revision: 345109<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=345109&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=345109&view=rev</a><br>
Log:<br>
Debug Info (-gmodules): emit full types for non-anchored template specializations<br>
<br>
Before this patch, clang would emit a (module-)forward declaration for<br>
template instantiations that are not anchored by an explicit template<br>
instantiation, but still are guaranteed to be available in an imported<br>
module. Unfortunately detecting the owning module doesn't reliably<br>
work when local submodule visibility is enabled and the template is<br>
inside a cross-module namespace.<br>
<br>
This make clang debuggable again with -gmodules and LSV enabled.<br>
<br>
rdar://problem/41552377<br>
<br>
Added:<br>
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/<br>
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/<br>
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/ADT.h<br>
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/B/<br>
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/B/B.h<br>
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/C/<br>
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/C/C.h<br>
cfe/trunk/test/Modules/Inputs/lsv-debuginfo/module.modulemap<br>
cfe/trunk/test/Modules/lsv-debuginfo.cpp (with props)<br>
Modified:<br>
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
cfe/trunk/test/Modules/ExtDebugInfo.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=345109&r1=345108&r2=345109&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=345109&r1=345108&r2=345109&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Oct 23 17:06:02 2018<br>
@@ -1955,8 +1955,17 @@ static bool isDefinedInClangModule(const<br>
if (auto *CXXDecl = dyn_cast<CXXRecordDecl>(RD)) {<br>
if (!CXXDecl->isCompleteDefinition())<br>
return false;<br>
+ // Check wether RD is a template.<br>
auto TemplateKind = CXXDecl->getTemplateSpecializationKind();<br>
if (TemplateKind != TSK_Undeclared) {<br>
+ // Unfortunately getOwningModule() isn't accurate enough to find the<br>
+ // owning module of a ClassTemplateSpecializationDecl that is inside a<br>
+ // namespace spanning multiple modules.<br>
+ bool Explicit = false;<br>
+ if (auto *TD = dyn_cast<ClassTemplateSpecializationDecl>(CXXDecl))<br>
+ Explicit = TD->isExplicitInstantiationOrSpecialization();<br>
+ if (!Explicit && CXXDecl->getEnclosingNamespaceContext())<br>
+ return false;<br>
// This is a template, check the origin of the first member.<br>
if (CXXDecl->field_begin() == CXXDecl->field_end())<br>
return TemplateKind == TSK_ExplicitInstantiationDeclaration;<br>
<br>
Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=345109&r1=345108&r2=345109&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=345109&r1=345108&r2=345109&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)<br>
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Tue Oct 23 17:06:02 2018<br>
@@ -83,11 +83,11 @@ void foo() {<br>
// CHECK: ![[NS]] = !DINamespace(name: "DebugCXX", scope: ![[MOD:[0-9]+]])<br>
// CHECK: ![[MOD]] = !DIModule(scope: null, name: {{.*}}DebugCXX<br>
<br>
-// This type is anchored in the module by an explicit template instantiation.<br>
+// This type is not anchored in the module by an explicit template instantiation.<br>
// CHECK: !DICompositeType(tag: DW_TAG_class_type,<br>
// CHECK-SAME: name: "Template<long, DebugCXX::traits<long> >",<br>
// CHECK-SAME: scope: ![[NS]],<br>
-// CHECK-SAME: flags: DIFlagFwdDecl,<br>
+// CHECK-SAME: elements:<br>
// CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIlEEEE")<br>
<br>
// This type is anchored in the module by an explicit template instantiation.<br>
<br>
Added: cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/ADT.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/ADT.h?rev=345109&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/ADT.h?rev=345109&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/ADT.h (added)<br>
+++ cfe/trunk/test/Modules/Inputs/lsv-debuginfo/A/ADT.h Tue Oct 23 17:06:02 2018<br>
@@ -0,0 +1,45 @@<br>
+#ifndef ADT<br>
+#define ADT<br>
+<br>
+#ifdef WITH_NAMESPACE<br>
+namespace llvm {<br>
+#endif<br>
+template <unsigned Alignment, unsigned Size><br>
+struct AlignedCharArray {<br>
+ alignas(Alignment) char buffer[Size];<br>
+};<br>
+<br>
+template <typename T1><br>
+class AlignerImpl {<br>
+ T1 t1;<br>
+};<br>
+<br>
+template <typename T1><br>
+union SizerImpl {<br>
+ char arr1[sizeof(T1)];<br>
+};<br>
+<br>
+template <typename T1><br>
+struct AlignedCharArrayUnion<br>
+ : AlignedCharArray<alignof(AlignerImpl<T1>), sizeof(SizerImpl<T1>)> {};<br>
+<br>
+template <typename T, unsigned N><br>
+struct SmallVectorStorage {<br>
+ AlignedCharArrayUnion<T> InlineElts[N];<br>
+};<br>
+template <typename T, unsigned N><br>
+class SmallVector : SmallVectorStorage<T, N> {};<br>
+<br>
+template <typename T><br>
+struct OptionalStorage {<br>
+ AlignedCharArrayUnion<T> storage;<br>
+};<br>
+template <typename T><br>
+class Optional {<br>
+ OptionalStorage<T> Storage;<br>
+};<br>
+<br>
+#ifdef WITH_NAMESPACE<br>
+} // namespace llvm<br>
+#endif<br>
+#endif<br>
<br>
Added: cfe/trunk/test/Modules/Inputs/lsv-debuginfo/B/B.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lsv-debuginfo/B/B.h?rev=345109&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lsv-debuginfo/B/B.h?rev=345109&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/Inputs/lsv-debuginfo/B/B.h (added)<br>
+++ cfe/trunk/test/Modules/Inputs/lsv-debuginfo/B/B.h Tue Oct 23 17:06:02 2018<br>
@@ -0,0 +1,14 @@<br>
+#ifndef B_H<br>
+#define B_H<br>
+#include <A/ADT.h><br>
+#include <C/C.h><br>
+<br>
+namespace llvm {<br>
+struct S {<br>
+ unsigned a, b, c, d;<br>
+};<br>
+class C {<br>
+ Optional<S> S;<br>
+};<br>
+}<br>
+#endif<br>
<br>
Added: cfe/trunk/test/Modules/Inputs/lsv-debuginfo/C/C.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lsv-debuginfo/C/C.h?rev=345109&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lsv-debuginfo/C/C.h?rev=345109&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/Inputs/lsv-debuginfo/C/C.h (added)<br>
+++ cfe/trunk/test/Modules/Inputs/lsv-debuginfo/C/C.h Tue Oct 23 17:06:02 2018<br>
@@ -0,0 +1,13 @@<br>
+#ifndef C_H<br>
+#define C_H<br>
+#include <A/ADT.h><br>
+<br>
+namespace llvm {<br>
+class D {<br>
+ struct Q {<br>
+ unsigned a, b, c, d;<br>
+ };<br>
+ SmallVector<Q, 4> q;<br>
+};<br>
+} // namespace llvm<br>
+#endif<br>
<br>
Added: cfe/trunk/test/Modules/Inputs/lsv-debuginfo/module.modulemap<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lsv-debuginfo/module.modulemap?rev=345109&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lsv-debuginfo/module.modulemap?rev=345109&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/Inputs/lsv-debuginfo/module.modulemap (added)<br>
+++ cfe/trunk/test/Modules/Inputs/lsv-debuginfo/module.modulemap Tue Oct 23 17:06:02 2018<br>
@@ -0,0 +1,9 @@<br>
+module A {<br>
+ umbrella "A" module * { export * }<br>
+}<br>
+module B {<br>
+ umbrella "B" module * { export * }<br>
+}<br>
+module C {<br>
+ umbrella "C" module * { export * }<br>
+}<br>
<br>
Added: cfe/trunk/test/Modules/lsv-debuginfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lsv-debuginfo.cpp?rev=345109&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lsv-debuginfo.cpp?rev=345109&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/lsv-debuginfo.cpp (added)<br>
+++ cfe/trunk/test/Modules/lsv-debuginfo.cpp Tue Oct 23 17:06:02 2018<br>
@@ -0,0 +1,39 @@<br>
+// Test C++ -gmodules debug info in the PCMs with local submodule visibility.<br>
+// REQUIRES: asserts<br>
+// RUN: rm -rf %t<br>
+// RUN: %clang_cc1 -triple %itanium_abi_triple \<br>
+// RUN: -fmodules-local-submodule-visibility %s \<br>
+// RUN: -dwarf-ext-refs -fmodule-format=obj -debug-info-kind=standalone \<br>
+// RUN: -dwarf-version=4 -fmodules -fimplicit-module-maps \<br>
+// RUN: -fmodules-cache-path="%t" -o %t.ll -I%S/Inputs/lsv-debuginfo \<br>
+// RUN: -mllvm -debug-only=pchcontainer &>%t-mod.ll<br>
+// RUN: cat %t-mod.ll | FileCheck %s<br>
+<br>
+// RUN: rm -rf %t<br>
+// RUN: %clang_cc1 -triple %itanium_abi_triple \<br>
+// RUN: -fmodules-local-submodule-visibility %s \<br>
+// RUN: -dwarf-ext-refs -fmodule-format=obj -debug-info-kind=standalone \<br>
+// RUN: -dwarf-version=4 -fmodules -fimplicit-module-maps \<br>
+// RUN: -fmodules-cache-path="%t" -o %t.ll -I%S/Inputs/lsv-debuginfo \<br>
+// RUN: -mllvm -debug-only=pchcontainer &>%t-mod.ll \<br>
+// RUN: -DWITH_NAMESPACE<br>
+// RUN: cat %t-mod.ll | FileCheck %s<br>
+<br>
+// ADT<br>
+// CHECK: @__clang_ast =<br>
+<br>
+// B<br>
+// CHECK: @__clang_ast =<br>
+<br>
+// This type isn't anchored anywhere, expect a full definition.<br>
+// CHECK: !DICompositeType({{.*}}, name: "AlignedCharArray<4, 16>",<br>
+// CHECK-SAME: elements:<br>
+<br>
+// C<br>
+// CHECK: @__clang_ast =<br>
+<br>
+// Here, too.<br>
+// CHECK: !DICompositeType({{.*}}, name: "AlignedCharArray<4, 16>",<br>
+// CHECK-SAME: elements:<br>
+<br>
+#include <B/B.h><br>
<br>
Propchange: cfe/trunk/test/Modules/lsv-debuginfo.cpp<br>
------------------------------------------------------------------------------<br>
svn:executable = *<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>