Skip to content

Commit e020f69

Browse files
[SYCL] Ignore vec_type_hint attribute in SYCL 2020 (#10619)
According to the SYCL 2020 spec, [[sycl::vec_type_hint()]] attribute should accept arguments of the type sycl::vec type. The attribute should also be accepted with non conforming lambda syntax. The current implementation in SYCL corresponds to the openCL version of this argument (with an additional spelling for SYCL), i.e. the attribute accepts extended vector type, floating point types and integral type. An error diagnostic is thrown for sycl:vec type. Since the attribute is deprecated and is not handled by any SYCL backend, and will be removed in a future version of the spec, to be minimally conformant with SYCL 2020 spec, this PR just ignores the attribute instead of adding support for sycl::vec type. Support was also added for non conforming lambda syntax
1 parent 0c51f60 commit e020f69

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4031,6 +4031,7 @@ def VecTypeHint : InheritableAttr {
40314031
let Spellings = [GNU<"vec_type_hint">, CXX11<"sycl", "vec_type_hint">];
40324032
let Args = [TypeArgument<"TypeHint">];
40334033
let Subjects = SubjectList<[Function], ErrorDiag>;
4034+
let SupportsNonconformingLambdaSyntax = 1;
40344035
let Documentation = [Undocumented];
40354036
}
40364037

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11979,6 +11979,9 @@ def warn_ivdep_attribute_argument : Warning<
1197911979
def warn_attribute_spelling_deprecated : Warning<
1198011980
"attribute %0 is deprecated">,
1198111981
InGroup<DeprecatedAttributes>;
11982+
def warn_attribute_deprecated_ignored : Warning<
11983+
"attribute %0 is deprecated; attribute ignored">,
11984+
InGroup<DeprecatedAttributes>;
1198211985
def note_spelling_suggestion : Note<
1198311986
"did you mean to use %0 instead?">;
1198411987
def warn_attribute_requires_non_negative_integer_argument :

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4550,8 +4550,11 @@ static void handleSYCLIntelLoopFuseAttr(Sema &S, Decl *D, const ParsedAttr &A) {
45504550

45514551
static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL) {
45524552
// This attribute is deprecated without replacement in SYCL 2020 mode.
4553-
if (S.LangOpts.getSYCLVersion() > LangOptions::SYCL_2017)
4554-
S.Diag(AL.getLoc(), diag::warn_attribute_spelling_deprecated) << AL;
4553+
// Ignore the attribute in SYCL 2020.
4554+
if (S.LangOpts.getSYCLVersion() > LangOptions::SYCL_2017) {
4555+
S.Diag(AL.getLoc(), diag::warn_attribute_deprecated_ignored) << AL;
4556+
return;
4557+
}
45554558

45564559
// If the attribute is used with the [[sycl::vec_type_hint]] spelling in SYCL
45574560
// 2017 mode, we want to warn about using the newer name in the older
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -sycl-std=2020 -internal-isystem %S/Inputs -fsyntax-only -verify %s
2+
3+
// Test which verifies [[sycl::vec_type_hint()]] is accepted
4+
// with non-conforming lambda syntax.
5+
6+
// NOTE: This attribute is not supported in the SYCL backends.
7+
// To be minimally conformant with SYCL2020, attribute is
8+
// accepted by the Clang FE with a warning. No additional
9+
// semantic handling or IR generation is done for this
10+
// attribute.
11+
12+
#include "sycl.hpp"
13+
14+
struct test {};
15+
16+
using namespace sycl;
17+
queue q;
18+
19+
void bar() {
20+
q.submit([&](handler &h) {
21+
h.single_task<class kernelname>(
22+
// expected-warning@+1 {{attribute 'vec_type_hint' is deprecated; attribute ignored}}
23+
[]() [[sycl::vec_type_hint(test)]] {});
24+
});
25+
}
26+

clang/test/SemaSYCL/vec-type-hint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
// __attribute__((vec_type_hint)) is deprecated without replacement in SYCL
99
// 2020 mode, but is allowed in SYCL 2017 and OpenCL modes.
10-
KERNEL __attribute__((vec_type_hint(int))) void foo() {} // sycl-2020-warning {{attribute 'vec_type_hint' is deprecated}}
10+
KERNEL __attribute__((vec_type_hint(int))) void foo() {} // sycl-2020-warning {{attribute 'vec_type_hint' is deprecated; attribute ignored}}

0 commit comments

Comments
 (0)