1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes 2; RUN: opt < %s -S -passes=openmp-opt -openmp-opt-inline-device | FileCheck %s 3 4%struct.ident_t = type { i32, i32, i32, i32, i8* } 5@0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 6@1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @0, i32 0, i32 0) }, align 8 7@__omp_offloading_fd02_c0934fc2_foo_l4_exec_mode = weak constant i8 1 8@llvm.compiler.used = appending global [1 x i8*] [i8* @__omp_offloading_fd02_c0934fc2_foo_l4_exec_mode], section "llvm.metadata" 9@G = external global i8 10 11; Function Attrs: convergent norecurse nounwind 12define weak void @__omp_offloading_fd02_c0934fc2_foo_l4() #0 { 13; CHECK: Function Attrs: convergent norecurse nounwind 14; CHECK-LABEL: @__omp_offloading_fd02_c0934fc2_foo_l4( 15; CHECK-NEXT: entry: 16; CHECK-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* @[[GLOB1:[0-9]+]], i8 1, i1 false, i1 true) 17; CHECK-NEXT: [[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP0]], -1 18; CHECK-NEXT: br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]] 19; CHECK: user_code.entry: 20; CHECK-NEXT: store i8 0, i8* @G, align 1 21; CHECK-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* @[[GLOB1]], i8 1, i1 true) 22; CHECK-NEXT: ret void 23; CHECK: worker.exit: 24; CHECK-NEXT: ret void 25; 26entry: 27 %0 = call i32 @__kmpc_target_init(%struct.ident_t* @1, i8 1, i1 true, i1 true) 28 %exec_user_code = icmp eq i32 %0, -1 29 br i1 %exec_user_code, label %user_code.entry, label %worker.exit 30 31user_code.entry: ; preds = %entry 32 ; Ensure we see a 0 here as the kernel doesn't have parallel regions and we want 33 ; generic execution. 34 ; TODO: This is not perfect. We should rather go for SPMD mode and tell the runtime 35 ; to only spawn a single thread. Further, we then should not guard any code. 36 %isSPMD = call i8 @__kmpc_is_spmd_exec_mode() 37 store i8 %isSPMD, i8* @G 38 call void @bar() #2 39 call void @__kmpc_target_deinit(%struct.ident_t* @1, i8 1, i1 true) 40 ret void 41 42worker.exit: ; preds = %entry 43 ret void 44} 45 46declare i8 @__kmpc_is_spmd_exec_mode() 47 48declare i32 @__kmpc_target_init(%struct.ident_t*, i8, i1, i1) 49 50declare void @__kmpc_target_deinit(%struct.ident_t*, i8, i1) 51 52; Function Attrs: convergent nounwind 53define hidden void @bar() #1 { 54; CHECK: Function Attrs: alwaysinline convergent nounwind 55; CHECK-LABEL: @bar( 56; CHECK-NEXT: entry: 57; CHECK-NEXT: ret void 58; 59entry: 60 ret void 61} 62 63attributes #0 = { convergent norecurse 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" } 64attributes #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" } 65attributes #2 = { convergent } 66 67!omp_offload.info = !{!0} 68!nvvm.annotations = !{!1} 69!llvm.module.flags = !{!2, !3, !4, !5, !6} 70!llvm.ident = !{!7} 71 72!0 = !{i32 0, i32 64770, i32 -1064087614, !"foo", i32 4, i32 0} 73!1 = !{void ()* @__omp_offloading_fd02_c0934fc2_foo_l4, !"kernel", i32 1} 74!2 = !{i32 1, !"wchar_size", i32 4} 75!3 = !{i32 7, !"openmp", i32 50} 76!4 = !{i32 7, !"openmp-device", i32 50} 77!5 = !{i32 7, !"PIC Level", i32 2} 78!6 = !{i32 7, !"frame-pointer", i32 2} 79!7 = !{!"clang version 14.0.0"} 80