Skip to content

Commit b3e2d6d

Browse files
authored
Suppress returning larger CXX records in mem on PlayStation (#161732)
In commit e8a486e, a change was made so that certain 256-bit and 512-bit CXX records would be returned in memory, fixing a violation of the x86-64 psABI (where they had been incorrectly returned in AVX registers). For compatibility reasons, we want to suppress that ABI-fix on PlayStation. This commit suppresses that change for PlayStation, and updates the test to include checking the 512-bit case.
1 parent 3757fa6 commit b3e2d6d

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

clang/lib/CodeGen/Targets/X86.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,9 +1343,10 @@ class X86_64ABIInfo : public ABIInfo {
13431343
}
13441344

13451345
bool returnCXXRecordGreaterThan128InMem() const {
1346-
// Clang <= 20.0 did not do this.
1346+
// Clang <= 20.0 did not do this, and PlayStation does not do this.
13471347
if (getContext().getLangOpts().getClangABICompat() <=
1348-
LangOptions::ClangABI::Ver20)
1348+
LangOptions::ClangABI::Ver20 ||
1349+
getTarget().getTriple().isPS())
13491350
return false;
13501351

13511352
return true;

clang/test/CodeGen/X86/avx-cxx-record.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -O2 -target-cpu x86-64-v3 -o - | FileCheck %s
22
// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -O2 -target-cpu x86-64-v3 -fclang-abi-compat=20 -o - | FileCheck --check-prefix CLANG-20 %s
3+
// RUN: %clang_cc1 %s -triple x86_64-sie-ps4 -emit-llvm -O2 -target-cpu x86-64-v3 -o - | FileCheck --check-prefix CLANG-20 %s
34

45
using UInt64x2 = unsigned long long __attribute__((__vector_size__(16), may_alias));
6+
using UInt64x4 = unsigned long long __attribute__((__vector_size__(32), may_alias));
57

68
template<int id>
79
struct XMM1 {
@@ -23,3 +25,24 @@ XMM2 foo() {
2325
((XMM1<1>*)&result)->x = UInt64x2{3, 4};
2426
return result;
2527
}
28+
29+
template<int id>
30+
struct YMM1 {
31+
UInt64x4 x;
32+
};
33+
34+
struct YMM2 : YMM1<0>, YMM1<1> {
35+
};
36+
37+
// CHECK: define{{.*}} @_Z3barv({{.*}} [[ARG:%.*]]){{.*}}
38+
// CLANG-20: define{{.*}} <8 x double> @_Z3barv()
39+
// CHECK: entry:
40+
// CHECK-NEXT: store {{.*}}, ptr [[ARG]]{{.*}}
41+
// CHECK-NEXT: [[TMP1:%.*]] = getelementptr {{.*}}, ptr [[ARG]]{{.*}}
42+
// CHECK-NEXT: store {{.*}}, ptr [[TMP1]]{{.*}}
43+
YMM2 bar() {
44+
YMM2 result;
45+
((YMM1<0>*)&result)->x = UInt64x4{1, 2, 3, 4};
46+
((YMM1<1>*)&result)->x = UInt64x4{5, 6, 7, 8};
47+
return result;
48+
}

0 commit comments

Comments
 (0)