1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals 2; RUN: opt -S -passes=openmp-opt < %s | FileCheck %s 3; RUN: opt -S -passes=openmp-opt -openmp-opt-disable-spmdization < %s | FileCheck %s --check-prefix=CHECK-DISABLED 4; 5; [[omp::assume("ompx_spmd_amenable")]] void pure(void) __attribute__((pure)); 6; [[omp::assume("omp_no_openmp","ompx_spmd_amenable")]] int no_openmp(int *); 7; 8; void sequential_loop(int *x, int N) { 9; #pragma omp target teams 10; { 11; x[0] = 0; 12; x[1] = 1; 13; x[N] = N; 14; for (int i = 2; i < N - 1; ++i) 15; x[i] = i - 1; 16; #pragma omp parallel 17; {} 18; int r1 = no_openmp(x); 19; x[r1] = r1; 20; int r2 = no_openmp(x); 21; x[r2] = r2; 22; int r3 = no_openmp(x); 23; x[r3] = r3; 24; 25; no_openmp(x); 26; pure(); 27; no_openmp(x); 28; pure(); 29; no_openmp(x); 30; pure(); 31; } 32; } 33; 34target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64" 35target triple = "nvptx64" 36 37%struct.ident_t = type { i32, i32, i32, i32, ptr } 38%struct.ConfigurationEnvironmentTy = type { i8, i8, i8, i32, i32, i32, i32, i32, i32 } 39%struct.KernelEnvironmentTy = type { %struct.ConfigurationEnvironmentTy, ptr, ptr } 40 41@0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 42@1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, ptr @0 }, align 8 43@LocGlob = private unnamed_addr addrspace(5) global i32 43 44@__omp_offloading_2a_fbfa7a_sequential_loop_l6_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 } 45 46 47; Function Attrs: convergent norecurse nounwind 48;. 49; CHECK: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [23 x i8] c" 50; CHECK: @[[GLOB1:[0-9]+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, ptr @[[GLOB0]] }, align 8 51; CHECK: @LocGlob = private unnamed_addr addrspace(5) global i32 43 52; CHECK: @__omp_offloading_2a_fbfa7a_sequential_loop_l6_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 } 53; CHECK: @[[GLOB2:[0-9]+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @[[GLOB0]] }, align 8 54;. 55; CHECK-DISABLED: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [23 x i8] c" 56; CHECK-DISABLED: @[[GLOB1:[0-9]+]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, ptr @[[GLOB0]] }, align 8 57; CHECK-DISABLED: @LocGlob = private unnamed_addr addrspace(5) global i32 43 58; CHECK-DISABLED: @__omp_offloading_2a_fbfa7a_sequential_loop_l6_kernel_environment = local_unnamed_addr constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy { i8 0, i8 0, i8 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0 }, ptr @[[GLOB1]], ptr null } 59; CHECK-DISABLED: @__omp_outlined__1_wrapper.ID = private constant i8 undef 60;. 61define weak ptx_kernel void @__omp_offloading_2a_fbfa7a_sequential_loop_l6(ptr %dyn, ptr %x, i64 %N) #0 { 62; CHECK-LABEL: define {{[^@]+}}@__omp_offloading_2a_fbfa7a_sequential_loop_l6 63; CHECK-SAME: (ptr [[DYN:%.*]], ptr [[X:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] { 64; CHECK-NEXT: entry: 65; CHECK-NEXT: [[HEAP2STACK_H2S:%.*]] = alloca i8, i64 8, align 8 66; CHECK-NEXT: [[LOC:%.*]] = alloca ptr, align 8 67; CHECK-NEXT: [[AL32:%.*]] = alloca i32, align 4 68; CHECK-NEXT: [[N_ADDR_SROA_0_0_EXTRACT_TRUNC:%.*]] = trunc i64 [[N]] to i32 69; CHECK-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_target_init(ptr nonnull @__omp_offloading_2a_fbfa7a_sequential_loop_l6_kernel_environment, ptr [[DYN]]) #[[ATTR6:[0-9]+]] 70; CHECK-NEXT: [[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP0]], -1 71; CHECK-NEXT: br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]] 72; CHECK: user_code.entry: 73; CHECK-NEXT: [[C:%.*]] = icmp eq i64 [[N]], 42 74; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[C]], ptr [[AL32]], ptr addrspacecast (ptr addrspace(5) @LocGlob to ptr) 75; CHECK-NEXT: store ptr [[SELECT]], ptr [[LOC]], align 8 76; CHECK-NEXT: [[TMP1:%.*]] = call i32 @__kmpc_global_thread_num(ptr nonnull @[[GLOB1]]) #[[ATTR6]] 77; CHECK-NEXT: [[ARRAYIDX1_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 1 78; CHECK-NEXT: [[SEXT:%.*]] = shl i64 [[N]], 32 79; CHECK-NEXT: [[IDXPROM_I:%.*]] = ashr exact i64 [[SEXT]], 32 80; CHECK-NEXT: [[ARRAYIDX2_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 [[IDXPROM_I]] 81; CHECK-NEXT: br label [[REGION_CHECK_TID:%.*]] 82; CHECK: region.check.tid: 83; CHECK-NEXT: [[TMP2:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block() 84; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP2]], 0 85; CHECK-NEXT: br i1 [[TMP3]], label [[REGION_GUARDED:%.*]], label [[REGION_BARRIER:%.*]] 86; CHECK: region.guarded: 87; CHECK-NEXT: store i32 0, ptr [[X]], align 4, !noalias [[META7:![0-9]+]] 88; CHECK-NEXT: store i32 1, ptr [[ARRAYIDX1_I]], align 4, !noalias [[META7]] 89; CHECK-NEXT: store i32 [[N_ADDR_SROA_0_0_EXTRACT_TRUNC]], ptr [[ARRAYIDX2_I]], align 4, !noalias [[META7]] 90; CHECK-NEXT: br label [[REGION_GUARDED_END:%.*]] 91; CHECK: region.guarded.end: 92; CHECK-NEXT: br label [[REGION_BARRIER]] 93; CHECK: region.barrier: 94; CHECK-NEXT: call void @__kmpc_barrier_simple_spmd(ptr @[[GLOB2]], i32 [[TMP2]]) 95; CHECK-NEXT: br label [[REGION_EXIT:%.*]] 96; CHECK: region.exit: 97; CHECK-NEXT: call void @usei8ptr(ptr captures(none) [[HEAP2STACK_H2S]]) #[[ATTR9:[0-9]+]] 98; CHECK-NEXT: br label [[FOR_COND_I:%.*]] 99; CHECK: for.cond.i: 100; CHECK-NEXT: [[I_0_I:%.*]] = phi i32 [ 2, [[REGION_EXIT]] ], [ [[INC_I:%.*]], [[REGION_EXIT3:%.*]] ] 101; CHECK-NEXT: [[SUB_I:%.*]] = add nsw i32 [[N_ADDR_SROA_0_0_EXTRACT_TRUNC]], -1 102; CHECK-NEXT: [[CMP_I:%.*]] = icmp slt i32 [[I_0_I]], [[SUB_I]] 103; CHECK-NEXT: br i1 [[CMP_I]], label [[FOR_BODY_I:%.*]], label [[__OMP_OUTLINED___EXIT:%.*]] 104; CHECK: for.body.i: 105; CHECK-NEXT: [[SUB3_I:%.*]] = add nsw i32 [[I_0_I]], -1 106; CHECK-NEXT: [[IDXPROM4_I:%.*]] = zext i32 [[I_0_I]] to i64 107; CHECK-NEXT: [[ARRAYIDX5_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 [[IDXPROM4_I]] 108; CHECK-NEXT: br label [[REGION_CHECK_TID5:%.*]] 109; CHECK: region.check.tid5: 110; CHECK-NEXT: [[TMP4:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block() 111; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[TMP4]], 0 112; CHECK-NEXT: br i1 [[TMP5]], label [[REGION_GUARDED4:%.*]], label [[REGION_BARRIER2:%.*]] 113; CHECK: region.guarded4: 114; CHECK-NEXT: store i32 [[SUB3_I]], ptr [[ARRAYIDX5_I]], align 4, !noalias [[META7]] 115; CHECK-NEXT: br label [[REGION_GUARDED_END1:%.*]] 116; CHECK: region.guarded.end1: 117; CHECK-NEXT: br label [[REGION_BARRIER2]] 118; CHECK: region.barrier2: 119; CHECK-NEXT: call void @__kmpc_barrier_simple_spmd(ptr @[[GLOB2]], i32 [[TMP4]]) 120; CHECK-NEXT: br label [[REGION_EXIT3]] 121; CHECK: region.exit3: 122; CHECK-NEXT: [[INC_I]] = add nuw nsw i32 [[I_0_I]], 1 123; CHECK-NEXT: br label [[FOR_COND_I]], !llvm.loop [[LOOP10:![0-9]+]] 124; CHECK: __omp_outlined__.exit: 125; CHECK-NEXT: call void @__kmpc_parallel_51(ptr null, i32 0, i32 1, i32 -1, i32 -1, ptr @__omp_outlined__1, ptr @__omp_outlined__1_wrapper, ptr null, i64 0) 126; CHECK-NEXT: [[CALL_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10:[0-9]+]], !noalias [[META7]] 127; CHECK-NEXT: [[IDXPROM6_I:%.*]] = sext i32 [[CALL_I]] to i64 128; CHECK-NEXT: [[ARRAYIDX7_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 [[IDXPROM6_I]] 129; CHECK-NEXT: br label [[REGION_CHECK_TID10:%.*]] 130; CHECK: region.check.tid10: 131; CHECK-NEXT: [[TMP6:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block() 132; CHECK-NEXT: [[TMP7:%.*]] = icmp eq i32 [[TMP6]], 0 133; CHECK-NEXT: br i1 [[TMP7]], label [[REGION_GUARDED9:%.*]], label [[REGION_BARRIER7:%.*]] 134; CHECK: region.guarded9: 135; CHECK-NEXT: store i32 [[CALL_I]], ptr [[ARRAYIDX7_I]], align 4, !noalias [[META7]] 136; CHECK-NEXT: br label [[REGION_GUARDED_END6:%.*]] 137; CHECK: region.guarded.end6: 138; CHECK-NEXT: br label [[REGION_BARRIER7]] 139; CHECK: region.barrier7: 140; CHECK-NEXT: call void @__kmpc_barrier_simple_spmd(ptr @[[GLOB2]], i32 [[TMP6]]) 141; CHECK-NEXT: br label [[REGION_EXIT8:%.*]] 142; CHECK: region.exit8: 143; CHECK-NEXT: [[CALL8_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10]], !noalias [[META7]] 144; CHECK-NEXT: [[IDXPROM9_I:%.*]] = sext i32 [[CALL8_I]] to i64 145; CHECK-NEXT: [[ARRAYIDX10_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 [[IDXPROM9_I]] 146; CHECK-NEXT: br label [[REGION_CHECK_TID15:%.*]] 147; CHECK: region.check.tid15: 148; CHECK-NEXT: [[TMP8:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block() 149; CHECK-NEXT: [[TMP9:%.*]] = icmp eq i32 [[TMP8]], 0 150; CHECK-NEXT: br i1 [[TMP9]], label [[REGION_GUARDED14:%.*]], label [[REGION_BARRIER12:%.*]] 151; CHECK: region.guarded14: 152; CHECK-NEXT: store i32 [[CALL8_I]], ptr [[ARRAYIDX10_I]], align 4, !noalias [[META7]] 153; CHECK-NEXT: br label [[REGION_GUARDED_END11:%.*]] 154; CHECK: region.guarded.end11: 155; CHECK-NEXT: br label [[REGION_BARRIER12]] 156; CHECK: region.barrier12: 157; CHECK-NEXT: call void @__kmpc_barrier_simple_spmd(ptr @[[GLOB2]], i32 [[TMP8]]) 158; CHECK-NEXT: br label [[REGION_EXIT13:%.*]] 159; CHECK: region.exit13: 160; CHECK-NEXT: [[CALL11_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10]], !noalias [[META7]] 161; CHECK-NEXT: [[IDXPROM12_I:%.*]] = sext i32 [[CALL11_I]] to i64 162; CHECK-NEXT: [[ARRAYIDX13_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 [[IDXPROM12_I]] 163; CHECK-NEXT: br label [[REGION_CHECK_TID20:%.*]] 164; CHECK: region.check.tid20: 165; CHECK-NEXT: [[TMP10:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block() 166; CHECK-NEXT: [[TMP11:%.*]] = icmp eq i32 [[TMP10]], 0 167; CHECK-NEXT: br i1 [[TMP11]], label [[REGION_GUARDED19:%.*]], label [[REGION_BARRIER17:%.*]] 168; CHECK: region.guarded19: 169; CHECK-NEXT: store i32 [[CALL11_I]], ptr [[ARRAYIDX13_I]], align 4, !noalias [[META7]] 170; CHECK-NEXT: br label [[REGION_GUARDED_END16:%.*]] 171; CHECK: region.guarded.end16: 172; CHECK-NEXT: br label [[REGION_BARRIER17]] 173; CHECK: region.barrier17: 174; CHECK-NEXT: call void @__kmpc_barrier_simple_spmd(ptr @[[GLOB2]], i32 [[TMP10]]) 175; CHECK-NEXT: br label [[REGION_EXIT18:%.*]] 176; CHECK: region.exit18: 177; CHECK-NEXT: [[CALL14_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10]], !noalias [[META7]] 178; CHECK-NEXT: [[CALL15_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10]], !noalias [[META7]] 179; CHECK-NEXT: [[CALL16_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10]], !noalias [[META7]] 180; CHECK-NEXT: call void @__kmpc_target_deinit() #[[ATTR6]] 181; CHECK-NEXT: ret void 182; CHECK: worker.exit: 183; CHECK-NEXT: ret void 184; 185; CHECK-DISABLED-LABEL: define {{[^@]+}}@__omp_offloading_2a_fbfa7a_sequential_loop_l6 186; CHECK-DISABLED-SAME: (ptr [[DYN:%.*]], ptr [[X:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] { 187; CHECK-DISABLED-NEXT: entry: 188; CHECK-DISABLED-NEXT: [[HEAP2STACK_H2S:%.*]] = alloca i8, i64 8, align 8 189; CHECK-DISABLED-NEXT: [[WORKER_WORK_FN_ADDR:%.*]] = alloca ptr, align 8 190; CHECK-DISABLED-NEXT: [[LOC:%.*]] = alloca ptr, align 8 191; CHECK-DISABLED-NEXT: [[AL32:%.*]] = alloca i32, align 4 192; CHECK-DISABLED-NEXT: [[N_ADDR_SROA_0_0_EXTRACT_TRUNC:%.*]] = trunc i64 [[N]] to i32 193; CHECK-DISABLED-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_target_init(ptr nonnull @__omp_offloading_2a_fbfa7a_sequential_loop_l6_kernel_environment, ptr [[DYN]]) #[[ATTR6:[0-9]+]] 194; CHECK-DISABLED-NEXT: [[THREAD_IS_WORKER:%.*]] = icmp ne i32 [[TMP0]], -1 195; CHECK-DISABLED-NEXT: br i1 [[THREAD_IS_WORKER]], label [[IS_WORKER_CHECK:%.*]], label [[THREAD_USER_CODE_CHECK:%.*]] 196; CHECK-DISABLED: is_worker_check: 197; CHECK-DISABLED-NEXT: [[BLOCK_HW_SIZE:%.*]] = call i32 @__kmpc_get_hardware_num_threads_in_block() 198; CHECK-DISABLED-NEXT: [[WARP_SIZE:%.*]] = call i32 @__kmpc_get_warp_size() 199; CHECK-DISABLED-NEXT: [[BLOCK_SIZE:%.*]] = sub i32 [[BLOCK_HW_SIZE]], [[WARP_SIZE]] 200; CHECK-DISABLED-NEXT: [[THREAD_IS_MAIN_OR_WORKER:%.*]] = icmp slt i32 [[TMP0]], [[BLOCK_SIZE]] 201; CHECK-DISABLED-NEXT: br i1 [[THREAD_IS_MAIN_OR_WORKER]], label [[WORKER_STATE_MACHINE_BEGIN:%.*]], label [[WORKER_STATE_MACHINE_FINISHED:%.*]] 202; CHECK-DISABLED: worker_state_machine.begin: 203; CHECK-DISABLED-NEXT: call void @__kmpc_barrier_simple_generic(ptr @[[GLOB1]], i32 [[TMP0]]) 204; CHECK-DISABLED-NEXT: [[WORKER_IS_ACTIVE:%.*]] = call i1 @__kmpc_kernel_parallel(ptr [[WORKER_WORK_FN_ADDR]]) 205; CHECK-DISABLED-NEXT: [[WORKER_WORK_FN:%.*]] = load ptr, ptr [[WORKER_WORK_FN_ADDR]], align 8 206; CHECK-DISABLED-NEXT: [[WORKER_IS_DONE:%.*]] = icmp eq ptr [[WORKER_WORK_FN]], null 207; CHECK-DISABLED-NEXT: br i1 [[WORKER_IS_DONE]], label [[WORKER_STATE_MACHINE_FINISHED]], label [[WORKER_STATE_MACHINE_IS_ACTIVE_CHECK:%.*]] 208; CHECK-DISABLED: worker_state_machine.finished: 209; CHECK-DISABLED-NEXT: ret void 210; CHECK-DISABLED: worker_state_machine.is_active.check: 211; CHECK-DISABLED-NEXT: br i1 [[WORKER_IS_ACTIVE]], label [[WORKER_STATE_MACHINE_PARALLEL_REGION_CHECK:%.*]], label [[WORKER_STATE_MACHINE_DONE_BARRIER:%.*]] 212; CHECK-DISABLED: worker_state_machine.parallel_region.check: 213; CHECK-DISABLED-NEXT: br i1 true, label [[WORKER_STATE_MACHINE_PARALLEL_REGION_EXECUTE:%.*]], label [[WORKER_STATE_MACHINE_PARALLEL_REGION_CHECK1:%.*]] 214; CHECK-DISABLED: worker_state_machine.parallel_region.execute: 215; CHECK-DISABLED-NEXT: call void @__omp_outlined__1_wrapper(i16 0, i32 [[TMP0]]) 216; CHECK-DISABLED-NEXT: br label [[WORKER_STATE_MACHINE_PARALLEL_REGION_END:%.*]] 217; CHECK-DISABLED: worker_state_machine.parallel_region.check1: 218; CHECK-DISABLED-NEXT: br label [[WORKER_STATE_MACHINE_PARALLEL_REGION_END]] 219; CHECK-DISABLED: worker_state_machine.parallel_region.end: 220; CHECK-DISABLED-NEXT: call void @__kmpc_kernel_end_parallel() 221; CHECK-DISABLED-NEXT: br label [[WORKER_STATE_MACHINE_DONE_BARRIER]] 222; CHECK-DISABLED: worker_state_machine.done.barrier: 223; CHECK-DISABLED-NEXT: call void @__kmpc_barrier_simple_generic(ptr @[[GLOB1]], i32 [[TMP0]]) 224; CHECK-DISABLED-NEXT: br label [[WORKER_STATE_MACHINE_BEGIN]] 225; CHECK-DISABLED: thread.user_code.check: 226; CHECK-DISABLED-NEXT: [[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP0]], -1 227; CHECK-DISABLED-NEXT: br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]] 228; CHECK-DISABLED: user_code.entry: 229; CHECK-DISABLED-NEXT: [[C:%.*]] = icmp eq i64 [[N]], 42 230; CHECK-DISABLED-NEXT: [[SELECT:%.*]] = select i1 [[C]], ptr [[AL32]], ptr addrspacecast (ptr addrspace(5) @LocGlob to ptr) 231; CHECK-DISABLED-NEXT: store ptr [[SELECT]], ptr [[LOC]], align 8 232; CHECK-DISABLED-NEXT: [[TMP1:%.*]] = call i32 @__kmpc_global_thread_num(ptr nonnull @[[GLOB1]]) #[[ATTR6]] 233; CHECK-DISABLED-NEXT: store i32 0, ptr [[X]], align 4, !noalias [[META7:![0-9]+]] 234; CHECK-DISABLED-NEXT: [[ARRAYIDX1_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 1 235; CHECK-DISABLED-NEXT: store i32 1, ptr [[ARRAYIDX1_I]], align 4, !noalias [[META7]] 236; CHECK-DISABLED-NEXT: [[SEXT:%.*]] = shl i64 [[N]], 32 237; CHECK-DISABLED-NEXT: [[IDXPROM_I:%.*]] = ashr exact i64 [[SEXT]], 32 238; CHECK-DISABLED-NEXT: [[ARRAYIDX2_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 [[IDXPROM_I]] 239; CHECK-DISABLED-NEXT: store i32 [[N_ADDR_SROA_0_0_EXTRACT_TRUNC]], ptr [[ARRAYIDX2_I]], align 4, !noalias [[META7]] 240; CHECK-DISABLED-NEXT: call void @usei8ptr(ptr captures(none) [[HEAP2STACK_H2S]]) #[[ATTR9:[0-9]+]] 241; CHECK-DISABLED-NEXT: br label [[FOR_COND_I:%.*]] 242; CHECK-DISABLED: for.cond.i: 243; CHECK-DISABLED-NEXT: [[I_0_I:%.*]] = phi i32 [ 2, [[USER_CODE_ENTRY]] ], [ [[INC_I:%.*]], [[FOR_BODY_I:%.*]] ] 244; CHECK-DISABLED-NEXT: [[SUB_I:%.*]] = add nsw i32 [[N_ADDR_SROA_0_0_EXTRACT_TRUNC]], -1 245; CHECK-DISABLED-NEXT: [[CMP_I:%.*]] = icmp slt i32 [[I_0_I]], [[SUB_I]] 246; CHECK-DISABLED-NEXT: br i1 [[CMP_I]], label [[FOR_BODY_I]], label [[__OMP_OUTLINED___EXIT:%.*]] 247; CHECK-DISABLED: for.body.i: 248; CHECK-DISABLED-NEXT: [[SUB3_I:%.*]] = add nsw i32 [[I_0_I]], -1 249; CHECK-DISABLED-NEXT: [[IDXPROM4_I:%.*]] = zext i32 [[I_0_I]] to i64 250; CHECK-DISABLED-NEXT: [[ARRAYIDX5_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 [[IDXPROM4_I]] 251; CHECK-DISABLED-NEXT: store i32 [[SUB3_I]], ptr [[ARRAYIDX5_I]], align 4, !noalias [[META7]] 252; CHECK-DISABLED-NEXT: [[INC_I]] = add nuw nsw i32 [[I_0_I]], 1 253; CHECK-DISABLED-NEXT: br label [[FOR_COND_I]], !llvm.loop [[LOOP10:![0-9]+]] 254; CHECK-DISABLED: __omp_outlined__.exit: 255; CHECK-DISABLED-NEXT: call void @__kmpc_parallel_51(ptr null, i32 0, i32 1, i32 -1, i32 -1, ptr @__omp_outlined__1, ptr @__omp_outlined__1_wrapper.ID, ptr null, i64 0) 256; CHECK-DISABLED-NEXT: [[CALL_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10:[0-9]+]], !noalias [[META7]] 257; CHECK-DISABLED-NEXT: [[IDXPROM6_I:%.*]] = sext i32 [[CALL_I]] to i64 258; CHECK-DISABLED-NEXT: [[ARRAYIDX7_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 [[IDXPROM6_I]] 259; CHECK-DISABLED-NEXT: store i32 [[CALL_I]], ptr [[ARRAYIDX7_I]], align 4, !noalias [[META7]] 260; CHECK-DISABLED-NEXT: [[CALL8_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10]], !noalias [[META7]] 261; CHECK-DISABLED-NEXT: [[IDXPROM9_I:%.*]] = sext i32 [[CALL8_I]] to i64 262; CHECK-DISABLED-NEXT: [[ARRAYIDX10_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 [[IDXPROM9_I]] 263; CHECK-DISABLED-NEXT: store i32 [[CALL8_I]], ptr [[ARRAYIDX10_I]], align 4, !noalias [[META7]] 264; CHECK-DISABLED-NEXT: [[CALL11_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10]], !noalias [[META7]] 265; CHECK-DISABLED-NEXT: [[IDXPROM12_I:%.*]] = sext i32 [[CALL11_I]] to i64 266; CHECK-DISABLED-NEXT: [[ARRAYIDX13_I:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 [[IDXPROM12_I]] 267; CHECK-DISABLED-NEXT: store i32 [[CALL11_I]], ptr [[ARRAYIDX13_I]], align 4, !noalias [[META7]] 268; CHECK-DISABLED-NEXT: [[CALL14_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10]], !noalias [[META7]] 269; CHECK-DISABLED-NEXT: [[CALL15_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10]], !noalias [[META7]] 270; CHECK-DISABLED-NEXT: [[CALL16_I:%.*]] = call i32 @no_openmp(ptr nonnull [[X]]) #[[ATTR10]], !noalias [[META7]] 271; CHECK-DISABLED-NEXT: call void @__kmpc_target_deinit() #[[ATTR6]] 272; CHECK-DISABLED-NEXT: ret void 273; CHECK-DISABLED: worker.exit: 274; CHECK-DISABLED-NEXT: ret void 275; 276entry: 277 %loc = alloca ptr 278 %al32 = alloca i32 279 %N.addr.sroa.0.0.extract.trunc = trunc i64 %N to i32 280 %0 = call i32 @__kmpc_target_init(ptr nonnull @__omp_offloading_2a_fbfa7a_sequential_loop_l6_kernel_environment, ptr %dyn) #3 281 %exec_user_code = icmp eq i32 %0, -1 282 br i1 %exec_user_code, label %user_code.entry, label %worker.exit 283 284user_code.entry: ; preds = %entry 285 %c = icmp eq i64 %N, 42 286 %select = select i1 %c, ptr %al32, ptr addrspacecast (ptr addrspace(5) @LocGlob to ptr) 287 store ptr %select, ptr %loc 288 %1 = call i32 @__kmpc_global_thread_num(ptr nonnull @1) 289 store i32 0, ptr %x, align 4, !noalias !8 290 %arrayidx1.i = getelementptr inbounds i32, ptr %x, i64 1 291 store i32 1, ptr %arrayidx1.i, align 4, !noalias !8 292 %sext = shl i64 %N, 32 293 %idxprom.i = ashr exact i64 %sext, 32 294 %arrayidx2.i = getelementptr inbounds i32, ptr %x, i64 %idxprom.i 295 store i32 %N.addr.sroa.0.0.extract.trunc, ptr %arrayidx2.i, align 4, !noalias !8 296 %heap2stack = call align 8 ptr @__kmpc_alloc_shared(i64 8) 297 call void @usei8ptr(ptr nocapture %heap2stack) willreturn nounwind 298 call void @__kmpc_free_shared(ptr %heap2stack, i64 8) 299 br label %for.cond.i 300 301for.cond.i: ; preds = %for.body.i, %user_code.entry 302 %i.0.i = phi i32 [ 2, %user_code.entry ], [ %inc.i, %for.body.i ] 303 %sub.i = add nsw i32 %N.addr.sroa.0.0.extract.trunc, -1 304 %cmp.i = icmp slt i32 %i.0.i, %sub.i 305 br i1 %cmp.i, label %for.body.i, label %__omp_outlined__.exit 306 307for.body.i: ; preds = %for.cond.i 308 %sub3.i = add nsw i32 %i.0.i, -1 309 %idxprom4.i = zext i32 %i.0.i to i64 310 %arrayidx5.i = getelementptr inbounds i32, ptr %x, i64 %idxprom4.i 311 store i32 %sub3.i, ptr %arrayidx5.i, align 4, !noalias !8 312 ; No Need to guard these accesses 313 %l = load ptr, ptr %loc 314 store i32 4711, ptr %l 315 %inc.i = add nuw nsw i32 %i.0.i, 1 316 br label %for.cond.i, !llvm.loop !11 317 318__omp_outlined__.exit: ; preds = %for.cond.i 319 call void @__kmpc_parallel_51(ptr null, i32 0, i32 1, i32 -1, i32 -1, ptr @__omp_outlined__1, ptr @__omp_outlined__1_wrapper, ptr null, i64 0) 320 %call.i = call i32 @no_openmp(ptr nonnull %x) #5, !noalias !8 321 %idxprom6.i = sext i32 %call.i to i64 322 %arrayidx7.i = getelementptr inbounds i32, ptr %x, i64 %idxprom6.i 323 store i32 %call.i, ptr %arrayidx7.i, align 4, !noalias !8 324 %call8.i = call i32 @no_openmp(ptr nonnull %x) #5, !noalias !8 325 %idxprom9.i = sext i32 %call8.i to i64 326 %arrayidx10.i = getelementptr inbounds i32, ptr %x, i64 %idxprom9.i 327 store i32 %call8.i, ptr %arrayidx10.i, align 4, !noalias !8 328 %call11.i = call i32 @no_openmp(ptr nonnull %x) #5, !noalias !8 329 %idxprom12.i = sext i32 %call11.i to i64 330 %arrayidx13.i = getelementptr inbounds i32, ptr %x, i64 %idxprom12.i 331 store i32 %call11.i, ptr %arrayidx13.i, align 4, !noalias !8 332 %call14.i = call i32 @no_openmp(ptr nonnull %x) #5, !noalias !8 333 %call15.i = call i32 @no_openmp(ptr nonnull %x) #5, !noalias !8 334 %call16.i = call i32 @no_openmp(ptr nonnull %x) #5, !noalias !8 335 call void @__kmpc_target_deinit() #3 336 ret void 337 338worker.exit: ; preds = %entry 339 ret void 340} 341 342define internal void @__omp_outlined__1(ptr noalias %.global_tid., ptr noalias %.bound_tid.) { 343; CHECK-LABEL: define {{[^@]+}}@__omp_outlined__1 344; CHECK-SAME: (ptr noalias [[DOTGLOBAL_TID_:%.*]], ptr noalias [[DOTBOUND_TID_:%.*]]) { 345; CHECK-NEXT: ret void 346; 347; CHECK-DISABLED-LABEL: define {{[^@]+}}@__omp_outlined__1 348; CHECK-DISABLED-SAME: (ptr noalias [[DOTGLOBAL_TID_:%.*]], ptr noalias [[DOTBOUND_TID_:%.*]]) { 349; CHECK-DISABLED-NEXT: ret void 350; 351 ret void 352} 353define internal void @__omp_outlined__1_wrapper(i16 zeroext %0, i32 %1) { 354; CHECK-LABEL: define {{[^@]+}}@__omp_outlined__1_wrapper 355; CHECK-SAME: (i16 zeroext [[TMP0:%.*]], i32 [[TMP1:%.*]]) { 356; CHECK-NEXT: ret void 357; 358; CHECK-DISABLED-LABEL: define {{[^@]+}}@__omp_outlined__1_wrapper 359; CHECK-DISABLED-SAME: (i16 zeroext [[TMP0:%.*]], i32 [[TMP1:%.*]]) { 360; CHECK-DISABLED-NEXT: ret void 361; 362 ret void 363} 364 365declare void @__kmpc_parallel_51(ptr, i32, i32, i32, i32, ptr, ptr, ptr, i64) 366 367; Make it a weak definition so we will apply custom state machine rewriting but can't use the body in the reasoning. 368define weak i32 @__kmpc_target_init(ptr, ptr) { 369; CHECK-LABEL: define {{[^@]+}}@__kmpc_target_init 370; CHECK-SAME: (ptr [[TMP0:%.*]], ptr [[TMP1:%.*]]) { 371; CHECK-NEXT: ret i32 0 372; 373; CHECK-DISABLED-LABEL: define {{[^@]+}}@__kmpc_target_init 374; CHECK-DISABLED-SAME: (ptr [[TMP0:%.*]], ptr [[TMP1:%.*]]) { 375; CHECK-DISABLED-NEXT: ret i32 0 376; 377 ret i32 0 378} 379 380; Function Attrs: convergent 381declare i32 @no_openmp(ptr) #1 382declare void @no_openmp_i32(i32) #1 383 384; Function Attrs: convergent nounwind readonly willreturn 385declare void @pure() #2 386 387declare ptr @__kmpc_alloc_shared(i64) 388declare void @__kmpc_free_shared(ptr nocapture, i64) 389declare void @usei8ptr(ptr) #1 390 391; Function Attrs: nounwind 392declare i32 @__kmpc_global_thread_num(ptr) #3 393 394declare void @__kmpc_target_deinit() 395 396; Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn 397declare void @llvm.experimental.noalias.scope.decl(metadata) #4 398 399attributes #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_53" "target-features"="+ptx32,+sm_53" } 400attributes #1 = { convergent "frame-pointer"="all" "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" } 401attributes #2 = { convergent nounwind readonly willreturn "frame-pointer"="all" "llvm.assume"="ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" } 402attributes #3 = { nounwind } 403attributes #4 = { inaccessiblememonly nofree nosync nounwind willreturn } 404attributes #5 = { convergent nounwind "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" } 405 406!omp_offload.info = !{!0} 407!llvm.module.flags = !{!2, !3, !4, !5, !6} 408!llvm.ident = !{!7} 409 410!0 = !{i32 0, i32 42, i32 16513658, !"sequential_loop", i32 6, i32 0} 411!2 = !{i32 1, !"wchar_size", i32 4} 412!3 = !{i32 7, !"openmp", i32 50} 413!4 = !{i32 7, !"openmp-device", i32 50} 414!5 = !{i32 8, !"PIC Level", i32 2} 415!6 = !{i32 7, !"frame-pointer", i32 2} 416!7 = !{!"clang version 14.0.0"} 417!8 = !{!9} 418!9 = distinct !{!9, !10, !"__omp_outlined__: %__context"} 419!10 = distinct !{!10, !"__omp_outlined__"} 420!11 = distinct !{!11, !12} 421!12 = !{!"llvm.loop.mustprogress"} 422;. 423; CHECK: attributes #[[ATTR0]] = { convergent norecurse nounwind "frame-pointer"="all" "kernel" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" } 424; CHECK: attributes #[[ATTR1:[0-9]+]] = { alwaysinline } 425; CHECK: attributes #[[ATTR2:[0-9]+]] = { convergent "frame-pointer"="all" "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" } 426; CHECK: attributes #[[ATTR3:[0-9]+]] = { convergent nounwind willreturn memory(read) "frame-pointer"="all" "llvm.assume"="ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" } 427; CHECK: attributes #[[ATTR4:[0-9]+]] = { nosync nounwind allocsize(0) } 428; CHECK: attributes #[[ATTR5:[0-9]+]] = { nosync nounwind } 429; CHECK: attributes #[[ATTR6]] = { nounwind } 430; CHECK: attributes #[[ATTR7:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) } 431; CHECK: attributes #[[ATTR8:[0-9]+]] = { convergent nounwind } 432; CHECK: attributes #[[ATTR9]] = { nounwind willreturn "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" } 433; CHECK: attributes #[[ATTR10]] = { convergent nounwind "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" } 434;. 435; CHECK-DISABLED: attributes #[[ATTR0]] = { convergent norecurse nounwind "frame-pointer"="all" "kernel" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" } 436; CHECK-DISABLED: attributes #[[ATTR1:[0-9]+]] = { alwaysinline } 437; CHECK-DISABLED: attributes #[[ATTR2:[0-9]+]] = { convergent "frame-pointer"="all" "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" } 438; CHECK-DISABLED: attributes #[[ATTR3:[0-9]+]] = { convergent nounwind willreturn memory(read) "frame-pointer"="all" "llvm.assume"="ompx_spmd_amenable" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="sm_53" "target-features"="+ptx32,+sm_53" } 439; CHECK-DISABLED: attributes #[[ATTR4:[0-9]+]] = { nosync nounwind allocsize(0) } 440; CHECK-DISABLED: attributes #[[ATTR5:[0-9]+]] = { nosync nounwind } 441; CHECK-DISABLED: attributes #[[ATTR6]] = { nounwind } 442; CHECK-DISABLED: attributes #[[ATTR7:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) } 443; CHECK-DISABLED: attributes #[[ATTR8:[0-9]+]] = { convergent nounwind } 444; CHECK-DISABLED: attributes #[[ATTR9]] = { nounwind willreturn "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" } 445; CHECK-DISABLED: attributes #[[ATTR10]] = { convergent nounwind "llvm.assume"="omp_no_openmp,ompx_spmd_amenable" } 446;. 447; CHECK: [[META0:![0-9]+]] = !{i32 0, i32 42, i32 16513658, !"sequential_loop", i32 6, i32 0} 448; CHECK: [[META1:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} 449; CHECK: [[META2:![0-9]+]] = !{i32 7, !"openmp", i32 50} 450; CHECK: [[META3:![0-9]+]] = !{i32 7, !"openmp-device", i32 50} 451; CHECK: [[META4:![0-9]+]] = !{i32 8, !"PIC Level", i32 2} 452; CHECK: [[META5:![0-9]+]] = !{i32 7, !"frame-pointer", i32 2} 453; CHECK: [[META6:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"} 454; CHECK: [[META7]] = !{[[META8:![0-9]+]]} 455; CHECK: [[META8]] = distinct !{[[META8]], [[META9:![0-9]+]], !"__omp_outlined__: %__context"} 456; CHECK: [[META9]] = distinct !{[[META9]], !"__omp_outlined__"} 457; CHECK: [[LOOP10]] = distinct !{[[LOOP10]], [[META11:![0-9]+]]} 458; CHECK: [[META11]] = !{!"llvm.loop.mustprogress"} 459;. 460; CHECK-DISABLED: [[META0:![0-9]+]] = !{i32 0, i32 42, i32 16513658, !"sequential_loop", i32 6, i32 0} 461; CHECK-DISABLED: [[META1:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} 462; CHECK-DISABLED: [[META2:![0-9]+]] = !{i32 7, !"openmp", i32 50} 463; CHECK-DISABLED: [[META3:![0-9]+]] = !{i32 7, !"openmp-device", i32 50} 464; CHECK-DISABLED: [[META4:![0-9]+]] = !{i32 8, !"PIC Level", i32 2} 465; CHECK-DISABLED: [[META5:![0-9]+]] = !{i32 7, !"frame-pointer", i32 2} 466; CHECK-DISABLED: [[META6:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"} 467; CHECK-DISABLED: [[META7]] = !{[[META8:![0-9]+]]} 468; CHECK-DISABLED: [[META8]] = distinct !{[[META8]], [[META9:![0-9]+]], !"__omp_outlined__: %__context"} 469; CHECK-DISABLED: [[META9]] = distinct !{[[META9]], !"__omp_outlined__"} 470; CHECK-DISABLED: [[LOOP10]] = distinct !{[[LOOP10]], [[META11:![0-9]+]]} 471; CHECK-DISABLED: [[META11]] = !{!"llvm.loop.mustprogress"} 472;. 473