[PATCH] D30378: [DebugInfo] [DWARFv5] Collect calling convention info for C++ types during codegen

Victor Leschuk via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 25 07:29:07 PST 2017


vleschuk created this revision.

When generating debug info collect information on calling convention for types (http://www.dwarfstd.org/ShowIssue.php?issue=141215.1) and pass it to backend.


https://reviews.llvm.org/D30378

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenCXX/debug-info-type-calling-conventions.cpp


Index: test/CodeGenCXX/debug-info-type-calling-conventions.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/debug-info-type-calling-conventions.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -dwarf-version=5 -std=c++11 -debug-info-kind=limited -emit-llvm -o - | FileCheck %s
+
+struct DefaultDtor {
+  ~DefaultDtor() = default;
+};
+
+void f(DefaultDtor arg) {}
+
+// CHECK: !DICompositeType({{.*}}name: "DefaultDtor"{{.*}}argABI: DW_CC_pass_by_value
+
+class UserDtor {
+public:
+  ~UserDtor() {}
+};
+
+void f(UserDtor arg) {}
+
+// CHECK: !DICompositeType({{.*}}name: "UserDtor"{{.*}}argABI: DW_CC_pass_by_reference
Index: lib/CodeGen/CGDebugInfo.h
===================================================================
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -287,6 +287,9 @@
   void CollectVTableInfo(const CXXRecordDecl *Decl, llvm::DIFile *F,
                          SmallVectorImpl<llvm::Metadata *> &EltTys,
                          llvm::DICompositeType *RecordTy);
+
+  void CollectArgABIInfo(const CXXRecordDecl *Decl,
+                         llvm::DICompositeType *RecordTy);
   /// @}
 
   /// Create a new lexical block node and push it on the stack.
Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -944,6 +944,21 @@
   return 0;
 }
 
+static llvm::dwarf::CallingConvention getArgABI(const CodeGenModule &CGM,
+                                                const CXXRecordDecl *CXXDecl) {
+  switch (CGM.getCXXABI().getRecordArgABI(CXXDecl)) {
+  case CGCXXABI::RAA_Default:
+    return llvm::dwarf::DW_CC_pass_by_value;
+  case CGCXXABI::RAA_Indirect:
+    return llvm::dwarf::DW_CC_pass_by_reference;
+  case CGCXXABI::RAA_DirectInMemory:
+    // DWARFv5 doesn't specify explicit DW_CC_* value for this case,
+    // thus we just return 'normal' here.
+    return llvm::dwarf::DW_CC_normal;
+  }
+  return llvm::dwarf::DW_CC_normal;
+}
+
 llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
                                       llvm::DIFile *Unit) {
   SmallVector<llvm::Metadata *, 16> EltTys;
@@ -1671,6 +1686,11 @@
   EltTys.push_back(VPtrMember);
 }
 
+void CGDebugInfo::CollectArgABIInfo(const CXXRecordDecl *Decl,
+                                    llvm::DICompositeType *RecordTy) {
+  DBuilder.replaceArgABI(RecordTy, getArgABI(CGM, Decl));
+}
+
 llvm::DIType *CGDebugInfo::getOrCreateRecordType(QualType RTy,
                                                  SourceLocation Loc) {
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
@@ -1881,6 +1901,7 @@
   if (CXXDecl) {
     CollectCXXBases(CXXDecl, DefUnit, EltTys, FwdDecl);
     CollectVTableInfo(CXXDecl, DefUnit, EltTys, FwdDecl);
+    CollectArgABIInfo(CXXDecl, FwdDecl);
   }
 
   // Collect data fields (including static variables and any initializers).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30378.89789.patch
Type: text/x-patch
Size: 2964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170225/abcbcddd/attachment.bin>


More information about the cfe-commits mailing list