Skip to content

Commit e0d64f5

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 68d4042 + a0c0e33 commit e0d64f5

File tree

119 files changed

+838
-520
lines changed

Some content is hidden

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

119 files changed

+838
-520
lines changed

buildbot/testlist.cfg

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
:test_accessor
2+
:test_address_space
3+
:test_atomic
4+
:test_buffer
5+
:test_context
6+
:test_device
7+
:test_device_event
8+
:test_device_selector
9+
:test_error
10+
:test_event
11+
:test_exception_handling
12+
:test_group
13+
:test_h_item
14+
:test_handler
15+
:test_header
16+
:test_hierarchical
17+
:test_id
18+
:test_image
19+
:test_invoke
20+
:test_item
21+
:test_kernel
22+
:test_kernel_args
23+
:test_math_builtin_api
24+
:test_multi_ptr
25+
:test_nd_item
26+
:test_nd_range
27+
:test_opencl_interop
28+
:test_platform
29+
:test_pointers
30+
:test_program
31+
:test_queue
32+
:test_range
33+
:test_sampler
34+
:test_scalars
35+
:test_std_classes
36+
:test_stream
37+
:test_vector_alias
38+
:test_vector_api
39+
:test_vector_constructors
40+
:test_vector_load_store
41+
# Disable test to speedup testing until JIT is optimized
42+
#:test_vector_operators
43+
:test_vector_swizzle_assignment
44+
:test_vector_swizzles
45+
:test_vector_swizzles_opencl

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10490,8 +10490,9 @@ def err_sycl_virtual_types : Error<
1049010490
"No class with a vtable can be used in a SYCL kernel or any code included in the kernel">;
1049110491
def note_sycl_used_here : Note<"used here">;
1049210492
def note_sycl_recursive_function_declared_here: Note<"function implemented using recursion declared here">;
10493-
def err_sycl_non_trivially_copyable_type : Error<
10494-
"kernel parameter has non-trivially copyable class/struct type %0">;
10493+
def err_sycl_non_trivially_copy_ctor_dtor_type
10494+
: Error<"kernel parameter has non-trivially %select{copy "
10495+
"constructible|destructible}0 class/struct type %1">;
1049510496
def err_sycl_non_std_layout_type : Error<
1049610497
"kernel parameter has non-standard layout class/struct type %0">;
1049710498
def err_conflicting_sycl_kernel_attributes : Error<

clang/lib/CodeGen/SYCLLowerIR/LowerWGScope.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
// local "shadow" variable. Before each PFWI invocation leader WI stores its
4141
// private copy of the variable into the shadow (under "is leader" guard), then
4242
// all WIs (ouside of "is leader" guard) load the shadow value into their
43-
// private copies ("materialize" the private copy). This works becase these
43+
// private copies ("materialize" the private copy). This works because these
4444
// variables are uniform - i.e. have the same value in all WIs and are not
4545
// changed within PFWI. The only exceptions are captures of private_memory
46-
// isntances - see next.
46+
// instances - see next.
4747
// ** Kind 1:
4848
// Even though WG-scope locals are supposed to be uniform, there is one
4949
// exception - capture of local of kind 1. It is always captured by non-const
@@ -52,7 +52,7 @@
5252
// of kind 1 variable's alloca is stored within the PFWI lambda.
5353
// Materialization of the lambda object value writes result of alloca of the
5454
// leader WI's private variable into the private copy of the lambda object,
55-
// which is wrong. So for tese variables this pass adds a write of the private
55+
// which is wrong. So for these variables this pass adds a write of the private
5656
// variable's address into the private copy of the lambda object right after its
5757
// materialization:
5858
// if (is_leader())
@@ -120,9 +120,6 @@ class SYCLLowerWGScopeLegacyPass : public FunctionPass {
120120

121121
// run the LowerWGScope pass on the specified module
122122
bool runOnFunction(Function &F) override {
123-
if (skipFunction(F))
124-
return false;
125-
126123
FunctionAnalysisManager FAM;
127124
auto PA = Impl.run(F, FAM);
128125
return !PA.areAllPreserved();
@@ -479,7 +476,7 @@ static void materializeLocalsInWIScopeBlocksImpl(
479476
// Checks if there is a need to materialize value of given local in given work
480477
// item-scope basic block.
481478
static bool localMustBeMaterialized(const AllocaInst *L, const BasicBlock &BB) {
482-
// TODO this is overly convervative - see speculations below.
479+
// TODO this is overly conservative - see speculations below.
483480
return true;
484481
}
485482

@@ -745,9 +742,9 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F,
745742
for (; I->getOpcode() == Instruction::Alloca; I = I->getNextNode()) {
746743
auto *AllocaI = dyn_cast<AllocaInst>(I);
747744
// Allocas marked with "work_item_scope" are those originating from
748-
// cl::sycl::private_memory<T> variables, which must in private. No
749-
// shadows/materialization is needed for them because they can be updated
750-
// only within PFWIs
745+
// cl::sycl::private_memory<T> variables, which must be in private memory.
746+
// No shadows/materialization is needed for them because they can be
747+
// updated only within PFWIs
751748
if (!AllocaI->getMetadata(WI_SCOPE_MD))
752749
Allocas.insert(AllocaI);
753750
}
@@ -801,7 +798,7 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F,
801798
}
802799
// There can be allocas not corresponding to any variable declared in user
803800
// code but generated by the compiler - e.g. for non-trivially typed
804-
// parameters passed by by value. There can be WG scope stores into such
801+
// parameters passed by value. There can be WG scope stores into such
805802
// allocas, which need to be made visible to all WIs. This is done via
806803
// creating a "shadow" workgroup-shared variable and using it to propagate
807804
// the value of the alloca'ed variable to worker WIs from the leader.
@@ -815,7 +812,7 @@ PreservedAnalyses SYCLLowerWGScopePass::run(Function &F,
815812
// Now materialize the locals:
816813
materializeLocalsInWIScopeBlocks(Allocas, WIScopeBBs);
817814

818-
// Fixup captured addresses of private_memory isntances in current WI
815+
// Fixup captured addresses of private_memory instances in current WI
819816
for (auto *PFWICall : PFWICalls)
820817
fixupPrivateMemoryPFWILambdaCaptures(PFWICall);
821818

clang/lib/Sema/SemaDecl.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7057,6 +7057,13 @@ NamedDecl *Sema::ActOnVariableDeclarator(
70577057
NewVD->setTSCSpec(TSCS);
70587058
}
70597059

7060+
// Static variables declared inside SYCL device code must be const or
7061+
// constexpr
7062+
if (getLangOpts().SYCLIsDevice && SCSpec == DeclSpec::SCS_static &&
7063+
!R.isConstant(Context))
7064+
SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_sycl_restrict)
7065+
<< Sema::KernelNonConstStaticDataVariable;
7066+
70607067
switch (D.getDeclSpec().getConstexprSpecifier()) {
70617068
case CSK_unspecified:
70627069
break;

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,10 +1069,22 @@ static bool buildArgTys(ASTContext &Context, CXXRecordDecl *KernelObj,
10691069
continue;
10701070
}
10711071
}
1072-
if (!ArgTy.isTriviallyCopyableType(Context)) {
1072+
1073+
CXXRecordDecl *RD =
1074+
cast<CXXRecordDecl>(ArgTy->getAs<RecordType>()->getDecl());
1075+
if (!RD->hasTrivialCopyConstructor()) {
1076+
Context.getDiagnostics().Report(
1077+
Fld->getLocation(),
1078+
diag::err_sycl_non_trivially_copy_ctor_dtor_type)
1079+
<< 0 << ArgTy;
1080+
AllArgsAreValid = false;
1081+
continue;
1082+
}
1083+
if (!RD->hasTrivialDestructor()) {
10731084
Context.getDiagnostics().Report(
1074-
Fld->getLocation(), diag::err_sycl_non_trivially_copyable_type)
1075-
<< ArgTy;
1085+
Fld->getLocation(),
1086+
diag::err_sycl_non_trivially_copy_ctor_dtor_type)
1087+
<< 1 << ArgTy;
10761088
AllArgsAreValid = false;
10771089
continue;
10781090
}

clang/test/CodeGenSYCL/address-space-of-returns.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ const char *ret_char() {
1010
// CHECK: ret i8 addrspace(4)* addrspacecast (i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0) to i8 addrspace(4)*)
1111

1212
const char *ret_arr() {
13-
static char Arr[42];
13+
const static char Arr[36] = "Carrots, cabbage, radish, potatoes!";
1414
return Arr;
1515
}
16-
// CHECK: ret i8 addrspace(4)* getelementptr inbounds ([42 x i8], [42 x i8] addrspace(4)* addrspacecast ([42 x i8] addrspace(1)* @{{.*}}ret_arr{{.*}}Arr to [42 x i8] addrspace(4)*), i64 0, i64 0)
16+
17+
// CHECK: ret i8 addrspace(4)* getelementptr inbounds ([36 x i8], [36 x i8] addrspace(4)* addrspacecast ([36 x i8] addrspace(1)* @{{.*}}ret_arr{{.*}}Arr to [36 x i8] addrspace(4)*), i64 0, i64 0)
1718

1819
const char &ret_ref() {
19-
static char a = 'A';
20+
const static char a = 'A';
2021
return a;
2122
}
2223
// CHECK: ret i8 addrspace(4)* addrspacecast (i8 addrspace(1)* @{{.*}}ret_ref{{.*}} to i8 addrspace(4)*)

clang/test/CodeGenSYCL/address-space-swap.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
// RUN: %clang -fsycl-device-only -S -emit-llvm %s -o - | FileCheck %s
22
#include <algorithm>
33

4-
54
void test() {
6-
static int foo = 0x42;
7-
// CHECK: @[[FOO:[a-zA-Z0-9_]+]] = internal addrspace(1) global i32 66, align 4
5+
int foo = 0x42;
6+
// CHECK: %[[FOO:[a-zA-Z0-9_]+]] = alloca i32, align 4
87
int i = 43;
9-
// CHECK: %[[I:[a-zA-Z0-9_]+]] = alloca i32, align 4
8+
// CHECK: %[[I:[a-zA-Z0-9_]+]] = alloca i32, align 4
109

11-
int* p1 = &foo;
12-
int* p2 = &i;
13-
// CHECK: %[[P1:[a-zA-Z0-9_]+]] = alloca i32 addrspace(4)*, align 8
14-
// CHECK: %[[P2:[a-zA-Z0-9_]+]] = alloca i32 addrspace(4)*, align 8
15-
// CHECK: %[[P1GEN:[a-zA-Z0-9_]+]] = addrspacecast i32 addrspace(4)** %[[P1]] to i32 addrspace(4)* addrspace(4)*
16-
// CHECK: %[[P2GEN:[a-zA-Z0-9_]+]] = addrspacecast i32 addrspace(4)** %[[P2]] to i32 addrspace(4)* addrspace(4)*
10+
int *p1 = &foo;
11+
int *p2 = &i;
12+
// CHECK: %[[P1:[a-zA-Z0-9_]+]] = alloca i32 addrspace(4)*, align 8
13+
// CHECK: %[[P2:[a-zA-Z0-9_]+]] = alloca i32 addrspace(4)*, align 8
14+
// CHECK: %[[P1GEN:[a-zA-Z0-9_]+]] = addrspacecast i32 addrspace(4)** %[[P1]] to i32 addrspace(4)* addrspace(4)*
15+
// CHECK: %[[P2GEN:[a-zA-Z0-9_]+]] = addrspacecast i32 addrspace(4)** %[[P2]] to i32 addrspace(4)* addrspace(4)*
1716

1817
std::swap(p1, p2);
19-
// CHECK: call spir_func void @_ZSt4swap{{.*}}(i32 addrspace(4)* addrspace(4)* dereferenceable(8) %[[P1GEN]], i32 addrspace(4)* addrspace(4)* dereferenceable(8) %[[P2GEN]])
18+
// CHECK: call spir_func void @_ZSt4swap{{.*}}(i32 addrspace(4)* addrspace(4)* dereferenceable(8) %[[P1GEN]], i32 addrspace(4)* addrspace(4)* dereferenceable(8) %[[P2GEN]])
2019

2120
std::swap(foo, i);
22-
// CHECK: %[[ICAST:[a-zA-Z0-9_]+]] = addrspacecast i32* %[[I]] to i32 addrspace(4)*
23-
// CHECK: call spir_func void @_ZSt4swap{{.*}}(i32 addrspace(4)* dereferenceable(4) addrspacecast (i32 addrspace(1)* @[[FOO]] to i32 addrspace(4)*), i32 addrspace(4)* dereferenceable(4) %[[ICAST]])
21+
// CHECK: %[[FOOCAST:[a-zA-Z0-9_]+]] = addrspacecast i32* %[[FOO]] to i32 addrspace(4)*
22+
// CHECK: %[[ICAST:[a-zA-Z0-9_]+]] = addrspacecast i32* %[[I]] to i32 addrspace(4)*
23+
// CHECK: call spir_func void @_ZSt4swap{{.*}}(i32 addrspace(4)* dereferenceable(4) %[[FOOCAST]], i32 addrspace(4)* dereferenceable(4) %[[ICAST]])
2424
}
2525

26-
2726
template <typename name, typename Func>
2827
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
2928
kernelFunc();
3029
}
3130

32-
3331
int main() {
3432
kernel_single_task<class fake_kernel>([]() { test(); });
3533
return 0;

clang/test/CodeGenSYCL/intel-fpga-local.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -disable-llvm-passes -fsycl-is-device -emit-llvm %s -o - | FileCheck %s -check-prefixes CHECK-DEVICE,CHECK-BOTH
22
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s -check-prefixes CHECK-HOST,CHECK-BOTH
33

4+
// CHECK-BOTH: @_ZZ15attrs_on_staticvE15static_numbanks = internal{{.*}}constant i32 20, align 4
45
// CHECK-DEVICE: [[ANN_numbanks_4:@.str]] = {{.*}}{memory:DEFAULT}{sizeinfo:4}{numbanks:4}
6+
// CHECK-BOTH: @_ZZ15attrs_on_staticvE15static_annotate = internal{{.*}}constant i32 30, align 4
57
// CHECK-BOTH: [[ANN_annotate:@.str[.0-9]*]] = {{.*}}foobar
68
// CHECK-DEVICE: [[ANN_register:@.str.[0-9]*]] = {{.*}}{register:1}
79
// CHECK-DEVICE: [[ANN_memory_default:@.str.[0-9]*]] = {{.*}}{memory:DEFAULT}{sizeinfo:4}
@@ -25,24 +27,17 @@
2527

2628
// CHECK-BOTH: @llvm.global.annotations
2729
// CHECK-DEVICE-SAME: { i8* addrspacecast (i8 addrspace(1)* bitcast (i32 addrspace(1)* @_ZZ15attrs_on_staticvE15static_numbanks to i8 addrspace(1)*) to i8*)
28-
// CHECK-DEVICE-SAME: [[ANN_numbanks_4]]{{.*}}i32 38
30+
// CHECK-DEVICE-SAME: [[ANN_numbanks_4]]{{.*}} i32 39
2931
// CHECK-DEVICE-SAME: { i8* addrspacecast (i8 addrspace(1)* bitcast (i32 addrspace(1)* @_ZZ15attrs_on_staticvE15static_annotate to i8 addrspace(1)*) to i8*)
3032
// CHECK-HOST-SAME: { i8* bitcast (i32* @_ZZ15attrs_on_staticvE15static_annotate to i8*)
31-
// CHECK-BOTH-SAME: [[ANN_annotate]]{{.*}}i32 42
33+
// CHECK-BOTH-SAME: [[ANN_annotate]]{{.*}} i32 40
3234

3335
// CHECK-HOST-NOT: llvm.var.annotation
3436
// CHECK-HOST-NOT: llvm.ptr.annotation
3537

3638
void attrs_on_static() {
37-
int a = 42;
38-
static int static_numbanks [[intelfpga::numbanks(4)]];
39-
// CHECK-BOTH: load{{.*}}static_numbanks
40-
// CHECK-BOTH: store{{.*}}static_numbanks
41-
static_numbanks = static_numbanks + a;
42-
static int static_annotate [[clang::annotate("foobar")]];
43-
// CHECK-BOTH: load{{.*}}static_annotate
44-
// CHECK-BOTH: store{{.*}}static_annotate
45-
static_annotate = static_annotate + a;
39+
const static int static_numbanks [[intelfpga::numbanks(4)]] = 20;
40+
const static int static_annotate [[clang::annotate("foobar")]] = 30;
4641
}
4742

4843
void attrs_on_var() {

clang/test/SemaSYCL/non-trivially-copyable-kernel-param.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ struct B {
1111
B (const B& x) : i(x.i) {}
1212
};
1313

14+
struct C : A {
15+
const A C2;
16+
C() : A{0}, C2{2}{}
17+
};
18+
19+
struct D {
20+
int i;
21+
~D();
22+
};
23+
1424
template <typename Name, typename Func>
1525
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
1626
kernelFunc();
@@ -20,9 +30,14 @@ void test() {
2030
A IamGood;
2131
IamGood.i = 0;
2232
B IamBad(1);
33+
C IamAlsoGood;
34+
D IamAlsoBad{0};
2335
kernel_single_task<class kernel_capture_refs>([=] {
2436
int a = IamGood.i;
25-
// expected-error@+1 {{kernel parameter has non-trivially copyable class/struct type}}
37+
// expected-error@+1 {{kernel parameter has non-trivially copy constructible class/struct type}}
2638
int b = IamBad.i;
39+
int c = IamAlsoGood.i;
40+
// expected-error@+1 {{kernel parameter has non-trivially destructible class/struct type}}
41+
int d = IamAlsoBad.i;
2742
});
2843
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %clang_cc1 -verify -fsyntax-only -fsycl-is-device %s
2+
3+
void usage() {
4+
// expected-error@+1{{SYCL kernel cannot use a non-const static data variable}}
5+
static int s1;
6+
const static int cs = 0;
7+
constexpr static int ces = 0;
8+
}
9+
10+
template <typename Name, typename Func>
11+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
12+
// expected-error@+1{{SYCL kernel cannot use a non-const static data variable}}
13+
static int z;
14+
// expected-note-re@+2{{called by 'kernel_single_task<fake_kernel, (lambda at {{.*}})>}}
15+
// expected-note-re@+1{{called by 'kernel_single_task<fake_kernel, (lambda at {{.*}})>}}
16+
kernelFunc();
17+
}
18+
19+
int main() {
20+
static int s2;
21+
kernel_single_task<class fake_kernel>([]() {
22+
// expected-note@+1{{called by 'operator()'}}
23+
usage();
24+
// expected-error@+1{{SYCL kernel cannot use a non-const static data variable}}
25+
static int s3;
26+
});
27+
28+
return 0;
29+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; UNSUPPORTED: system-windows
2+
3+
; Check the return code
4+
; RUN: llvm-no-spir-kernel %s; \
5+
; RUN: if [ $? = 1 ]; then exit 0; else exit 1; fi
6+
7+
; expected failure
8+
define spir_kernel void @foo() {
9+
bb:
10+
ret void
11+
}
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
; RUN: not llvm-no-spir-kernel %s
1+
; RUN: not llvm-no-spir-kernel %s 2>&1 | FileCheck %s
22

3-
; expected failure
4-
define spir_kernel void @foo() {
3+
; expected no failures
4+
define void @foo() {
55
bb:
66
ret void
77
}
88

9-
9+
; expected failure
10+
; CHECK: error: Unexpected SPIR kernel occurrence:
11+
; CHECK-SAME: foo2
12+
define spir_kernel void @foo2() {
13+
bb:
14+
ret void
15+
}

llvm/test/tools/llvm-no-spir-kernel/has-spir-kernel2.ll

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
; RUN: echo garbage > garbage.ll
2+
; RUN: not llvm-no-spir-kernel garbage.ll

llvm/tools/llvm-no-spir-kernel/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set(LLVM_LINK_COMPONENTS
22
Core
3+
Demangle
34
IRReader
45
Support
56
)

0 commit comments

Comments
 (0)