1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --check-globals 2; RUN: opt < %s -S -passes=openmp-opt -openmp-opt-inline-device | FileCheck %s 3 4%struct.ident_t = type { i32, i32, i32, i32, ptr } 5%struct.KernelEnvironmentTy = type { %struct.ConfigurationEnvironmentTy, ptr, ptr } 6%struct.ConfigurationEnvironmentTy = type { i8, i8, i8, i32, i32, i32, i32, i32, i32 } 7@0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 8@1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, ptr @0 }, align 8 9@G = external global i8 10 11@kernel_environment = local_unnamed_addr constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy { i8 1, i8 0, i8 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0 }, ptr @1, ptr null } 12 13; Function Attrs: convergent norecurse nounwind 14;. 15; CHECK: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [23 x i8] c" 16; CHECK: @[[GLOB1:[0-9]+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, ptr @[[GLOB0]] }, align 8 17; CHECK: @G = external global i8 18; CHECK: @kernel_environment = local_unnamed_addr constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy { i8 0, i8 0, i8 3, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0 }, ptr @[[GLOB1]], ptr null } 19;. 20define weak ptx_kernel void @__omp_offloading_fd02_c0934fc2_foo_l4(ptr %dyn) #0 { 21; CHECK: Function Attrs: norecurse nounwind 22; CHECK-LABEL: @__omp_offloading_fd02_c0934fc2_foo_l4( 23; CHECK-NEXT: entry: 24; CHECK-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_target_init(ptr @kernel_environment, ptr [[DYN:%.*]]) 25; CHECK-NEXT: [[THREAD_ID_IN_BLOCK:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block() 26; CHECK-NEXT: [[THREAD_IS_MAIN:%.*]] = icmp ne i32 [[THREAD_ID_IN_BLOCK]], 0 27; CHECK-NEXT: br i1 [[THREAD_IS_MAIN]], label [[EXIT_THREADS:%.*]], label [[MAIN_THREAD_USER_CODE:%.*]] 28; CHECK: exit.threads: 29; CHECK-NEXT: ret void 30; CHECK: main.thread.user_code: 31; CHECK-NEXT: [[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP0]], -1 32; CHECK-NEXT: br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]] 33; CHECK: user_code.entry: 34; CHECK-NEXT: store i8 1, ptr @G, align 1 35; CHECK-NEXT: call void @__kmpc_target_deinit() 36; CHECK-NEXT: ret void 37; CHECK: worker.exit: 38; CHECK-NEXT: ret void 39; 40entry: 41 %0 = call i32 @__kmpc_target_init(ptr @kernel_environment, ptr %dyn) 42 %exec_user_code = icmp eq i32 %0, -1 43 br i1 %exec_user_code, label %user_code.entry, label %worker.exit 44 45user_code.entry: ; preds = %entry 46 ; Ensure we see a 0 here as the kernel doesn't have parallel regions and we want 47 ; generic execution. 48 ; TODO: This is not perfect. We should rather go for SPMD mode and tell the runtime 49 ; to only spawn a single thread. Further, we then should not guard any code. 50 %isSPMD = call i8 @__kmpc_is_spmd_exec_mode() 51 store i8 %isSPMD, ptr @G 52 call void @bar() #2 53 call void @__kmpc_target_deinit() 54 ret void 55 56worker.exit: ; preds = %entry 57 ret void 58} 59 60declare i8 @__kmpc_is_spmd_exec_mode() 61 62declare i32 @__kmpc_target_init(ptr, ptr) 63 64declare void @__kmpc_target_deinit() 65 66; Function Attrs: convergent nounwind 67define hidden void @bar() #1 { 68; CHECK: Function Attrs: alwaysinline convergent nounwind 69; CHECK-LABEL: @bar( 70; CHECK-NEXT: entry: 71; CHECK-NEXT: ret void 72; 73entry: 74 ret void 75} 76 77attributes #0 = { convergent norecurse nounwind "kernel" "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_70" "target-features"="+ptx32,+sm_70" } 78attributes #1 = { convergent nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_70" "target-features"="+ptx32,+sm_70" } 79attributes #2 = { convergent } 80 81!omp_offload.info = !{!0} 82!llvm.module.flags = !{!2, !3, !4, !5, !6} 83!llvm.ident = !{!7} 84 85!0 = !{i32 0, i32 64770, i32 -1064087614, !"foo", i32 4, i32 0} 86!2 = !{i32 1, !"wchar_size", i32 4} 87!3 = !{i32 7, !"openmp", i32 50} 88!4 = !{i32 7, !"openmp-device", i32 50} 89!5 = !{i32 7, !"PIC Level", i32 2} 90!6 = !{i32 7, !"frame-pointer", i32 2} 91!7 = !{!"clang version 14.0.0"} 92;. 93; CHECK: attributes #[[ATTR0:[0-9]+]] = { norecurse nounwind "frame-pointer"="all" "kernel" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_70" "target-features"="+ptx32,+sm_70" } 94; CHECK: attributes #[[ATTR1:[0-9]+]] = { alwaysinline convergent nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_70" "target-features"="+ptx32,+sm_70" } 95; CHECK: attributes #[[ATTR2:[0-9]+]] = { nounwind } 96;. 97; CHECK: [[META0:![0-9]+]] = !{i32 0, i32 64770, i32 -1064087614, !"foo", i32 4, i32 0} 98; CHECK: [[META1:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} 99; CHECK: [[META2:![0-9]+]] = !{i32 7, !"openmp", i32 50} 100; CHECK: [[META3:![0-9]+]] = !{i32 7, !"openmp-device", i32 50} 101; CHECK: [[META4:![0-9]+]] = !{i32 8, !"PIC Level", i32 2} 102; CHECK: [[META5:![0-9]+]] = !{i32 7, !"frame-pointer", i32 2} 103; CHECK: [[META6:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"} 104;. 105