<div dir="auto"><div dir="auto">This is an ABI break (theoretically), but due to its nature I'm not too concerned.</div><div dir="auto"><br></div>Please update the documentation for the attribute to describe these new semantics, though: the documentation currently says that we're just treating certain special members as if they were trivial when determining whether we can pass in registers, and that's not true any more, because the ABI says that classes with only deleted copy and move ctors is never passed in registers regardless of triviality.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, 10 Jan 2019, 23:10 Akira Hatanaka 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: ahatanak<br>
Date: Thu Jan 10 23:06:38 2019<br>
New Revision: 350920<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=350920&view=rev" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=350920&view=rev</a><br>
Log:<br>
[Sema] Make canPassInRegisters return true if the CXXRecordDecl passed<br>
to it is a trivial_abi class.<br>
<br>
A class that has all of its copy and move constructors deleted can still<br>
be passed or returned in registers if the class is annotated with<br>
trivial_abi.<br>
<br>
This fixes PR39683.<br>
<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
    cfe/trunk/test/CodeGenCXX/trivial_abi.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=350920&r1=350919&r2=350920&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=350920&r1=350919&r2=350920&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jan 10 23:06:38 2019<br>
@@ -5886,6 +5886,9 @@ static bool canPassInRegisters(Sema &S,<br>
   if (D->isDependentType() || D->isInvalidDecl())<br>
     return false;<br>
<br>
+  if (D->hasAttr<TrivialABIAttr>())<br>
+    return true;<br>
+<br>
   // Clang <= 4 used the pre-C++11 rule, which ignores move operations.<br>
   // The PS4 platform ABI follows the behavior of Clang 3.2.<br>
   if (CCK == TargetInfo::CCK_ClangABI4OrPS4)<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/trivial_abi.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/trivial_abi.cpp?rev=350920&r1=350919&r2=350920&view=diff" rel="noreferrer noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/trivial_abi.cpp?rev=350920&r1=350919&r2=350920&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/trivial_abi.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/trivial_abi.cpp Thu Jan 10 23:06:38 2019<br>
@@ -1,5 +1,5 @@<br>
-// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s<br>
-// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions -fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s<br>
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s<br>
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions -fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s<br>
<br>
 // CHECK: %[[STRUCT_SMALL:.*]] = type { i32* }<br>
 // CHECK: %[[STRUCT_LARGE:.*]] = type { i32*, [128 x i32] }<br>
@@ -43,6 +43,13 @@ struct HasNonTrivial {<br>
   NonTrivial m;<br>
 };<br>
<br>
+struct __attribute__((trivial_abi)) CopyMoveDeleted {<br>
+  CopyMoveDeleted(int);<br>
+  CopyMoveDeleted(const CopyMoveDeleted &) = delete;<br>
+  CopyMoveDeleted(CopyMoveDeleted &&) = delete;<br>
+  int a;<br>
+};<br>
+<br>
 // CHECK: define void @_Z14testParamSmall5Small(i64 %[[A_COERCE:.*]])<br>
 // CHECK: %[[A:.*]] = alloca %[[STRUCT_SMALL]], align 8<br>
 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[A]], i32 0, i32 0<br>
@@ -237,3 +244,11 @@ void calleeExceptionLarge(Large, Large);<br>
 void testExceptionLarge() {<br>
   calleeExceptionLarge(Large(), Large());<br>
 }<br>
+<br>
+// A class with deleted copy and move constructors can still be passed or<br>
+// returned in registers if the class is annotated with trivial_abi.<br>
+<br>
+// CHECK: define i64 @_Z19testCopyMoveDeletedi(i32 %<br>
+CopyMoveDeleted testCopyMoveDeleted(int a) {<br>
+  return a;<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" rel="noreferrer">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>