Skip to content

Commit b8615ff

Browse files
authored
[SYCL] Turning off the deprecated attribute propagation and Sycl2017Compat option specification (#14984)
As a continuation of [#14544](#14544) this PR turns off attribute propagation specified by sycl-1.2.1. It also removes rest of 2017/121 things like a definition of Sycl2017Compat which had been turned off in [#14239](#14239)
1 parent e16b0a4 commit b8615ff

File tree

6 files changed

+12
-82
lines changed

6 files changed

+12
-82
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,9 +1375,8 @@ def OpenMP : DiagGroup<"openmp", [
13751375
]>;
13761376

13771377
// SYCL warnings
1378-
def Sycl2017Compat : DiagGroup<"sycl-2017-compat">;
13791378
def Sycl2020Compat : DiagGroup<"sycl-2020-compat">;
1380-
def SyclStrict : DiagGroup<"sycl-strict", [ Sycl2017Compat, Sycl2020Compat]>;
1379+
def SyclStrict : DiagGroup<"sycl-strict", [ Sycl2020Compat]>;
13811380
def SyclTarget : DiagGroup<"sycl-target">;
13821381
def SyclFPGAMismatch : DiagGroup<"sycl-fpga-mismatch">;
13831382
def SyclAspectMismatch : DiagGroup<"sycl-aspect-mismatch">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12485,14 +12485,6 @@ def err_sycl_invalid_aspect_argument : Error<
1248512485
def warn_sycl_pass_by_value_deprecated
1248612486
: Warning<"passing kernel functions by value is deprecated in SYCL 2020">,
1248712487
InGroup<Sycl2020Compat>, ShowInSystemHeader;
12488-
def warn_sycl_pass_by_reference_future
12489-
: Warning<"passing of kernel functions by reference is a SYCL 2020 extension">,
12490-
InGroup<Sycl2017Compat>, ShowInSystemHeader;
12491-
def warn_sycl_implicit_decl
12492-
: Warning<"SYCL 1.2.1 specification requires an explicit forward "
12493-
"declaration for a kernel type name; your program may not "
12494-
"be portable">,
12495-
InGroup<SyclStrict>, ShowInSystemHeader, DefaultIgnore;
1249612488
def warn_sycl_potentially_invalid_as_cast : Warning<
1249712489
"explicit cast from %0 to %1 potentially leads to an invalid address space"
1249812490
" cast in the resulting code">, InGroup<SyclStrict>,
@@ -12528,9 +12520,6 @@ def err_sycl_mismatch_group_size
1252812520
def note_sycl_kernel_declared_here : Note<"kernel declared here">;
1252912521
def err_sycl_expected_finalize_method : Error<
1253012522
"expected a 'finalize' method for the 'stream' class">;
12531-
def ext_sycl_2020_attr_spelling : ExtWarn<
12532-
"use of attribute %0 is a SYCL 2020 extension">,
12533-
InGroup<Sycl2017Compat>;
1253412523
def err_sycl_esimd_not_supported_for_type : Error<
1253512524
"type %0 is not supported in ESIMD context">;
1253612525
def err_sycl_taking_address_of_wrong_function : Error<

clang/include/clang/Basic/LangOptions.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,13 @@ class LangOptionsBase {
146146

147147
enum SYCLMajorVersion {
148148
SYCL_None,
149-
SYCL_2017,
150149
SYCL_2020,
151150
// The "default" SYCL version to be used when none is specified on the
152151
// frontend command line.
153152
SYCL_Default = SYCL_2020
154153
};
155154

156155
enum class SYCLVersionList {
157-
sycl_1_2_1,
158156
undefined
159157
};
160158

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ void Sema::CheckDeprecatedSYCLAttributeSpelling(const ParsedAttr &A,
151151
return;
152152
}
153153

154-
// Diagnose SYCL 2017 spellings in later SYCL modes.
155-
if (LangOpts.getSYCLVersion() > LangOptions::SYCL_2017) {
154+
// Diagnose SYCL 2020 spellings in later SYCL modes.
155+
if (LangOpts.getSYCLVersion() >= LangOptions::SYCL_2020) {
156156
// All attributes in the cl vendor namespace are deprecated in favor of a
157157
// name in the sycl namespace as of SYCL 2020.
158158
if (A.hasScope() && A.getScopeName()->isStr("cl")) {
@@ -177,14 +177,6 @@ void Sema::CheckDeprecatedSYCLAttributeSpelling(const ParsedAttr &A,
177177
return;
178178
}
179179
}
180-
181-
// Diagnose SYCL 2020 spellings used in earlier SYCL modes as being an
182-
// extension.
183-
if (LangOpts.getSYCLVersion() == LangOptions::SYCL_2017 && A.hasScope() &&
184-
A.getScopeName()->isStr("sycl")) {
185-
Diag(A.getLoc(), diag::ext_sycl_2020_attr_spelling) << A;
186-
return;
187-
}
188180
}
189181

190182
/// Check if IdxExpr is a valid parameter index for a function or
@@ -4358,19 +4350,13 @@ static void handleSYCLIntelLoopFuseAttr(Sema &S, Decl *D, const ParsedAttr &A) {
43584350
}
43594351

43604352
static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL) {
4361-
// This attribute is deprecated without replacement in SYCL 2020 mode.
4353+
// Given attribute is deprecated without replacement in SYCL 2020 mode.
43624354
// Ignore the attribute in SYCL 2020.
4363-
if (S.LangOpts.getSYCLVersion() > LangOptions::SYCL_2017) {
4355+
if (S.LangOpts.getSYCLVersion() >= LangOptions::SYCL_2020) {
43644356
S.Diag(AL.getLoc(), diag::warn_attribute_deprecated_ignored) << AL;
43654357
return;
43664358
}
43674359

4368-
// If the attribute is used with the [[sycl::vec_type_hint]] spelling in SYCL
4369-
// 2017 mode, we want to warn about using the newer name in the older
4370-
// standard as a compatibility extension.
4371-
if (S.LangOpts.getSYCLVersion() == LangOptions::SYCL_2017 && AL.hasScope())
4372-
S.Diag(AL.getLoc(), diag::ext_sycl_2020_attr_spelling) << AL;
4373-
43744360
if (!AL.hasParsedType()) {
43754361
S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
43764362
return;

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,9 @@ static void collectSYCLAttributes(SemaSYCL &S, FunctionDecl *FD,
539539
if (!FD->hasAttrs())
540540
return;
541541

542-
// In SYCL 1.2.1 mode, the attributes are propagated from the function they
543-
// are applied to onto the kernel which calls the function.
544-
// In SYCL 2020 mode, the attributes are not propagated to the kernel.
545-
if (DirectlyCalled || S.getASTContext().getLangOpts().getSYCLVersion() <
546-
LangOptions::SYCL_2020) {
542+
// In SYCL 2020 mode, the attributes aren't propagated from the function they
543+
// are applied on to the kernel which calls the function.
544+
if (DirectlyCalled) {
547545
llvm::copy_if(FD->getAttrs(), std::back_inserter(Attrs), [](Attr *A) {
548546
// FIXME: Make this list self-adapt as new SYCL attributes are added.
549547
return isa<IntelReqdSubGroupSizeAttr, IntelNamedSubGroupSizeAttr,
@@ -553,14 +551,8 @@ static void collectSYCLAttributes(SemaSYCL &S, FunctionDecl *FD,
553551
SYCLIntelMaxWorkGroupSizeAttr, SYCLIntelMaxGlobalWorkDimAttr,
554552
SYCLIntelMinWorkGroupsPerComputeUnitAttr,
555553
SYCLIntelMaxWorkGroupsPerMultiprocessorAttr,
556-
SYCLIntelNoGlobalWorkOffsetAttr, SYCLSimdAttr>(A);
557-
});
558-
}
559-
560-
// Attributes that should not be propagated from device functions to a kernel.
561-
if (DirectlyCalled) {
562-
llvm::copy_if(FD->getAttrs(), std::back_inserter(Attrs), [](Attr *A) {
563-
return isa<SYCLIntelLoopFuseAttr, SYCLIntelMaxConcurrencyAttr,
554+
SYCLIntelNoGlobalWorkOffsetAttr, SYCLSimdAttr,
555+
SYCLIntelLoopFuseAttr, SYCLIntelMaxConcurrencyAttr,
564556
SYCLIntelDisableLoopPipeliningAttr,
565557
SYCLIntelInitiationIntervalAttr,
566558
SYCLIntelUseStallEnableClustersAttr, SYCLDeviceHasAttr,
@@ -4856,10 +4848,6 @@ class SYCLKernelNameTypeVisitor
48564848
scope */
48574849
0 << KernelNameType;
48584850
IsInvalid = true;
4859-
} else {
4860-
S.Diag(KernelInvocationFuncLoc, diag::warn_sycl_implicit_decl);
4861-
S.Diag(DeclNamed->getLocation(), diag::note_previous_decl)
4862-
<< DeclNamed->getName();
48634851
}
48644852
}
48654853
}
@@ -4930,13 +4918,9 @@ void SemaSYCL::CheckSYCLKernelCall(FunctionDecl *KernelFunc,
49304918

49314919
// check that calling kernel conforms to spec
49324920
QualType KernelParamTy = KernelFunc->getParamDecl(0)->getType();
4933-
if (KernelParamTy->isReferenceType()) {
4934-
// passing by reference, so emit warning if not using SYCL 2020
4935-
if (SemaRef.LangOpts.getSYCLVersion() < LangOptions::SYCL_2020)
4936-
Diag(KernelFunc->getLocation(), diag::warn_sycl_pass_by_reference_future);
4937-
} else {
4921+
if (not KernelParamTy->isReferenceType()) {
49384922
// passing by value. emit warning if using SYCL 2020 or greater
4939-
if (SemaRef.LangOpts.getSYCLVersion() > LangOptions::SYCL_2017)
4923+
if (SemaRef.LangOpts.getSYCLVersion() >= LangOptions::SYCL_2020)
49404924
Diag(KernelFunc->getLocation(), diag::warn_sycl_pass_by_value_deprecated);
49414925
}
49424926

clang/test/SemaSYCL/implicit_kernel_type.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,6 @@ int main() {
2929
h.single_task<InvalidKernelName1>([]() {});
3030
});
3131

32-
#if defined(WARN)
33-
// expected-warning@#KernelSingleTask {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
34-
#elif defined(ERROR)
35-
// expected-error@#KernelSingleTask {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
36-
#endif
37-
38-
q.submit([&](handler &h) {
39-
// expected-note@+2 {{fake_kernel declared here}}
40-
// expected-note@+1 {{in instantiation of function template specialization}}
41-
h.single_task<class fake_kernel>([]() { function(); });
42-
});
43-
44-
#if defined(WARN)
45-
// expected-warning@#KernelSingleTask {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
46-
#elif defined(ERROR)
47-
// expected-error@#KernelSingleTask {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
48-
#endif
49-
50-
q.submit([&](handler &h) {
51-
// expected-note@+2 {{fake_kernel2 declared here}}
52-
// expected-note@+1 {{in instantiation of function template specialization}}
53-
h.single_task<class fake_kernel2>([]() {
54-
auto l = [](auto f) { f(); };
55-
});
56-
});
57-
5832
q.submit([&](handler &h) {
5933
h.single_task<class myWrapper>([]() { function(); });
6034
});

0 commit comments

Comments
 (0)