]> granicus.if.org Git - clang/commitdiff
Skip type units/type uniquing when we know we're only emitting the type once (vtable...
authorDavid Blaikie <dblaikie@gmail.com>
Thu, 25 Apr 2019 20:05:47 +0000 (20:05 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Thu, 25 Apr 2019 20:05:47 +0000 (20:05 +0000)
(this would regress size without a corresponding LLVM change that avoids
putting other user defined types inside type units when they aren't in
their own type units - instead emitting declarations inside the type
unit and a definition in the primary CU)

Reviewers: aprantl

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

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

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenCXX/debug-info-class.cpp
test/Modules/ExtDebugInfo.cpp
test/Modules/ModuleDebugInfo.cpp

index d62757ec9175571fcf5f73aaa99803f390adf0c6..80d348462327ce5c236cfec9d891fedba8f0e588 100644 (file)
@@ -915,6 +915,11 @@ static SmallString<256> getTypeIdentifier(const TagType *Ty, CodeGenModule &CGM,
 
   if (!needsTypeIdentifier(TD, CGM, TheCU))
     return Identifier;
+  if (const auto *RD = dyn_cast<CXXRecordDecl>(TD))
+    if (RD->getDefinition())
+      if (RD->isDynamicClass() &&
+          CGM.getVTableLinkage(RD) == llvm::GlobalValue::ExternalLinkage)
+        return Identifier;
 
   // TODO: This is using the RTTI name. Is there a better way to get
   // a unique string for a type?
index 747b377ffb2f9fdcc4db8f75aef18b66f34282cf..b3e79c37923dd2992521fea7f2bcd2399c0f68d1 100644 (file)
@@ -57,6 +57,11 @@ struct I : virtual H {};
 struct J : I {};
 J j;
 
+struct K {
+  virtual void func() {
+  }
+};
+
 struct A {
   int one;
   static const int HdrSize = 52;
@@ -72,6 +77,8 @@ void f1() {
   E y;
   int i = F::i;
   F::inner z;
+  K k;
+  k.func();
 }
 
 int main(int argc, char **argv) {
@@ -98,7 +105,8 @@ int main(int argc, char **argv) {
 
 // CHECK: [[F:![0-9]*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "F"
 // CHECK-SAME:                             DIFlagFwdDecl
-// CHECK-SAME:                             identifier: "_ZTS1F"
+// CHECK-NOT:                             identifier:
+// CHECK-SAME:                            ){{$}}
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "I"
 // CHECK-NOT:              DIFlagFwdDecl
 // CHECK-SAME:             ){{$}}
@@ -117,7 +125,8 @@ int main(int argc, char **argv) {
 // CHECK-NOT:                              DIFlagFwdDecl
 // CHECK-SAME:                             elements: [[C_MEM:![0-9]*]]
 // CHECK-SAME:                             vtableHolder: [[C]]
-// CHECK-SAME:                             identifier: "_ZTS1C"
+// CHECK-NOT:                              identifier:
+// CHECK-SAME:                             ){{$}}
 // CHECK: [[C_MEM]] = !{[[C_VPTR:![0-9]*]], [[C_S:![0-9]*]], [[C_DTOR:![0-9]*]]}
 // CHECK: [[C_VPTR]] = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$C"
 // CHECK-SAME:                        DIFlagArtificial
@@ -129,10 +138,16 @@ int main(int argc, char **argv) {
 // CHECK: [[D:![0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "D"
 // CHECK-NOT:              size:
 // CHECK-SAME:             DIFlagFwdDecl
-// CHECK-SAME:             identifier: "_ZTS1D"
+// CHECK-NOT:              identifier:
+// CHECK-SAME:             ){{$}}
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "E"
 // CHECK-SAME:             DIFlagFwdDecl
-// CHECK-SAME:             identifier: "_ZTS1E"
+// CHECK-NOT:              identifier:
+// CHECK-SAME:             ){{$}}
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "K"
+// CHECK-SAME:             identifier: "_ZTS1K"
+// CHECK-SAME:             ){{$}}
 
 // CHECK: !DISubprogram(name: "func",{{.*}} scope: [[D]]
 // CHECK-SAME:          DISPFlagDefinition
@@ -146,7 +161,8 @@ int main(int argc, char **argv) {
 
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "G"
 // CHECK-SAME:             DIFlagFwdDecl
-// CHECK-SAME:             identifier: "_ZTS1G"
+// CHECK-NOT:              identifier:
+// CHECK-SAME:             ){{$}}
 // CHECK: [[G_INNER_MEM]] = !{[[G_INNER_I:![0-9]*]]}
 // CHECK: [[G_INNER_I]] = !DIDerivedType(tag: DW_TAG_member, name: "j"
 // CHECK-SAME:                           baseType: ![[INT]]
@@ -154,5 +170,5 @@ int main(int argc, char **argv) {
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "A"
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "HdrSize"
 //
-// CHECK: ![[EXCEPTLOC]] = !DILocation(line: 84,
-// CHECK: ![[RETLOC]] = !DILocation(line: 83,
+// CHECK: ![[EXCEPTLOC]] = !DILocation(line: 91,
+// CHECK: ![[RETLOC]] = !DILocation(line: 90,
index 592612b9a5db88ea0acb69b47fec8af9b2a3a06d..5d2921cd99599392fb7a8af502dc3ba534aaa967 100644 (file)
@@ -214,7 +214,7 @@ void foo() {
 // CHECK-PCH:                dwoId: 18446744073709551614
 
 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A",
-// CHECK-SAME:             DIFlagFwdDecl, identifier: "_ZTS1A")
+// CHECK-SAME:             DIFlagFwdDecl)
 
 // There is a full definition of the type available in the module.
 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Virtual",
index 116aa5fc3107b9ab6bb46d2fb264f425f1f9afaf..6fe546f7013e51385ca04275b688e016c6558f27 100644 (file)
 
 // CHECK: ![[A:.*]] = {{.*}}!DICompositeType(tag: DW_TAG_class_type, name: "A",
 // CHECK-SAME:                               elements:
-// CHECK-SAME:                               vtableHolder: ![[A]],
-// CHECK-SAME:                               identifier: "_ZTS1A")
+// CHECK-SAME:                               vtableHolder: ![[A]])
 
 // CHECK: ![[DERIVED:.*]] = {{.*}}!DICompositeType(tag: DW_TAG_class_type, name: "Derived",
 // CHECK-SAME:                                     identifier: "_ZTS7Derived")