Skip to content

Commit a42d4a4

Browse files
author
Sergey Kanaev
committed
Merge branch 'sycl' into no_instr_mdata-2
2 parents e43c0a3 + 86716c5 commit a42d4a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+711
-251
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,14 @@ class Attr {
566566
// attribute may be documented under multiple categories, more than one
567567
// Documentation entry may be listed.
568568
list<Documentation> Documentation;
569+
// The SYCL specification allows attributes on lambdas as a nonconforming
570+
// extension to C++. The attributes are written in the type position but will
571+
// be applied to the generated function declaration rather than type. Setting
572+
// this bit to 1 opts an attribute into this nonconforming extension. New
573+
// attributes should not set this bit unless the attribute is required by the
574+
// SYCL specification. This bit only applies to the [[]] spelling of an
575+
// attribute and has no effect on any other spellings.
576+
bit SupportsNonconformingLambdaSyntax = 0;
569577
}
570578

571579
/// A type attribute is not processed on a declaration or a statement.
@@ -1183,9 +1191,10 @@ def SYCLKernel : InheritableAttr {
11831191
def SYCLSimd : InheritableAttr {
11841192
let Spellings = [GNU<"sycl_explicit_simd">,
11851193
CXX11<"intel", "sycl_explicit_simd">];
1186-
let Subjects = SubjectList<[Function]>;
1194+
let Subjects = SubjectList<[Function, GlobalVar]>;
11871195
let LangOpts = [SYCLExplicitSIMD];
11881196
let Documentation = [SYCLSimdDocs];
1197+
let SupportsNonconformingLambdaSyntax = 1;
11891198
}
11901199

11911200
// Available in SYCL explicit SIMD extension. Binds a file scope private
@@ -1258,11 +1267,12 @@ def SYCLRequiresDecomposition : InheritableAttr {
12581267
}
12591268

12601269
def SYCLIntelKernelArgsRestrict : InheritableAttr {
1261-
let Spellings = [ CXX11<"intel", "kernel_args_restrict"> ];
1270+
let Spellings = [CXX11<"intel", "kernel_args_restrict">];
12621271
let Subjects = SubjectList<[Function], ErrorDiag>;
1263-
let LangOpts = [ SYCLIsDevice, SYCLIsHost ];
1264-
let Documentation = [ SYCLIntelKernelArgsRestrictDocs ];
1272+
let LangOpts = [SYCLIsDevice, SYCLIsHost];
1273+
let Documentation = [SYCLIntelKernelArgsRestrictDocs];
12651274
let SimpleHandler = 1;
1275+
let SupportsNonconformingLambdaSyntax = 1;
12661276
}
12671277

12681278
def SYCLIntelNumSimdWorkItems : InheritableAttr {
@@ -1272,13 +1282,15 @@ def SYCLIntelNumSimdWorkItems : InheritableAttr {
12721282
let LangOpts = [SYCLIsDevice, SYCLIsHost];
12731283
let Subjects = SubjectList<[Function], ErrorDiag>;
12741284
let Documentation = [SYCLIntelNumSimdWorkItemsAttrDocs];
1285+
let SupportsNonconformingLambdaSyntax = 1;
12751286
}
12761287

12771288
def SYCLIntelUseStallEnableClusters : InheritableAttr {
12781289
let Spellings = [CXX11<"intel","use_stall_enable_clusters">];
12791290
let LangOpts = [SYCLIsHost, SYCLIsDevice];
12801291
let Subjects = SubjectList<[Function], ErrorDiag>;
12811292
let Documentation = [SYCLIntelUseStallEnableClustersAttrDocs];
1293+
let SupportsNonconformingLambdaSyntax = 1;
12821294
}
12831295

12841296
def SYCLIntelSchedulerTargetFmaxMhz : InheritableAttr {
@@ -1288,6 +1300,7 @@ def SYCLIntelSchedulerTargetFmaxMhz : InheritableAttr {
12881300
let LangOpts = [SYCLIsDevice, SYCLIsHost];
12891301
let Subjects = SubjectList<[Function], ErrorDiag>;
12901302
let Documentation = [SYCLIntelSchedulerTargetFmaxMhzAttrDocs];
1303+
let SupportsNonconformingLambdaSyntax = 1;
12911304
}
12921305

12931306
def SYCLIntelMaxWorkGroupSize : InheritableAttr {
@@ -1313,6 +1326,7 @@ def SYCLIntelMaxWorkGroupSize : InheritableAttr {
13131326
}
13141327
}];
13151328
let Documentation = [SYCLIntelMaxWorkGroupSizeAttrDocs];
1329+
let SupportsNonconformingLambdaSyntax = 1;
13161330
}
13171331

13181332
def SYCLIntelMaxGlobalWorkDim : InheritableAttr {
@@ -1322,6 +1336,7 @@ def SYCLIntelMaxGlobalWorkDim : InheritableAttr {
13221336
let LangOpts = [SYCLIsDevice, SYCLIsHost];
13231337
let Subjects = SubjectList<[Function], ErrorDiag>;
13241338
let Documentation = [SYCLIntelMaxGlobalWorkDimAttrDocs];
1339+
let SupportsNonconformingLambdaSyntax = 1;
13251340
}
13261341

13271342
def SYCLIntelNoGlobalWorkOffset : InheritableAttr {
@@ -1331,6 +1346,7 @@ def SYCLIntelNoGlobalWorkOffset : InheritableAttr {
13311346
let LangOpts = [SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
13321347
let Subjects = SubjectList<[Function], ErrorDiag>;
13331348
let Documentation = [SYCLIntelNoGlobalWorkOffsetAttrDocs];
1349+
let SupportsNonconformingLambdaSyntax = 1;
13341350
}
13351351

13361352
def SYCLIntelLoopFuse : InheritableAttr {
@@ -1342,6 +1358,7 @@ def SYCLIntelLoopFuse : InheritableAttr {
13421358
let Accessors = [Accessor<"isIndependent",
13431359
[CXX11<"intel", "loop_fuse_independent">]>];
13441360
let Documentation = [SYCLIntelLoopFuseDocs];
1361+
let SupportsNonconformingLambdaSyntax = 1;
13451362
}
13461363

13471364
def C11NoReturn : InheritableAttr {
@@ -1404,6 +1421,7 @@ def IntelReqdSubGroupSize: InheritableAttr {
14041421
let Subjects = SubjectList<[Function], ErrorDiag>;
14051422
let Documentation = [IntelReqdSubGroupSizeDocs];
14061423
let LangOpts = [OpenCL, SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
1424+
let SupportsNonconformingLambdaSyntax = 1;
14071425
}
14081426

14091427
// This attribute is both a type attribute, and a declaration attribute (for
@@ -2808,6 +2826,7 @@ def ReqdWorkGroupSize : InheritableAttr {
28082826
}
28092827
}];
28102828
let Documentation = [ReqdWorkGroupSizeAttrDocs];
2829+
let SupportsNonconformingLambdaSyntax = 1;
28112830
}
28122831

28132832
def WorkGroupSizeHint : InheritableAttr {

clang/include/clang/Basic/AttrDocs.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,12 @@ def SYCLSimdDocs : Documentation {
360360
let Category = DocCatFunction;
361361
let Content = [{
362362
The ``__attribute__((sycl_explicit_simd))`` attribute is used by the device
363-
compiler front end to mark kernels and functions to be compiled and executed
364-
in the explicit SIMD mode. In this mode subgroup size is always 1 and
365-
explicit SIMD extensions - such as manual vectorization using wide vector
366-
data types and operations can be used. Compiler may decide to compile such
367-
functions using different optimization and code generation
368-
pipeline.
363+
compiler front end to mark ESIMD kernels and functions. In this mode,
364+
subgroup size is always equal to 1 and explicit SIMD extensions, such as
365+
manual vectorization using wide vector data types and operations can be used.
366+
The compiler may decide to compile such functions using different optimization
367+
and code generation pipeline. Also, this attribute is used to distinguish
368+
ESIMD private globals from regular SYCL global variables.
369369
}];
370370
}
371371

clang/include/clang/Basic/AttributeCommonInfo.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -153,26 +153,6 @@ class AttributeCommonInfo {
153153
return SyntaxUsed == AS_CXX11 || isAlignasAttribute();
154154
}
155155

156-
bool isAllowedOnLambdas() const {
157-
// FIXME: Eventually we want to do a list here populated via tablegen. But
158-
// we want C++ attributes to be permissible on Lambdas, and get propagated
159-
// to the call operator declaration.
160-
auto ParsedAttr = getParsedKind();
161-
if (ParsedAttr == AT_SYCLIntelKernelArgsRestrict ||
162-
(ParsedAttr == AT_ReqdWorkGroupSize && isCXX11Attribute()) ||
163-
(ParsedAttr == AT_IntelReqdSubGroupSize && isCXX11Attribute()) ||
164-
ParsedAttr == AT_SYCLIntelNumSimdWorkItems ||
165-
ParsedAttr == AT_SYCLIntelSchedulerTargetFmaxMhz ||
166-
ParsedAttr == AT_SYCLIntelMaxWorkGroupSize ||
167-
ParsedAttr == AT_SYCLIntelMaxGlobalWorkDim ||
168-
ParsedAttr == AT_SYCLIntelNoGlobalWorkOffset ||
169-
ParsedAttr == AT_SYCLIntelUseStallEnableClusters ||
170-
ParsedAttr == AT_SYCLIntelLoopFuse || ParsedAttr == AT_SYCLSimd)
171-
return true;
172-
173-
return false;
174-
}
175-
176156
bool isC2xAttribute() const { return SyntaxUsed == AS_C2x; }
177157

178158
bool isKeywordAttribute() const {

clang/include/clang/Driver/Options.td

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,10 +4295,6 @@ def fsycl : Flag<["-"], "fsycl">, Flags<[NoXarchOption, CoreOption]>, Group<sycl
42954295
HelpText<"Enables SYCL kernels compilation for device">;
42964296
def fno_sycl : Flag<["-"], "fno-sycl">, Flags<[NoXarchOption, CoreOption]>, Group<sycl_Group>,
42974297
HelpText<"Disables SYCL kernels compilation for device">;
4298-
def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_Group>, Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
4299-
HelpText<"SYCL language standard to compile for.">, Values<"2020,2017,121,1.2.1,sycl-1.2.1">,
4300-
NormalizedValues<["SYCL_2020", "SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>, NormalizedValuesScope<"LangOptions">,
4301-
MarshallingInfoString<LangOpts<"SYCLVersion">, "SYCL_None">, AutoNormalizeEnum;
43024298
defm sycl_esimd: BoolFOption<"sycl-explicit-simd",
43034299
LangOpts<"SYCLExplicitSIMD">, DefaultFalse,
43044300
PosFlag<SetTrue, [CC1Option], "Enable">, NegFlag<SetFalse, [], "Disable">,
@@ -5528,13 +5524,27 @@ def fsycl_int_header_EQ : Joined<["-"], "fsycl-int-header=">,
55285524
def fsycl_std_layout_kernel_params: Flag<["-"], "fsycl-std-layout-kernel-params">,
55295525
HelpText<"Enable standard layout requirement for SYCL kernel parameters.">,
55305526
MarshallingInfoFlag<LangOpts<"SYCLStdLayoutKernelParams">>;
5531-
defm sycl_allow_func_ptr: OptInFFlag<"sycl-allow-func-ptr", "Allow", "Disallow", " function pointers in SYCL device.", [CC1Option,CoreOption], LangOpts<"SYCLAllowFuncPtr">>;
5527+
defm sycl_allow_func_ptr: BoolFOption<"sycl-allow-func-ptr",
5528+
LangOpts<"SYCLAllowFuncPtr">, DefaultFalse,
5529+
PosFlag<SetTrue, [], "Allow">,
5530+
NegFlag<SetFalse, [], "Disallow">,
5531+
BothFlags<[CC1Option, CoreOption], " function pointers in SYCL device.">>;
55325532
def fenable_sycl_dae : Flag<["-"], "fenable-sycl-dae">,
55335533
HelpText<"Enable Dead Argument Elimination in SPIR kernels">,
55345534
MarshallingInfoFlag<LangOpts<"EnableDAEInSpirKernels">>;
55355535

55365536
} // let Flags = [CC1Option, NoDriverOption]
55375537

5538+
def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_Group>,
5539+
Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
5540+
HelpText<"SYCL language standard to compile for.">,
5541+
Values<"2020,2017,121,1.2.1,sycl-1.2.1">,
5542+
NormalizedValues<["SYCL_2020", "SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>,
5543+
NormalizedValuesScope<"LangOptions">,
5544+
MarshallingInfoString<LangOpts<"SYCLVersion">, "SYCL_None">,
5545+
AutoNormalizeEnum,
5546+
ShouldParseIf<!strconcat(fsycl_is_device.KeyPath, "||", fsycl_is_host.KeyPath)>;
5547+
55385548
defm cuda_approx_transcendentals : BoolFOption<"cuda-approx-transcendentals",
55395549
LangOpts<"CUDADeviceApproxTranscendentals">, DefaultFalse,
55405550
PosFlag<SetTrue, [CC1Option], "Use">, NegFlag<SetFalse, [], "Don't use">,

clang/include/clang/Sema/ParsedAttr.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ struct ParsedAttrInfo {
6060
unsigned IsKnownToGCC : 1;
6161
/// True if this attribute is supported by #pragma clang attribute.
6262
unsigned IsSupportedByPragmaAttribute : 1;
63+
/// True if this attribute supports a nonconforming behavior when applied to
64+
/// a lambda in the type position.
65+
unsigned SupportsNonconformingLambdaSyntax : 1;
6366
/// The syntaxes supported by this attribute and how they're spelled.
6467
struct Spelling {
6568
AttributeCommonInfo::Syntax Syntax;
@@ -590,6 +593,7 @@ class ParsedAttr final
590593
bool existsInTarget(const TargetInfo &Target) const;
591594
bool isKnownToGCC() const;
592595
bool isSupportedByPragmaAttribute() const;
596+
bool supportsNonconformingLambdaSyntax() const;
593597

594598
/// If the parsed attribute has a semantic equivalent, and it would
595599
/// have a semantic Spelling enumeration (due to having semantically-distinct

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13082,7 +13082,7 @@ class Sema final {
1308213082
/// Tells whether given variable is a SYCL explicit SIMD extension's "private
1308313083
/// global" variable - global variable in the private address space.
1308413084
bool isSYCLEsimdPrivateGlobal(VarDecl *VDecl) {
13085-
return getLangOpts().SYCLIsDevice && getLangOpts().SYCLExplicitSIMD &&
13085+
return getLangOpts().SYCLIsDevice && VDecl->hasAttr<SYCLSimdAttr>() &&
1308613086
VDecl->hasGlobalStorage() &&
1308713087
(VDecl->getType().getAddressSpace() == LangAS::opencl_private);
1308813088
}

clang/lib/CodeGen/CGCall.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4774,9 +4774,14 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
47744774
// If the argument doesn't match, perform a bitcast to coerce it. This
47754775
// can happen due to trivial type mismatches.
47764776
if (FirstIRArg < IRFuncTy->getNumParams() &&
4777-
V->getType() != IRFuncTy->getParamType(FirstIRArg))
4778-
V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
4779-
4777+
V->getType() != IRFuncTy->getParamType(FirstIRArg)) {
4778+
if (V->getType()->getPointerAddressSpace() !=
4779+
IRFuncTy->getParamType(FirstIRArg)->getPointerAddressSpace())
4780+
V = Builder.CreateAddrSpaceCast(V,
4781+
IRFuncTy->getParamType(FirstIRArg));
4782+
else
4783+
V = Builder.CreateBitCast(V, IRFuncTy->getParamType(FirstIRArg));
4784+
}
47804785
IRCallArgs[FirstIRArg] = V;
47814786
break;
47824787
}

clang/lib/Driver/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6193,7 +6193,8 @@ InputInfo Driver::BuildJobsForActionNoCache(
61936193
TI = types::TY_Tempfilelist;
61946194
} else if (EffectiveTriple.getSubArch() !=
61956195
llvm::Triple::SPIRSubArch_fpga) {
6196-
if (UI.DependentOffloadKind == Action::OFK_SYCL) {
6196+
if (UI.DependentOffloadKind == Action::OFK_SYCL &&
6197+
JA->getType() != types::TY_FPGA_AOCO) {
61976198
// Do not add the current info for device with FPGA device. The
61986199
// device side isn't used
61996200
continue;

clang/lib/Sema/ParsedAttr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ bool ParsedAttr::isSupportedByPragmaAttribute() const {
193193
return getInfo().IsSupportedByPragmaAttribute;
194194
}
195195

196+
bool ParsedAttr::supportsNonconformingLambdaSyntax() const {
197+
return getInfo().SupportsNonconformingLambdaSyntax && isCXX11Attribute();
198+
}
199+
196200
unsigned ParsedAttr::getSemanticSpelling() const {
197201
return getInfo().spellingIndexToSemanticSpelling(*this);
198202
}

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8859,7 +8859,7 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
88598859
// Ignore C++11 attributes on declarator chunks: they appertain to the type
88608860
// instead.
88618861
if (AL.isCXX11Attribute() && !IncludeCXX11Attributes &&
8862-
(!IsDeclLambdaCallOperator(D) || !AL.isAllowedOnLambdas()))
8862+
(!IsDeclLambdaCallOperator(D) || !AL.supportsNonconformingLambdaSyntax()))
88638863
return;
88648864

88658865
// Unknown attributes are automatically warned on. Target-specific attributes

clang/lib/Sema/SemaType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8123,7 +8123,8 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type,
81238123
default:
81248124
// A C++11 attribute on a declarator chunk must appertain to a type.
81258125
if (attr.isCXX11Attribute() && TAL == TAL_DeclChunk &&
8126-
(!state.isProcessingLambdaExpr() || !attr.isAllowedOnLambdas())) {
8126+
(!state.isProcessingLambdaExpr() ||
8127+
!attr.supportsNonconformingLambdaSyntax())) {
81278128
state.getSema().Diag(attr.getLoc(), diag::err_attribute_not_type_attr)
81288129
<< attr;
81298130
attr.setUsedAsTypeAttr();

clang/test/CodeGenSYCL/esimd-private-global.cpp

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

1111
// This test checks that FE allows globals with register_num attribute in ESIMD mode.
1212

13-
__attribute__((opencl_private)) __attribute__((register_num(17))) int vc;
13+
__attribute__((opencl_private)) __attribute__((sycl_explicit_simd)) __attribute__((register_num(17))) int vc;
1414
// CHECK: @vc = {{.+}} i32 0, align 4 #0
1515

1616
template <typename name, typename Func>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %clang_cc1 -sycl-std=2020 -fsycl-is-device -fsycl-allow-func-ptr -internal-isystem %S/Inputs -disable-llvm-passes -triple spir64-unknown-unknown-sycldevice -emit-llvm -o - %s | FileCheck %s
2+
3+
// Test that the type of function object invoked from the kernel has
4+
// the right address space.
5+
6+
#include "sycl.hpp"
7+
8+
using namespace cl::sycl;
9+
queue q;
10+
11+
// CHECK: define linkonce_odr spir_func i32 @{{.*}}invoke_function{{.*}}(i32 () addrspace(4)* %f)
12+
template <typename Callable>
13+
auto invoke_function(Callable &&f) {
14+
// CHECK: %f.addr = alloca i32 () addrspace(4)*, align 8
15+
// CHECK: %f.addr.ascast = addrspacecast i32 () addrspace(4)** %f.addr to i32 () addrspace(4)* addrspace(4)*
16+
// CHECK: store i32 () addrspace(4)* %f, i32 () addrspace(4)* addrspace(4)* %f.addr.ascast, align 8
17+
// CHECK: %0 = load i32 () addrspace(4)*, i32 () addrspace(4)* addrspace(4)* %f.addr.ascast, align 8
18+
// CHECK: %call = call spir_func addrspace(4) i32 %0()
19+
return f();
20+
}
21+
22+
// CHECK: define dso_local spir_func i32 @{{.*}}bar10{{.*}}()
23+
int bar10() { return 10; }
24+
25+
int main() {
26+
kernel_single_task<class KernelName>(
27+
[=]() {
28+
invoke_function(bar10);
29+
});
30+
return 0;
31+
}

clang/test/Driver/sycl-offload-static-lib.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,15 @@
150150
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -foffload-static-lib= -c %s 2>&1 \
151151
// RUN: | FileCheck %s -check-prefixes=FOFFLOAD_STATIC_LIB_NOVALUE
152152
// FOFFLOAD_STATIC_LIB_NOVALUE: warning: argument unused during compilation: '-foffload-static-lib='
153+
154+
/// Use of a static archive with various targets should compile and unbundle
155+
// RUN: touch %t.a
156+
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl %t.a -### 2>&1 \
157+
// RUN: | FileCheck %s -check-prefixes=STATIC_ARCHIVE_UNBUNDLE
158+
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_gen-unknown-unknown-sycldevice %t.a -### 2>&1 \
159+
// RUN: | FileCheck %s -check-prefixes=STATIC_ARCHIVE_UNBUNDLE
160+
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %t.a -### 2>&1 \
161+
// RUN: | FileCheck %s -check-prefixes=STATIC_ARCHIVE_UNBUNDLE
162+
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %t.a -### 2>&1 \
163+
// RUN: | FileCheck %s -check-prefixes=STATIC_ARCHIVE_UNBUNDLE
164+
// STATIC_ARCHIVE_UNBUNDLE: clang-offload-bundler{{.*}}

clang/test/Misc/pragma-attribute-supported-attributes-list.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
// CHECK-NEXT: SYCLIntelSchedulerTargetFmaxMhz (SubjectMatchRule_function)
163163
// CHECK-NEXT: SYCLIntelUseStallEnableClusters (SubjectMatchRule_function)
164164
// CHECK-NEXT: SYCLRegisterNum (SubjectMatchRule_variable_is_global)
165-
// CHECK-NEXT: SYCLSimd (SubjectMatchRule_function)
165+
// CHECK-NEXT: SYCLSimd (SubjectMatchRule_function, SubjectMatchRule_variable_is_global)
166166
// CHECK-NEXT: ScopedLockable (SubjectMatchRule_record)
167167
// CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
168168
// CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)

clang/test/SemaSYCL/esimd-private-global.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
// RUN: %clang_cc1 -fsycl-is-device -fsycl-explicit-simd -fsyntax-only -verify -pedantic %s
22

3+
// This test checks specifics of semantic analysis of ESIMD private globals
4+
5+
// No error expected. SYCL private globals are allowed to have initializers
6+
__attribute__((opencl_private)) int syclPrivGlob;
7+
__attribute__((opencl_private)) int syclPrivGlobInit = 10;
8+
9+
// expected-error@+1{{SYCL explicit SIMD does not permit private global variable to have an initializer}}
10+
__attribute__((opencl_private)) __attribute__((sycl_explicit_simd)) int esimdPrivGlobInit = 10;
11+
12+
// No error expected. ESIMD private globals without initializers are OK
13+
__attribute__((opencl_private)) __attribute__((sycl_explicit_simd)) int esimdPrivGlob;
14+
315
// no error expected
416
__attribute__((opencl_private)) __attribute__((register_num(17))) int privGlob;
517

@@ -9,9 +21,6 @@ __attribute__((opencl_private)) __attribute__((register_num())) int privGlob1;
921
// expected-error@+1{{'register_num' attribute takes one argument}}
1022
__attribute__((opencl_private)) __attribute__((register_num(10, 11))) int privGlob2;
1123

12-
// expected-error@+1{{SYCL explicit SIMD does not permit private global variable to have an initializer}}
13-
__attribute__((opencl_private)) int privGlob3 = 10;
14-
1524
void foo() {
1625
// expected-warning@+1{{'register_num' attribute only applies to global variables}}
1726
__attribute__((register_num(17))) int privLoc;

clang/test/SemaSYCL/sycl-esimd.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// RUN: %clang_cc1 -fsycl-is-device -fsycl-explicit-simd -fsyntax-only -Wno-sycl-2017-compat -verify %s
22

3+
// This test checks specifics of semantic analysis of ESIMD kernels.
4+
35
// ----------- Negative tests
46

5-
__attribute__((sycl_explicit_simd)) // expected-warning {{'sycl_explicit_simd' attribute only applies to functions}}
6-
int N;
7+
void foo(
8+
__attribute__((sycl_explicit_simd)) // expected-warning {{'sycl_explicit_simd' attribute only applies to functions and global variables}}
9+
int N);
710

811
__attribute__((sycl_explicit_simd(3))) // expected-error {{'sycl_explicit_simd' attribute takes no arguments}}
912
void

0 commit comments

Comments
 (0)