<div dir="ltr">Great - are you tracking/planning to implement this for trivial_abi once it's in? (was mentioned in the code review, but not sure if it's on your plate/plan or not (no worries if it isn't, just keeping these things in mind))</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jan 4, 2018 at 5:14 PM Adrian Prantl via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Thu Jan  4 17:13:52 2018<br>
New Revision: 321845<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=321845&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=321845&view=rev</a><br>
Log:<br>
Debug Info: Support DW_AT_calling_convention on composite types.<br>
This implements the DWARF 5 feature described at<br>
<a href="http://www.dwarfstd.org/ShowIssue.php?issue=141215.1" rel="noreferrer" target="_blank">http://www.dwarfstd.org/ShowIssue.php?issue=141215.1</a><br>
<br>
This allows a consumer to understand whether a composite data type is<br>
trivially copyable and thus should be passed by value instead of by<br>
reference. The canonical example is being able to distinguish the<br>
following two types:<br>
<br>
  // S is not trivially copyable because of the explicit destructor.<br>
  struct S {<br>
     ~S() {}<br>
  };<br>
<br>
  // T is a POD type.<br>
  struct T {<br>
    ~T() = default;<br>
  };<br>
<br>
<rdar://problem/36034993><br>
Differential Revision: <a href="https://reviews.llvm.org/D41039" rel="noreferrer" target="_blank">https://reviews.llvm.org/D41039</a><br>
<br>
Added:<br>
    cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321845&r1=321844&r2=321845&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321845&r1=321844&r2=321845&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jan  4 17:13:52 2018<br>
@@ -2803,9 +2803,18 @@ llvm::DICompositeType *CGDebugInfo::Crea<br>
<br>
   SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);<br>
<br>
+  // Explicitly record the calling convention for C++ records.<br>
+  auto Flags = llvm::DINode::FlagZero;<br>
+  if (auto CXXRD = dyn_cast<CXXRecordDecl>(RD)) {<br>
+    if (CGM.getCXXABI().getRecordArgABI(CXXRD) == CGCXXABI::RAA_Indirect)<br>
+      Flags |= llvm::DINode::FlagTypePassByReference;<br>
+    else<br>
+      Flags |= llvm::DINode::FlagTypePassByValue;<br>
+  }<br>
+<br>
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(<br>
       getTagForRecord(RD), RDName, RDContext, DefUnit, Line, 0, Size, Align,<br>
-      llvm::DINode::FlagZero, FullName);<br>
+      Flags, FullName);<br>
<br>
   // Elements of composite types usually have back to the type, creating<br>
   // uniquing cycles.  Distinct nodes are more efficient.<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=321845&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=321845&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp Thu Jan  4 17:13:52 2018<br>
@@ -0,0 +1,48 @@<br>
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple %itanium_abi_triple %s -o - | FileCheck %s<br>
+<br>
+// Not trivially copyable because of the explicit destructor.<br>
+// CHECK-DAG: !DICompositeType({{.*}}, name: "RefDtor",{{.*}}flags: DIFlagTypePassByReference<br>
+struct RefDtor {<br>
+  int i;<br>
+  ~RefDtor() {}<br>
+} refDtor;<br>
+<br>
+// Not trivially copyable because of the explicit copy constructor.<br>
+// CHECK-DAG: !DICompositeType({{.*}}, name: "RefCopy",{{.*}}flags: DIFlagTypePassByReference<br>
+struct RefCopy {<br>
+  int i;<br>
+  RefCopy() = default;<br>
+  RefCopy(RefCopy &Copy) {}<br>
+} refCopy;<br>
+<br>
+// Not trivially copyable because of the explicit move constructor.<br>
+// CHECK-DAG: !DICompositeType({{.*}}, name: "RefMove",{{.*}}flags: DIFlagTypePassByReference<br>
+struct RefMove {<br>
+  int i;<br>
+  RefMove() = default;<br>
+  RefMove(RefMove &&Move) {}<br>
+} refMove;<br>
+<br>
+// POD-like type even though it defines a destructor.<br>
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Podlike", {{.*}}flags: DIFlagTypePassByValue<br>
+struct Podlike {<br>
+  int i;<br>
+  Podlike() = default;<br>
+  Podlike(Podlike &&Move) = default;<br>
+  ~Podlike() = default;<br>
+} podlike;<br>
+<br>
+<br>
+// This is a POD type.<br>
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Pod",{{.*}}flags: DIFlagTypePassByValue<br>
+struct Pod {<br>
+  int i;<br>
+} pod;<br>
+<br>
+// This is definitely not a POD type.<br>
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Complex",{{.*}}flags: DIFlagTypePassByReference<br>
+struct Complex {<br>
+  Complex() {}<br>
+  Complex(Complex &Copy) : i(Copy.i) {};<br>
+  int i;<br>
+} complex;<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>