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

2017-02-27 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:955-957
+// DWARFv5 doesn't specify explicit DW_CC_* value for this case,
+// thus we just return 'normal' here.
+return llvm::dwarf::DW_CC_normal;

dblaikie wrote:
> Could you file a bug/feature request with the DWARF committee? & maybe we 
> could/should use an implementation defined extension value here? (assuming 
> the DW_CC set has an implementation defined space - which I really hope it 
> does)
Plenty:
DW_CC_lo_user   0x40
DW_CC_hi_user   0xff


https://reviews.llvm.org/D30378



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-02-27 Thread Victor Leschuk via Phabricator via cfe-commits
vleschuk added inline comments.



Comment at: test/CodeGenCXX/debug-info-type-calling-conventions.cpp:11-12
+
+class UserDtor {
+public:
+  ~UserDtor() {}

dblaikie wrote:
> I'd probably make this a struct (and drop the 'public:' section since it'll 
> be the default then) - since it doesn't seem to matter here.
Will do when I fix this bug: 
http://lists.llvm.org/pipermail/llvm-dev/2017-February/110557.html


https://reviews.llvm.org/D30378



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-02-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Be best to avoid having to 'fixup' the argabi after the fact - and instead 
build the type with the right argabi from the get-go.




Comment at: lib/CodeGen/CGDebugInfo.cpp:955-957
+// DWARFv5 doesn't specify explicit DW_CC_* value for this case,
+// thus we just return 'normal' here.
+return llvm::dwarf::DW_CC_normal;

Could you file a bug/feature request with the DWARF committee? & maybe we 
could/should use an implementation defined extension value here? (assuming the 
DW_CC set has an implementation defined space - which I really hope it does)



Comment at: test/CodeGenCXX/debug-info-type-calling-conventions.cpp:11-12
+
+class UserDtor {
+public:
+  ~UserDtor() {}

I'd probably make this a struct (and drop the 'public:' section since it'll be 
the default then) - since it doesn't seem to matter here.


https://reviews.llvm.org/D30378



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-02-25 Thread Victor Leschuk via Phabricator via cfe-commits
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::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 ,
+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 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).


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::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 ,
+const CXXRecordDecl *CXXDecl) {
+  switch (CGM.getCXXABI().getRecordArgABI(CXXDecl)) {
+  case CGCXXABI::RAA_Default:
+return llvm::dwarf::DW_CC_pass_by_value;
+  case