r272944 - [DebugInfo] Put the vftable index in the debug info

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 16 13:08:52 PDT 2016


Author: rnk
Date: Thu Jun 16 15:08:51 2016
New Revision: 272944

URL: http://llvm.org/viewvc/llvm-project?rev=272944&view=rev
Log:
[DebugInfo] Put the vftable index in the debug info

This won't always be enough info to call a virtual method from the
debugger, but it's a start.

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=272944&r1=272943&r2=272944&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jun 16 15:08:51 2016
@@ -1185,14 +1185,23 @@ llvm::DISubprogram *CGDebugInfo::CreateC
     else
       Virtuality = llvm::dwarf::DW_VIRTUALITY_virtual;
 
-    // It doesn't make sense to give a virtual destructor a vtable index,
-    // since a single destructor has two entries in the vtable.
-    // FIXME: Add proper support for debug info for virtual calls in
-    // the Microsoft ABI, where we may use multiple vptrs to make a vftable
-    // lookup if we have multiple or virtual inheritance.
-    if (!isa<CXXDestructorDecl>(Method) &&
-        !CGM.getTarget().getCXXABI().isMicrosoft())
-      VIndex = CGM.getItaniumVTableContext().getMethodVTableIndex(Method);
+    if (CGM.getTarget().getCXXABI().isItaniumFamily()) {
+      // It doesn't make sense to give a virtual destructor a vtable index,
+      // since a single destructor has two entries in the vtable.
+      if (!isa<CXXDestructorDecl>(Method))
+        VIndex = CGM.getItaniumVTableContext().getMethodVTableIndex(Method);
+    } else {
+      // Emit MS ABI vftable information.  There is only one entry for the
+      // deleting dtor.
+      const auto *DD = dyn_cast<CXXDestructorDecl>(Method);
+      GlobalDecl GD = DD ? GlobalDecl(DD, Dtor_Deleting) : GlobalDecl(Method);
+      MicrosoftVTableContext::MethodVFTableLocation ML =
+          CGM.getMicrosoftVTableContext().getMethodVFTableLocation(GD);
+      VIndex = ML.Index;
+      // FIXME: Pass down ML.VFPtrOffset and ML.VBTableIndex. The debugger needs
+      // these to synthesize a call to a virtual method in a complex inheritance
+      // hierarchy.
+    }
     ContainingType = RecordTy;
   }
 

Modified: cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp?rev=272944&r1=272943&r2=272944&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-ms-abi.cpp Thu Jun 16 15:08:51 2016
@@ -3,11 +3,17 @@
 // Tests that certain miscellaneous features work in the MS ABI.
 
 struct Foo {
+  virtual void f();
+  virtual void g();
+  virtual void h();
   struct Nested {};
 };
 Foo f;
 Foo::Nested n;
-// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo",
+// CHECK: ![[Foo:[^ ]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo",
 // CHECK-SAME: identifier: ".?AUFoo@@"
+// CHECK: !DISubprogram(name: "f", {{.*}} containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 0, {{.*}})
+// CHECK: !DISubprogram(name: "g", {{.*}} containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 1, {{.*}})
+// CHECK: !DISubprogram(name: "h", {{.*}} containingType: ![[Foo]], virtuality: DW_VIRTUALITY_virtual, virtualIndex: 2, {{.*}})
 // CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested",
 // CHECK-SAME: identifier: ".?AUNested at Foo@@"




More information about the cfe-commits mailing list