
This patch is part of the upstreaming effort for supporting SYCL language front end. It makes the following changes: 1. Adds sycl_external attribute for functions with external linkage, which is intended for use to implement the SYCL_EXTERNAL macro as specified by the SYCL 2020 specification 2. Adds checks to avoid emitting device code when sycl_external and sycl_kernel_entry_point attributes are not enabled 3. Fixes test failures caused by the above changes This patch is missing diagnostics for the following diagnostics listed in the SYCL 2020 specification's section 5.10.1, which will be addressed in a subsequent PR: Functions that are declared using SYCL_EXTERNAL have the following additional restrictions beyond those imposed on other device functions: 1. If the SYCL backend does not support the generic address space then the function cannot use raw pointers as parameter or return types. Explicit pointer classes must be used instead; 2. The function cannot call group::parallel_for_work_item; 3. The function cannot be called from a parallel_for_work_group scope. In addition to that, the subsequent PR will also implement diagnostics for inline functions including virtual functions defined as inline. --------- Co-authored-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --version 3
|
|
// RUN: %clang_cc1 -fsycl-is-device -disable-llvm-passes \
|
|
// RUN: -triple spir64 -fexceptions -emit-llvm -fno-ident %s -o - | FileCheck %s
|
|
|
|
int foo();
|
|
|
|
// CHECK-LABEL: define dso_local spir_func void @_Z3barv(
|
|
// CHECK-SAME: ) #[[ATTR2:[0-9]+]] {
|
|
// CHECK-NEXT: entry:
|
|
// CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
|
|
// CHECK-NEXT: [[A_ASCAST:%.*]] = addrspacecast ptr [[A]] to ptr addrspace(4)
|
|
// CHECK-NEXT: [[CALL:%.*]] = call spir_func noundef i32 @_Z3foov() #[[ATTR3:[0-9]+]]
|
|
// CHECK-NEXT: store i32 [[CALL]], ptr addrspace(4) [[A_ASCAST]], align 4
|
|
// CHECK-NEXT: ret void
|
|
//
|
|
void bar() {
|
|
int a = foo();
|
|
}
|
|
|
|
// CHECK-LABEL: define dso_local spir_func noundef i32 @_Z3foov(
|
|
// CHECK-SAME: ) #[[ATTR2]] {
|
|
// CHECK-NEXT: entry:
|
|
// CHECK-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
|
|
// CHECK-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr [[RETVAL]] to ptr addrspace(4)
|
|
// CHECK-NEXT: ret i32 1
|
|
//
|
|
int foo() {
|
|
return 1;
|
|
}
|
|
|
|
template <typename Name, typename Func>
|
|
[[clang::sycl_kernel_entry_point(Name)]] void kernel_single_task(const Func &kernelFunc) {
|
|
kernelFunc();
|
|
}
|
|
|
|
int main() {
|
|
kernel_single_task<class fake_kernel>([] { bar(); });
|
|
return 0;
|
|
}
|
|
//.
|
|
// CHECK: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
|
|
// CHECK: attributes #1 = { convergent nounwind }
|
|
//.
|
|
// CHECK: !{{[0-9]+}} = !{i32 1, !"wchar_size", i32 4}
|
|
//.
|