Skip to content

Commit 64e0835

Browse files
authored
[clang] Make PS template DLL attribute propagation the same as MSVC (#92549)
For PlayStation, make the propagation of DLL import/export attributes for explicit template instantiations the same as MSVC and Windows Itanium.
1 parent d0dc29c commit 64e0835

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11124,8 +11124,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
1112411124
Def->setTemplateSpecializationKind(TSK);
1112511125

1112611126
if (!getDLLAttr(Def) && getDLLAttr(Specialization) &&
11127-
(Context.getTargetInfo().shouldDLLImportComdatSymbols() &&
11128-
!Context.getTargetInfo().getTriple().isPS())) {
11127+
Context.getTargetInfo().shouldDLLImportComdatSymbols()) {
1112911128
// An explicit instantiation definition can add a dll attribute to a
1113011129
// template with a previous instantiation declaration. MinGW doesn't
1113111130
// allow this.
@@ -11142,8 +11141,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
1114211141
bool NewlyDLLExported =
1114311142
!PreviouslyDLLExported && Specialization->hasAttr<DLLExportAttr>();
1114411143
if (Old_TSK == TSK_ImplicitInstantiation && NewlyDLLExported &&
11145-
(Context.getTargetInfo().shouldDLLImportComdatSymbols() &&
11146-
!Context.getTargetInfo().getTriple().isPS())) {
11144+
Context.getTargetInfo().shouldDLLImportComdatSymbols()) {
1114711145
// An explicit instantiation definition can add a dll attribute to a
1114811146
// template with a previous implicit instantiation. MinGW doesn't allow
1114911147
// this. We limit clang to only adding dllexport, to avoid potentially
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_cc1 -std=c++11 -triple i686-windows -fdeclspec -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MS
2-
// RUN: %clang_cc1 -std=c++11 -triple i686-windows-itanium -fdeclspec -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-IA
3-
// RUN: %clang_cc1 -std=c++11 -triple x86_64-scei-ps4 -fdeclspec -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-PS4
4-
// RUN: %clang_cc1 -std=c++11 -triple x86_64-sie-ps5 -fdeclspec -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-PS4
2+
// RUN: %clang_cc1 -std=c++11 -triple i686-windows-itanium -fdeclspec -emit-llvm %s -o - | FileCheck %s
3+
// RUN: %clang_cc1 -std=c++11 -triple x86_64-scei-ps4 -fdeclspec -emit-llvm %s -o - | FileCheck %s
4+
// RUN: %clang_cc1 -std=c++11 -triple x86_64-sie-ps5 -fdeclspec -emit-llvm %s -o - | FileCheck %s
55

66
template <typename>
77
struct s {};
@@ -15,8 +15,5 @@ template class __declspec(dllexport) t<char>;
1515
// CHECK-MS: dllexport {{.*}} @"??4?$t@D@@QAEAAV0@ABV0@@Z"
1616
// CHECK-MS: dllexport {{.*}} @"??4?$s@D@@QAEAAU0@ABU0@@Z"
1717

18-
// CHECK-IA: dllexport {{.*}} @_ZN1tIcEaSERKS0_
19-
// CHECK-IA: dllexport {{.*}} @_ZN1sIcEaSERKS0_
20-
21-
// CHECK-PS4-NOT: @_ZN1tIcEaSERKS0_
22-
// CHECK-PS4-NOT: @_ZN1sIcEaSERKS0_
18+
// CHECK: dllexport {{.*}} @_ZN1tIcEaSERKS0_
19+
// CHECK: dllexport {{.*}} @_ZN1sIcEaSERKS0_

clang/test/CodeGenCXX/windows-itanium-dllexport.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_cc1 -emit-llvm -triple i686-windows-itanium -fdeclspec %s -o - | FileCheck %s --check-prefixes=CHECK,WI
2-
// RUN: %clang_cc1 -emit-llvm -triple x86_64-scei-ps4 -fdeclspec %s -o - | FileCheck %s --check-prefixes=CHECK,PS4
3-
// RUN: %clang_cc1 -emit-llvm -triple x86_64-sie-ps5 -fdeclspec %s -o - | FileCheck %s --check-prefixes=CHECK,PS4
2+
// RUN: %clang_cc1 -emit-llvm -triple x86_64-scei-ps4 -fdeclspec %s -o - | FileCheck %s --check-prefixes=CHECK,PS
3+
// RUN: %clang_cc1 -emit-llvm -triple x86_64-sie-ps5 -fdeclspec %s -o - | FileCheck %s --check-prefixes=CHECK,PS
44

55
#define JOIN2(x, y) x##y
66
#define JOIN(x, y) JOIN2(x, y)
@@ -27,18 +27,14 @@ template class __declspec(dllexport) c<int>;
2727
extern template class c<char>;
2828
template class __declspec(dllexport) c<char>;
2929

30-
// WI: define {{.*}} dllexport {{.*}} @_ZN1cIcEaSERKS0_
31-
// WI: define {{.*}} dllexport {{.*}} @_ZN1cIcE1fEv
32-
// PS4-NOT: @_ZN1cIcEaSERKS0_
33-
// PS4: define weak_odr void @_ZN1cIcE1fEv
30+
// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcEaSERKS0_
31+
// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcE1fEv
3432

3533
c<double> g;
3634
template class __declspec(dllexport) c<double>;
3735

38-
// WI: define {{.*}} dllexport {{.*}} @_ZN1cIdEaSERKS0_
39-
// WI: define {{.*}} dllexport {{.*}} @_ZN1cIdE1fEv
40-
// PS4-NOT: @_ZN1cIdEaSERKS0_
41-
// PS4: define weak_odr void @_ZN1cIdE1fEv
36+
// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIdEaSERKS0_
37+
// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIdE1fEv
4238

4339
template <class T>
4440
struct outer {
@@ -59,4 +55,4 @@ USEMEMFUNC(outer<char>::inner, f)
5955

6056
// CHECK-DAG: declare dllimport {{.*}} @_ZN5outerIcE1fEv
6157
// WI-DAG: define {{.*}} @_ZN5outerIcE5inner1fEv
62-
// PS4-DAG: declare {{.*}} @_ZN5outerIcE5inner1fEv
58+
// PS-DAG: declare {{.*}} @_ZN5outerIcE5inner1fEv

0 commit comments

Comments
 (0)