<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 8, 2018, at 8:14 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">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></div></blockquote><div><br class=""></div><div>Yes, this was in fact my primary motivation for the feature. Since the code is asking the ABI object, it looks like this might work out of the box with the trivial_abi attribute, but I will definitely at least add a testcase once it's in.</div><div><br class=""></div><div>-- adrian</div><br class=""><blockquote type="cite" class=""><div class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, Jan 4, 2018 at 5:14 PM Adrian Prantl via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br class="">
Date: Thu Jan 4 17:13:52 2018<br class="">
New Revision: 321845<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=321845&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=321845&view=rev</a><br class="">
Log:<br class="">
Debug Info: Support DW_AT_calling_convention on composite types.<br class="">
This implements the DWARF 5 feature described at<br class="">
<a href="http://www.dwarfstd.org/ShowIssue.php?issue=141215.1" rel="noreferrer" target="_blank" class="">http://www.dwarfstd.org/ShowIssue.php?issue=141215.1</a><br class="">
<br class="">
This allows a consumer to understand whether a composite data type is<br class="">
trivially copyable and thus should be passed by value instead of by<br class="">
reference. The canonical example is being able to distinguish the<br class="">
following two types:<br class="">
<br class="">
// S is not trivially copyable because of the explicit destructor.<br class="">
struct S {<br class="">
~S() {}<br class="">
};<br class="">
<br class="">
// T is a POD type.<br class="">
struct T {<br class="">
~T() = default;<br class="">
};<br class="">
<br class="">
<<a href="rdar://problem/36034993" class="">rdar://problem/36034993</a>><br class="">
Differential Revision: <a href="https://reviews.llvm.org/D41039" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/D41039</a><br class="">
<br class="">
Added:<br class="">
cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp<br class="">
Modified:<br class="">
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class="">
<br class="">
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321845&r1=321844&r2=321845&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br class="">
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jan 4 17:13:52 2018<br class="">
@@ -2803,9 +2803,18 @@ llvm::DICompositeType *CGDebugInfo::Crea<br class="">
<br class="">
SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);<br class="">
<br class="">
+ // Explicitly record the calling convention for C++ records.<br class="">
+ auto Flags = llvm::DINode::FlagZero;<br class="">
+ if (auto CXXRD = dyn_cast<CXXRecordDecl>(RD)) {<br class="">
+ if (CGM.getCXXABI().getRecordArgABI(CXXRD) == CGCXXABI::RAA_Indirect)<br class="">
+ Flags |= llvm::DINode::FlagTypePassByReference;<br class="">
+ else<br class="">
+ Flags |= llvm::DINode::FlagTypePassByValue;<br class="">
+ }<br class="">
+<br class="">
llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(<br class="">
getTagForRecord(RD), RDName, RDContext, DefUnit, Line, 0, Size, Align,<br class="">
- llvm::DINode::FlagZero, FullName);<br class="">
+ Flags, FullName);<br class="">
<br class="">
// Elements of composite types usually have back to the type, creating<br class="">
// uniquing cycles. Distinct nodes are more efficient.<br class="">
<br class="">
Added: cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=321845&view=auto</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp (added)<br class="">
+++ cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp Thu Jan 4 17:13:52 2018<br class="">
@@ -0,0 +1,48 @@<br class="">
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple %itanium_abi_triple %s -o - | FileCheck %s<br class="">
+<br class="">
+// Not trivially copyable because of the explicit destructor.<br class="">
+// CHECK-DAG: !DICompositeType({{.*}}, name: "RefDtor",{{.*}}flags: DIFlagTypePassByReference<br class="">
+struct RefDtor {<br class="">
+ int i;<br class="">
+ ~RefDtor() {}<br class="">
+} refDtor;<br class="">
+<br class="">
+// Not trivially copyable because of the explicit copy constructor.<br class="">
+// CHECK-DAG: !DICompositeType({{.*}}, name: "RefCopy",{{.*}}flags: DIFlagTypePassByReference<br class="">
+struct RefCopy {<br class="">
+ int i;<br class="">
+ RefCopy() = default;<br class="">
+ RefCopy(RefCopy &Copy) {}<br class="">
+} refCopy;<br class="">
+<br class="">
+// Not trivially copyable because of the explicit move constructor.<br class="">
+// CHECK-DAG: !DICompositeType({{.*}}, name: "RefMove",{{.*}}flags: DIFlagTypePassByReference<br class="">
+struct RefMove {<br class="">
+ int i;<br class="">
+ RefMove() = default;<br class="">
+ RefMove(RefMove &&Move) {}<br class="">
+} refMove;<br class="">
+<br class="">
+// POD-like type even though it defines a destructor.<br class="">
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Podlike", {{.*}}flags: DIFlagTypePassByValue<br class="">
+struct Podlike {<br class="">
+ int i;<br class="">
+ Podlike() = default;<br class="">
+ Podlike(Podlike &&Move) = default;<br class="">
+ ~Podlike() = default;<br class="">
+} podlike;<br class="">
+<br class="">
+<br class="">
+// This is a POD type.<br class="">
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Pod",{{.*}}flags: DIFlagTypePassByValue<br class="">
+struct Pod {<br class="">
+ int i;<br class="">
+} pod;<br class="">
+<br class="">
+// This is definitely not a POD type.<br class="">
+// CHECK-DAG: !DICompositeType({{.*}}, name: "Complex",{{.*}}flags: DIFlagTypePassByReference<br class="">
+struct Complex {<br class="">
+ Complex() {}<br class="">
+ Complex(Complex &Copy) : i(Copy.i) {};<br class="">
+ int i;<br class="">
+} complex;<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
cfe-commits mailing list<br class="">
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></body></html>