[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / clang / test / CodeGenSYCL / function-attrs.cpp
blob83a77a617240a647f9658902c69049d926fdf0e7
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --version 3
2 // RUN: %clang_cc1 -fsycl-is-device -disable-llvm-passes \
3 // RUN: -triple spir64 -fexceptions -emit-llvm -fno-ident %s -o - | FileCheck %s
5 int foo();
7 // CHECK-LABEL: define dso_local spir_func void @_Z3barv(
8 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
9 // CHECK-NEXT: entry:
10 // CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
11 // CHECK-NEXT: [[A_ASCAST:%.*]] = addrspacecast ptr [[A]] to ptr addrspace(4)
12 // CHECK-NEXT: [[CALL:%.*]] = call spir_func noundef i32 @_Z3foov() #[[ATTR1:[0-9]+]]
13 // CHECK-NEXT: store i32 [[CALL]], ptr addrspace(4) [[A_ASCAST]], align 4
14 // CHECK-NEXT: ret void
16 void bar() {
17 int a = foo();
20 // CHECK-LABEL: define dso_local spir_func noundef i32 @_Z3foov(
21 // CHECK-SAME: ) #[[ATTR0]] {
22 // CHECK-NEXT: entry:
23 // CHECK-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
24 // CHECK-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr [[RETVAL]] to ptr addrspace(4)
25 // CHECK-NEXT: ret i32 1
27 int foo() {
28 return 1;
31 template <typename Name, typename Func>
32 __attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) {
33 kernelFunc();
36 // CHECK-LABEL: define dso_local noundef i32 @main(
37 // CHECK-SAME: ) #[[ATTR0]] {
38 // CHECK-NEXT: entry:
39 // CHECK-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
40 // CHECK-NEXT: [[REF_TMP:%.*]] = alloca [[CLASS_ANON:%.*]], align 1
41 // CHECK-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr [[RETVAL]] to ptr addrspace(4)
42 // CHECK-NEXT: [[REF_TMP_ASCAST:%.*]] = addrspacecast ptr [[REF_TMP]] to ptr addrspace(4)
43 // CHECK-NEXT: store i32 0, ptr addrspace(4) [[RETVAL_ASCAST]], align 4
44 // CHECK-NEXT: call spir_func void @_Z18kernel_single_taskIZ4mainE11fake_kernelZ4mainEUlvE_EvRKT0_(ptr addrspace(4) noundef align 1 dereferenceable(1) [[REF_TMP_ASCAST]]) #[[ATTR1]]
45 // CHECK-NEXT: ret i32 0
47 int main() {
48 kernel_single_task<class fake_kernel>([] { bar(); });
49 return 0;
51 //.
52 // CHECK: attributes #0 = { convergent mustprogress noinline norecurse nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
53 // CHECK: attributes #1 = { convergent nounwind }
54 //.
55 // CHECK: !0 = !{i32 1, !"wchar_size", i32 4}
56 //.