[clang] 4e719e0 - DebugInfo: Prefer vtable homing over ctor homing.

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 27 17:10:53 PDT 2022


Author: David Blaikie
Date: 2022-07-28T00:07:35Z
New Revision: 4e719e0f16933a8945a4e85db39fdad5afbede36

URL: https://github.com/llvm/llvm-project/commit/4e719e0f16933a8945a4e85db39fdad5afbede36
DIFF: https://github.com/llvm/llvm-project/commit/4e719e0f16933a8945a4e85db39fdad5afbede36.diff

LOG: DebugInfo: Prefer vtable homing over ctor homing.

Vtables will be emitted in fewer places than ctors (every ctor
references the vtable, so at worst it's the same places - but at best
the type has a non-inline key function and the vtable is emitted in one
place)

Pulling this fix out of 517bbc64dbe493644eff8d55fd9566435e930520 which
was reverted in 4821508d4db75a535d02b8938f81fac6de66cc26

Added: 
    

Modified: 
    clang/lib/CodeGen/CGDebugInfo.cpp
    clang/test/CodeGenCXX/debug-info-limited-ctor.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 94c48316add7..6821fc97e504 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3351,7 +3351,7 @@ void CGDebugInfo::completeTemplateDefinition(
 }
 
 void CGDebugInfo::completeUnusedClass(const CXXRecordDecl &D) {
-  if (DebugKind <= codegenoptions::DebugLineTablesOnly)
+  if (DebugKind <= codegenoptions::DebugLineTablesOnly || D.isDynamicClass())
     return;
 
   completeClassData(&D);

diff  --git a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
index 835e6d481622..d17e3a142ad7 100644
--- a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -77,3 +77,14 @@ void L() {
 // Check that types are being added to retained types list.
 // CHECK-DAG: !DICompileUnit{{.*}}retainedTypes: ![[RETAINED:[0-9]+]]
 // CHECK-DAG: ![[RETAINED]] = {{.*}}![[C]]
+
+
+struct VTableAndCtor {
+  virtual void f1();
+  VTableAndCtor();
+};
+
+VTableAndCtor::VTableAndCtor() {
+}
+
+// CHECK-DAG: !DICompositeType({{.*}}name: "VTableAndCtor", {{.*}}flags: DIFlagFwdDecl


        


More information about the cfe-commits mailing list