Skip to content

Commit 9e67183

Browse files
committed
Revert "[Sema] Make canPassInRegisters return true if the CXXRecordDecl passed"
This reverts commit r350920 as it is not clear whether we should force a class to be returned in registers when copy and move constructors are both deleted. For more background, see the following discussion: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190128/259907.html llvm-svn: 352822
1 parent ef9a388 commit 9e67183

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5889,9 +5889,6 @@ static bool canPassInRegisters(Sema &S, CXXRecordDecl *D,
58895889
if (D->isDependentType() || D->isInvalidDecl())
58905890
return false;
58915891

5892-
if (D->hasAttr<TrivialABIAttr>())
5893-
return true;
5894-
58955892
// Clang <= 4 used the pre-C++11 rule, which ignores move operations.
58965893
// The PS4 platform ABI follows the behavior of Clang 3.2.
58975894
if (CCK == TargetInfo::CCK_ClangABI4OrPS4)

clang/test/CodeGenCXX/trivial_abi.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s
2-
// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions -fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
1+
// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions -fexceptions -emit-llvm -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions -fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
33

44
// CHECK: %[[STRUCT_SMALL:.*]] = type { i32* }
55
// CHECK: %[[STRUCT_LARGE:.*]] = type { i32*, [128 x i32] }
@@ -43,13 +43,6 @@ struct HasNonTrivial {
4343
NonTrivial m;
4444
};
4545

46-
struct __attribute__((trivial_abi)) CopyMoveDeleted {
47-
CopyMoveDeleted(int);
48-
CopyMoveDeleted(const CopyMoveDeleted &) = delete;
49-
CopyMoveDeleted(CopyMoveDeleted &&) = delete;
50-
int a;
51-
};
52-
5346
// CHECK: define void @_Z14testParamSmall5Small(i64 %[[A_COERCE:.*]])
5447
// CHECK: %[[A:.*]] = alloca %[[STRUCT_SMALL]], align 8
5548
// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[A]], i32 0, i32 0
@@ -244,11 +237,3 @@ void calleeExceptionLarge(Large, Large);
244237
void testExceptionLarge() {
245238
calleeExceptionLarge(Large(), Large());
246239
}
247-
248-
// A class with deleted copy and move constructors can still be passed or
249-
// returned in registers if the class is annotated with trivial_abi.
250-
251-
// CHECK: define i64 @_Z19testCopyMoveDeletedi(i32 %
252-
CopyMoveDeleted testCopyMoveDeleted(int a) {
253-
return a;
254-
}

0 commit comments

Comments
 (0)