1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature 2; RUN: opt -S -attributor -openmpopt < %s | FileCheck %s 3; RUN: opt -S -passes='attributor,cgscc(openmpopt)' < %s | FileCheck %s 4; 5target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 6 7%struct.ident_t = type { i32, i32, i32, i32, i8* } 8 9@.str = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 10@0 = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0) }, align 8 11@1 = private unnamed_addr global %struct.ident_t { i32 0, i32 322, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0) }, align 8 12@.gomp_critical_user_.reduction.var = common global [8 x i32] zeroinitializer 13@2 = private unnamed_addr global %struct.ident_t { i32 0, i32 18, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0) }, align 8 14 15; void delete_parallel_0(void) { 16; #pragma omp parallel 17; { unknown_willreturn(); } 18; #pragma omp parallel 19; { readonly_willreturn(); } 20; #pragma omp parallel 21; { readnone_willreturn(); } 22; #pragma omp parallel 23; {} 24; } 25; 26; We delete all but the first of the parallel regions in this test. 27define void @delete_parallel_0() { 28; CHECK-LABEL: define {{[^@]+}}@delete_parallel_0() 29; CHECK-NEXT: entry: 30; CHECK-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* noundef nonnull align 8 dereferenceable(24) @0, i32 noundef 0, void (i32*, i32*, ...)* noundef bitcast (void (i32*, i32*)* @.omp_outlined.willreturn to void (i32*, i32*, ...)*)) 31; CHECK-NEXT: ret void 32; 33entry: 34 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined.willreturn to void (i32*, i32*, ...)*)) 35 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined.willreturn.0 to void (i32*, i32*, ...)*)) 36 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined.willreturn.1 to void (i32*, i32*, ...)*)) 37 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined.willreturn.2 to void (i32*, i32*, ...)*)) 38 ret void 39} 40 41define internal void @.omp_outlined.willreturn(i32* noalias %.global_tid., i32* noalias %.bound_tid.) { 42; CHECK-LABEL: define {{[^@]+}}@.omp_outlined.willreturn 43; CHECK-SAME: (i32* noalias nocapture nofree readnone [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]]) #0 44; CHECK-NEXT: entry: 45; CHECK-NEXT: call void @unknown() #0 46; CHECK-NEXT: ret void 47; 48entry: 49 call void @unknown() willreturn 50 ret void 51} 52 53define internal void @.omp_outlined.willreturn.0(i32* noalias %.global_tid., i32* noalias %.bound_tid.) willreturn { 54; CHECK-LABEL: define {{[^@]+}}@.omp_outlined.willreturn.0 55; CHECK-SAME: (i32* noalias nocapture nofree readnone [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]]) #1 56; CHECK-NEXT: entry: 57; CHECK-NEXT: call void @readonly() #4 58; CHECK-NEXT: ret void 59; 60entry: 61 call void @readonly() 62 ret void 63} 64 65define internal void @.omp_outlined.willreturn.1(i32* noalias %.global_tid., i32* noalias %.bound_tid.) { 66; CHECK-LABEL: define {{[^@]+}}@.omp_outlined.willreturn.1 67; CHECK-SAME: (i32* noalias nocapture nofree readnone [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]]) #2 68; CHECK-NEXT: entry: 69; CHECK-NEXT: call void @readnone() #0 70; CHECK-NEXT: ret void 71; 72entry: 73 call void @readnone() willreturn 74 ret void 75} 76 77define internal void @.omp_outlined.willreturn.2(i32* noalias %.global_tid., i32* noalias %.bound_tid.) { 78; CHECK-LABEL: define {{[^@]+}}@.omp_outlined.willreturn.2 79; CHECK-SAME: (i32* noalias nocapture nofree readnone [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]]) #3 80; CHECK-NEXT: entry: 81; CHECK-NEXT: ret void 82; 83entry: 84 ret void 85} 86 87; void delete_parallel_1(void) { 88; #pragma omp parallel 89; { unknown(); } 90; #pragma omp parallel 91; { readonly(); } 92; #pragma omp parallel 93; { readnone(); } 94; #pragma omp parallel 95; {} 96; } 97; 98; We delete only the last parallel regions in this test because the others might not return. 99define void @delete_parallel_1() { 100; CHECK-LABEL: define {{[^@]+}}@delete_parallel_1() 101; CHECK-NEXT: entry: 102; CHECK-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* noundef nonnull align 8 dereferenceable(24) @0, i32 noundef 0, void (i32*, i32*, ...)* noundef bitcast (void (i32*, i32*)* @.omp_outlined. to void (i32*, i32*, ...)*)) 103; CHECK-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* noundef nonnull align 8 dereferenceable(24) @0, i32 noundef 0, void (i32*, i32*, ...)* noundef bitcast (void (i32*, i32*)* @.omp_outlined..0 to void (i32*, i32*, ...)*)) 104; CHECK-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* noundef nonnull align 8 dereferenceable(24) @0, i32 noundef 0, void (i32*, i32*, ...)* noundef bitcast (void (i32*, i32*)* @.omp_outlined..1 to void (i32*, i32*, ...)*)) 105; CHECK-NEXT: ret void 106; 107entry: 108 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined. to void (i32*, i32*, ...)*)) 109 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined..0 to void (i32*, i32*, ...)*)) 110 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined..1 to void (i32*, i32*, ...)*)) 111 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined..2 to void (i32*, i32*, ...)*)) 112 ret void 113} 114 115define internal void @.omp_outlined.(i32* noalias %.global_tid., i32* noalias %.bound_tid.) { 116; CHECK-LABEL: define {{[^@]+}}@.omp_outlined. 117; CHECK-SAME: (i32* noalias nocapture nofree readnone [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]]) 118; CHECK-NEXT: entry: 119; CHECK-NEXT: call void @unknown() 120; CHECK-NEXT: ret void 121; 122entry: 123 call void @unknown() 124 ret void 125} 126 127define internal void @.omp_outlined..0(i32* noalias %.global_tid., i32* noalias %.bound_tid.) { 128; CHECK-LABEL: define {{[^@]+}}@.omp_outlined..0 129; CHECK-SAME: (i32* noalias nocapture nofree readnone [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]]) #4 130; CHECK-NEXT: entry: 131; CHECK-NEXT: call void @readonly() #4 132; CHECK-NEXT: ret void 133; 134entry: 135 call void @readonly() 136 ret void 137} 138 139define internal void @.omp_outlined..1(i32* noalias %.global_tid., i32* noalias %.bound_tid.) { 140; CHECK-LABEL: define {{[^@]+}}@.omp_outlined..1 141; CHECK-SAME: (i32* noalias nocapture nofree readnone [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]]) #5 142; CHECK-NEXT: entry: 143; CHECK-NEXT: call void @readnone() 144; CHECK-NEXT: ret void 145; 146entry: 147 call void @readnone() 148 ret void 149} 150 151define internal void @.omp_outlined..2(i32* noalias %.global_tid., i32* noalias %.bound_tid.) { 152; CHECK-LABEL: define {{[^@]+}}@.omp_outlined..2 153; CHECK-SAME: (i32* noalias nocapture nofree readnone [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]]) #3 154; CHECK-NEXT: entry: 155; CHECK-NEXT: ret void 156; 157entry: 158 ret void 159} 160 161; void delete_parallel_2(void) { 162; int a = 0; 163; #pragma omp parallel 164; { 165; if (omp_get_thread_num() == 0) 166; ++a; 167; } 168; #pragma omp parallel 169; { 170; #pragma omp master 171; ++a; 172; } 173; #pragma omp parallel 174; { 175; #pragma omp single 176; ++a; 177; } 178; #pragma omp parallel reduction(+: a) 179; { 180; ++a; 181; } 182; } 183; 184; FIXME: We do not realize that `a` is dead and all accesses to it can be removed 185; making the parallel regions readonly and deletable. 186define void @delete_parallel_2() { 187; CHECK-LABEL: define {{[^@]+}}@delete_parallel_2() 188; CHECK-NEXT: entry: 189; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4 190; CHECK-NEXT: [[TMP:%.*]] = bitcast i32* [[A]] to i8* 191; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 noundef 4, i8* noundef nonnull align 4 dereferenceable(4) [[TMP]]) #0 192; CHECK-NEXT: store i32 0, i32* [[A]], align 4 193; CHECK-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* noundef nonnull align 8 dereferenceable(24) @0, i32 noundef 1, void (i32*, i32*, ...)* noundef bitcast (void (i32*, i32*, i32*)* @.omp_outlined..3 to void (i32*, i32*, ...)*), i32* nocapture nofree noundef nonnull align 4 dereferenceable(4) [[A]]) 194; CHECK-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* noundef nonnull align 8 dereferenceable(24) @0, i32 noundef 1, void (i32*, i32*, ...)* noundef bitcast (void (i32*, i32*, i32*)* @.omp_outlined..4 to void (i32*, i32*, ...)*), i32* nocapture noundef nonnull align 4 dereferenceable(4) [[A]]) 195; CHECK-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* noundef nonnull align 8 dereferenceable(24) @0, i32 noundef 1, void (i32*, i32*, ...)* noundef bitcast (void (i32*, i32*, i32*)* @.omp_outlined..5 to void (i32*, i32*, ...)*), i32* nocapture noundef nonnull align 4 dereferenceable(4) [[A]]) 196; CHECK-NEXT: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* noundef nonnull align 8 dereferenceable(24) @0, i32 noundef 1, void (i32*, i32*, ...)* noundef bitcast (void (i32*, i32*, i32*)* @.omp_outlined..6 to void (i32*, i32*, ...)*), i32* nocapture noundef nonnull align 4 dereferenceable(4) [[A]]) 197; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[A]] to i8* 198; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 noundef 4, i8* noundef nonnull [[TMP1]]) 199; CHECK-NEXT: ret void 200; 201entry: 202 %a = alloca i32, align 4 203 %tmp = bitcast i32* %a to i8* 204 call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %tmp) 205 store i32 0, i32* %a, align 4 206 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* @.omp_outlined..3 to void (i32*, i32*, ...)*), i32* nonnull %a) 207 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* @.omp_outlined..4 to void (i32*, i32*, ...)*), i32* nonnull %a) 208 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* @.omp_outlined..5 to void (i32*, i32*, ...)*), i32* nonnull %a) 209 call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i32*)* @.omp_outlined..6 to void (i32*, i32*, ...)*), i32* nonnull %a) 210 %tmp1 = bitcast i32* %a to i8* 211 call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %tmp1) 212 ret void 213} 214 215define internal void @.omp_outlined..3(i32* noalias %.global_tid., i32* noalias %.bound_tid., i32* dereferenceable(4) %a) { 216; CHECK-LABEL: define {{[^@]+}}@.omp_outlined..3 217; CHECK-SAME: (i32* noalias nocapture nofree readnone [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]], i32* nocapture nofree noundef nonnull align 4 dereferenceable(4) [[A:%.*]]) #6 218; CHECK-NEXT: entry: 219; CHECK-NEXT: [[CALL:%.*]] = call i32 @omp_get_thread_num() #4 220; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[CALL]], 0 221; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] 222; CHECK: if.then: 223; CHECK-NEXT: [[TMP:%.*]] = load i32, i32* [[A]], align 4 224; CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP]], 1 225; CHECK-NEXT: store i32 [[INC]], i32* [[A]], align 4 226; CHECK-NEXT: br label [[IF_END]] 227; CHECK: if.end: 228; CHECK-NEXT: ret void 229; 230entry: 231 %call = call i32 @omp_get_thread_num() 232 %cmp = icmp eq i32 %call, 0 233 br i1 %cmp, label %if.then, label %if.end 234 235if.then: ; preds = %entry 236 %tmp = load i32, i32* %a, align 4 237 %inc = add nsw i32 %tmp, 1 238 store i32 %inc, i32* %a, align 4 239 br label %if.end 240 241if.end: ; preds = %if.then, %entry 242 ret void 243} 244 245define internal void @.omp_outlined..4(i32* noalias %.global_tid., i32* noalias %.bound_tid., i32* dereferenceable(4) %a) { 246; CHECK-LABEL: define {{[^@]+}}@.omp_outlined..4 247; CHECK-SAME: (i32* noalias nocapture nonnull readonly align 4 dereferenceable(4) [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]], i32* nocapture noundef nonnull align 4 dereferenceable(4) [[A:%.*]]) 248; CHECK-NEXT: entry: 249; CHECK-NEXT: [[TMP:%.*]] = load i32, i32* [[DOTGLOBAL_TID_]], align 4 250; CHECK-NEXT: [[TMP1:%.*]] = call i32 @__kmpc_master(%struct.ident_t* noundef nonnull @0, i32 [[TMP]]) 251; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0 252; CHECK-NEXT: br i1 [[TMP2]], label [[OMP_IF_END:%.*]], label [[OMP_IF_THEN:%.*]] 253; CHECK: omp_if.then: 254; CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* [[A]], align 4 255; CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP3]], 1 256; CHECK-NEXT: store i32 [[INC]], i32* [[A]], align 4 257; CHECK-NEXT: call void @__kmpc_end_master(%struct.ident_t* noundef nonnull @0, i32 [[TMP]]) 258; CHECK-NEXT: br label [[OMP_IF_END]] 259; CHECK: omp_if.end: 260; CHECK-NEXT: ret void 261; 262entry: 263 %tmp = load i32, i32* %.global_tid., align 4 264 %tmp1 = call i32 @__kmpc_master(%struct.ident_t* nonnull @0, i32 %tmp) 265 %tmp2 = icmp eq i32 %tmp1, 0 266 br i1 %tmp2, label %omp_if.end, label %omp_if.then 267 268omp_if.then: ; preds = %entry 269 %tmp3 = load i32, i32* %a, align 4 270 %inc = add nsw i32 %tmp3, 1 271 store i32 %inc, i32* %a, align 4 272 call void @__kmpc_end_master(%struct.ident_t* nonnull @0, i32 %tmp) 273 br label %omp_if.end 274 275omp_if.end: ; preds = %entry, %omp_if.then 276 ret void 277} 278 279declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) 280 281declare i32 @omp_get_thread_num() inaccessiblememonly nofree nosync nounwind readonly 282 283declare i32 @__kmpc_master(%struct.ident_t*, i32) 284 285declare void @__kmpc_end_master(%struct.ident_t*, i32) 286 287define internal void @.omp_outlined..5(i32* noalias %.global_tid., i32* noalias %.bound_tid., i32* dereferenceable(4) %a) { 288; CHECK-LABEL: define {{[^@]+}}@.omp_outlined..5 289; CHECK-SAME: (i32* noalias nocapture nonnull readonly align 4 dereferenceable(4) [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]], i32* nocapture noundef nonnull align 4 dereferenceable(4) [[A:%.*]]) 290; CHECK-NEXT: entry: 291; CHECK-NEXT: [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* noundef nonnull @0) 292; CHECK-NEXT: [[TMP:%.*]] = load i32, i32* [[DOTGLOBAL_TID_]], align 4 293; CHECK-NEXT: [[TMP1:%.*]] = call i32 @__kmpc_single(%struct.ident_t* noundef nonnull @0, i32 [[TMP]]) 294; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0 295; CHECK-NEXT: br i1 [[TMP2]], label [[OMP_IF_END:%.*]], label [[OMP_IF_THEN:%.*]] 296; CHECK: omp_if.then: 297; CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* [[A]], align 4 298; CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP3]], 1 299; CHECK-NEXT: store i32 [[INC]], i32* [[A]], align 4 300; CHECK-NEXT: call void @__kmpc_end_single(%struct.ident_t* noundef nonnull @0, i32 [[TMP]]) 301; CHECK-NEXT: br label [[OMP_IF_END]] 302; CHECK: omp_if.end: 303; CHECK-NEXT: call void @__kmpc_barrier(%struct.ident_t* noundef nonnull @1, i32 [[OMP_GLOBAL_THREAD_NUM]]) 304; CHECK-NEXT: ret void 305; 306entry: 307 %omp_global_thread_num = call i32 @__kmpc_global_thread_num(%struct.ident_t* nonnull @0) 308 %tmp = load i32, i32* %.global_tid., align 4 309 %tmp1 = call i32 @__kmpc_single(%struct.ident_t* nonnull @0, i32 %tmp) 310 %tmp2 = icmp eq i32 %tmp1, 0 311 br i1 %tmp2, label %omp_if.end, label %omp_if.then 312 313omp_if.then: ; preds = %entry 314 %tmp3 = load i32, i32* %a, align 4 315 %inc = add nsw i32 %tmp3, 1 316 store i32 %inc, i32* %a, align 4 317 call void @__kmpc_end_single(%struct.ident_t* nonnull @0, i32 %tmp) 318 br label %omp_if.end 319 320omp_if.end: ; preds = %entry, %omp_if.then 321 call void @__kmpc_barrier(%struct.ident_t* nonnull @1, i32 %omp_global_thread_num) #6 322 ret void 323} 324 325define internal void @.omp_outlined..6(i32* noalias %.global_tid., i32* noalias %.bound_tid., i32* dereferenceable(4) %a) { 326; CHECK-LABEL: define {{[^@]+}}@.omp_outlined..6 327; CHECK-SAME: (i32* noalias nocapture nonnull readonly align 4 dereferenceable(4) [[DOTGLOBAL_TID_:%.*]], i32* noalias nocapture nofree readnone [[DOTBOUND_TID_:%.*]], i32* nocapture noundef nonnull align 4 dereferenceable(4) [[A:%.*]]) 328; CHECK-NEXT: entry: 329; CHECK-NEXT: [[A1:%.*]] = alloca i32, align 4 330; CHECK-NEXT: [[DOTOMP_REDUCTION_RED_LIST:%.*]] = alloca [1 x i8*], align 8 331; CHECK-NEXT: [[TMP:%.*]] = bitcast i32* [[A1]] to i8* 332; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 noundef 4, i8* noundef nonnull align 4 [[TMP]]) #0 333; CHECK-NEXT: store i32 1, i32* [[A1]], align 4 334; CHECK-NEXT: [[TMP1:%.*]] = bitcast [1 x i8*]* [[DOTOMP_REDUCTION_RED_LIST]] to i32** 335; CHECK-NEXT: store i32* [[A1]], i32** [[TMP1]], align 8 336; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[DOTGLOBAL_TID_]], align 4 337; CHECK-NEXT: [[TMP3:%.*]] = bitcast [1 x i8*]* [[DOTOMP_REDUCTION_RED_LIST]] to i8* 338; CHECK-NEXT: [[TMP4:%.*]] = call i32 @__kmpc_reduce_nowait(%struct.ident_t* noundef nonnull @2, i32 [[TMP2]], i32 noundef 1, i64 noundef 8, i8* noundef nonnull align 8 [[TMP3]], void (i8*, i8*)* noundef nonnull @.omp.reduction.reduction_func, [8 x i32]* noundef nonnull @.gomp_critical_user_.reduction.var) 339; CHECK-NEXT: switch i32 [[TMP4]], label [[DOTOMP_REDUCTION_DEFAULT:%.*]] [ 340; CHECK-NEXT: i32 1, label [[DOTOMP_REDUCTION_CASE1:%.*]] 341; CHECK-NEXT: i32 2, label [[DOTOMP_REDUCTION_CASE2:%.*]] 342; CHECK-NEXT: ] 343; CHECK: .omp.reduction.case1: 344; CHECK-NEXT: [[TMP5:%.*]] = load i32, i32* [[A]], align 4 345; CHECK-NEXT: [[TMP6:%.*]] = load i32, i32* [[A1]], align 4 346; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP5]], [[TMP6]] 347; CHECK-NEXT: store i32 [[ADD]], i32* [[A]], align 4 348; CHECK-NEXT: call void @__kmpc_end_reduce_nowait(%struct.ident_t* noundef nonnull @2, i32 [[TMP2]], [8 x i32]* noundef nonnull @.gomp_critical_user_.reduction.var) 349; CHECK-NEXT: br label [[DOTOMP_REDUCTION_DEFAULT]] 350; CHECK: .omp.reduction.case2: 351; CHECK-NEXT: [[TMP7:%.*]] = load i32, i32* [[A1]], align 4 352; CHECK-NEXT: [[TMP8:%.*]] = atomicrmw add i32* [[A]], i32 [[TMP7]] monotonic 353; CHECK-NEXT: br label [[DOTOMP_REDUCTION_DEFAULT]] 354; CHECK: .omp.reduction.default: 355; CHECK-NEXT: [[TMP9:%.*]] = bitcast i32* [[A1]] to i8* 356; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 noundef 4, i8* noundef nonnull [[TMP9]]) 357; CHECK-NEXT: ret void 358; 359entry: 360 %a1 = alloca i32, align 4 361 %.omp.reduction.red_list = alloca [1 x i8*], align 8 362 %tmp = bitcast i32* %a1 to i8* 363 call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %tmp) 364 store i32 1, i32* %a1, align 4 365 %tmp1 = bitcast [1 x i8*]* %.omp.reduction.red_list to i32** 366 store i32* %a1, i32** %tmp1, align 8 367 %tmp2 = load i32, i32* %.global_tid., align 4 368 %tmp3 = bitcast [1 x i8*]* %.omp.reduction.red_list to i8* 369 %tmp4 = call i32 @__kmpc_reduce_nowait(%struct.ident_t* nonnull @2, i32 %tmp2, i32 1, i64 8, i8* nonnull %tmp3, void (i8*, i8*)* nonnull @.omp.reduction.reduction_func, [8 x i32]* nonnull @.gomp_critical_user_.reduction.var) 370 switch i32 %tmp4, label %.omp.reduction.default [ 371 i32 1, label %.omp.reduction.case1 372 i32 2, label %.omp.reduction.case2 373 ] 374 375.omp.reduction.case1: ; preds = %entry 376 %tmp5 = load i32, i32* %a, align 4 377 %tmp6 = load i32, i32* %a1, align 4 378 %add = add nsw i32 %tmp5, %tmp6 379 store i32 %add, i32* %a, align 4 380 call void @__kmpc_end_reduce_nowait(%struct.ident_t* nonnull @2, i32 %tmp2, [8 x i32]* nonnull @.gomp_critical_user_.reduction.var) 381 br label %.omp.reduction.default 382 383.omp.reduction.case2: ; preds = %entry 384 %tmp7 = load i32, i32* %a1, align 4 385 %tmp8 = atomicrmw add i32* %a, i32 %tmp7 monotonic 386 br label %.omp.reduction.default 387 388.omp.reduction.default: ; preds = %.omp.reduction.case2, %.omp.reduction.case1, %entry 389 %tmp9 = bitcast i32* %a1 to i8* 390 call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %tmp9) 391 ret void 392} 393 394define internal void @.omp.reduction.reduction_func(i8* %arg, i8* %arg1) { 395; CHECK-LABEL: define {{[^@]+}}@.omp.reduction.reduction_func 396; CHECK-SAME: (i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG:%.*]], i8* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[ARG1:%.*]]) #{{[0-9]+}} 397; CHECK-NEXT: entry: 398; CHECK-NEXT: [[TMP:%.*]] = bitcast i8* [[ARG1]] to i32** 399; CHECK-NEXT: [[TMP2:%.*]] = load i32*, i32** [[TMP]], align 8 400; CHECK-NEXT: [[TMP3:%.*]] = bitcast i8* [[ARG]] to i32** 401; CHECK-NEXT: [[TMP4:%.*]] = load i32*, i32** [[TMP3]], align 8 402; CHECK-NEXT: [[TMP5:%.*]] = load i32, i32* [[TMP4]], align 4 403; CHECK-NEXT: [[TMP6:%.*]] = load i32, i32* [[TMP2]], align 4 404; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP5]], [[TMP6]] 405; CHECK-NEXT: store i32 [[ADD]], i32* [[TMP4]], align 4 406; CHECK-NEXT: ret void 407; 408entry: 409 %tmp = bitcast i8* %arg1 to i32** 410 %tmp2 = load i32*, i32** %tmp, align 8 411 %tmp3 = bitcast i8* %arg to i32** 412 %tmp4 = load i32*, i32** %tmp3, align 8 413 %tmp5 = load i32, i32* %tmp4, align 4 414 %tmp6 = load i32, i32* %tmp2, align 4 415 %add = add nsw i32 %tmp5, %tmp6 416 store i32 %add, i32* %tmp4, align 4 417 ret void 418} 419 420declare i32 @__kmpc_single(%struct.ident_t*, i32) 421 422declare void @__kmpc_end_single(%struct.ident_t*, i32) 423 424declare void @__kmpc_barrier(%struct.ident_t*, i32) 425 426declare i32 @__kmpc_global_thread_num(%struct.ident_t*) nofree nosync nounwind readonly 427 428declare i32 @__kmpc_reduce_nowait(%struct.ident_t*, i32, i32, i64, i8*, void (i8*, i8*)*, [8 x i32]*) 429 430declare void @__kmpc_end_reduce_nowait(%struct.ident_t*, i32, [8 x i32]*) 431 432declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) 433 434declare !callback !2 void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) 435 436declare void @unknown() 437 438declare void @readonly() readonly 439 440declare void @readnone() readnone 441 442!0 = !{i32 1, !"wchar_size", i32 4} 443!1 = !{!"clang"} 444!2 = !{!3} 445!3 = !{i64 2, i64 -1, i64 -1, i1 true} 446!4 = !{!5, !5, i64 0} 447!5 = !{!"int", !6, i64 0} 448!6 = !{!"omnipotent char", !7, i64 0} 449!7 = !{!"Simple C/C++ TBAA"} 450