425 lines · plain
1; RUN: llc -mtriple=powerpc64le -O0 < %s | FileCheck %s2; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff -O0 < %s | FileCheck %s --check-prefix=AIX3; RUN: llc -mtriple=powerpc-ibm-aix-xcoff -O0 < %s | FileCheck %s --check-prefix=AIX4 5; CHECK-LABEL: in_bounds:6; CHECK-NOT: __stack_chk_guard7; AIX-NOT: __ssp_canary_word8define i32 @in_bounds() #0 {9 %var = alloca i32, align 410 store i32 0, ptr %var, align 411 %ret = load i32, ptr %var, align 412 ret i32 %ret13}14 15; CHECK-LABEL: constant_out_of_bounds:16; CHECK: __stack_chk_guard17; AIX: __ssp_canary_word18define i32 @constant_out_of_bounds() #0 {19 %var = alloca i32, align 420 store i32 0, ptr %var, align 421 %gep = getelementptr inbounds i32, ptr %var, i32 122 %ret = load i32, ptr %gep, align 423 ret i32 %ret24}25 26; CHECK-LABEL: nonconstant_out_of_bounds:27; CHECK: __stack_chk_guard28; AIX: __ssp_canary_word29define i32 @nonconstant_out_of_bounds(i32 %n) #0 {30 %var = alloca i32, align 431 store i32 0, ptr %var, align 432 %gep = getelementptr inbounds i32, ptr %var, i32 %n33 %ret = load i32, ptr %gep, align 434 ret i32 %ret35}36 37; CHECK-LABEL: phi_before_gep_in_bounds:38; CHECK-NOT: __stack_chk_guard39; AIX-NOT: __ssp_canary_word40define i32 @phi_before_gep_in_bounds(i32 %k) #0 {41entry:42 %var1 = alloca i32, align 443 %var2 = alloca i32, align 444 store i32 0, ptr %var1, align 445 store i32 0, ptr %var2, align 446 %cmp = icmp ne i32 %k, 047 br i1 %cmp, label %if, label %then48 49if:50 br label %then51 52then:53 %ptr = phi ptr [ %var1, %entry ], [ %var2, %if ]54 %ret = load i32, ptr %ptr, align 455 ret i32 %ret56}57 58; CHECK-LABEL: phi_before_gep_constant_out_of_bounds:59; CHECK: __stack_chk_guard60; AIX: __ssp_canary_word61define i32 @phi_before_gep_constant_out_of_bounds(i32 %k) #0 {62entry:63 %var1 = alloca i32, align 464 %var2 = alloca i32, align 465 store i32 0, ptr %var1, align 466 store i32 0, ptr %var2, align 467 %cmp = icmp ne i32 %k, 068 br i1 %cmp, label %if, label %then69 70if:71 br label %then72 73then:74 %ptr = phi ptr [ %var1, %entry ], [ %var2, %if ]75 %gep = getelementptr inbounds i32, ptr %ptr, i32 176 %ret = load i32, ptr %gep, align 477 ret i32 %ret78}79 80; CHECK-LABEL: phi_before_gep_nonconstant_out_of_bounds:81; CHECK: __stack_chk_guard82; AIX: __ssp_canary_word83define i32 @phi_before_gep_nonconstant_out_of_bounds(i32 %k, i32 %n) #0 {84entry:85 %var1 = alloca i32, align 486 %var2 = alloca i32, align 487 store i32 0, ptr %var1, align 488 store i32 0, ptr %var2, align 489 %cmp = icmp ne i32 %k, 090 br i1 %cmp, label %if, label %then91 92if:93 br label %then94 95then:96 %ptr = phi ptr [ %var1, %entry ], [ %var2, %if ]97 %gep = getelementptr inbounds i32, ptr %ptr, i32 %n98 %ret = load i32, ptr %gep, align 499 ret i32 %ret100}101 102; CHECK-LABEL: phi_after_gep_in_bounds:103; CHECK-NOT: __stack_chk_guard104; AIX-NOT: __ssp_canary_word105define i32 @phi_after_gep_in_bounds(i32 %k) #0 {106entry:107 %var1 = alloca i32, align 4108 %var2 = alloca i32, align 4109 store i32 0, ptr %var1, align 4110 store i32 0, ptr %var2, align 4111 %cmp = icmp ne i32 %k, 0112 br i1 %cmp, label %if, label %else113 114if:115 br label %then116 117else:118 br label %then119 120then:121 %ptr = phi ptr [ %var1, %if ], [ %var2, %else ]122 %ret = load i32, ptr %ptr, align 4123 ret i32 %ret124}125 126; CHECK-LABEL: phi_after_gep_constant_out_of_bounds_a:127; CHECK: __stack_chk_guard128; AIX: __ssp_canary_word129define i32 @phi_after_gep_constant_out_of_bounds_a(i32 %k) #0 {130entry:131 %var1 = alloca i32, align 4132 %var2 = alloca i32, align 4133 store i32 0, ptr %var1, align 4134 store i32 0, ptr %var2, align 4135 %cmp = icmp ne i32 %k, 0136 br i1 %cmp, label %if, label %else137 138if:139 br label %then140 141else:142 %gep2 = getelementptr inbounds i32, ptr %var2, i32 1143 br label %then144 145then:146 %ptr = phi ptr [ %var1, %if ], [ %gep2, %else ]147 %ret = load i32, ptr %ptr, align 4148 ret i32 %ret149}150 151; CHECK-LABEL: phi_after_gep_constant_out_of_bounds_b:152; CHECK: __stack_chk_guard153; AIX: __ssp_canary_word154define i32 @phi_after_gep_constant_out_of_bounds_b(i32 %k) #0 {155entry:156 %var1 = alloca i32, align 4157 %var2 = alloca i32, align 4158 store i32 0, ptr %var1, align 4159 store i32 0, ptr %var2, align 4160 %cmp = icmp ne i32 %k, 0161 br i1 %cmp, label %if, label %else162 163if:164 %gep1 = getelementptr inbounds i32, ptr %var1, i32 1165 br label %then166 167else:168 br label %then169 170then:171 %ptr = phi ptr [ %gep1, %if ], [ %var2, %else ]172 %ret = load i32, ptr %ptr, align 4173 ret i32 %ret174}175 176; CHECK-LABEL: phi_different_types_a:177; CHECK: __stack_chk_guard178; AIX: __ssp_canary_word179define i64 @phi_different_types_a(i32 %k) #0 {180entry:181 %var1 = alloca i64, align 4182 %var2 = alloca i32, align 4183 store i64 0, ptr %var1, align 4184 store i32 0, ptr %var2, align 4185 %cmp = icmp ne i32 %k, 0186 br i1 %cmp, label %if, label %then187 188if:189 br label %then190 191then:192 %ptr = phi ptr [ %var1, %entry ], [ %var2, %if ]193 %ret = load i64, ptr %ptr, align 4194 ret i64 %ret195}196 197; CHECK-LABEL: phi_different_types_b:198; CHECK: __stack_chk_guard199; AIX: __ssp_canary_word200define i64 @phi_different_types_b(i32 %k) #0 {201entry:202 %var1 = alloca i32, align 4203 %var2 = alloca i64, align 4204 store i32 0, ptr %var1, align 4205 store i64 0, ptr %var2, align 4206 %cmp = icmp ne i32 %k, 0207 br i1 %cmp, label %if, label %then208 209if:210 br label %then211 212then:213 %ptr = phi ptr [ %var2, %entry ], [ %var1, %if ]214 %ret = load i64, ptr %ptr, align 4215 ret i64 %ret216}217 218; CHECK-LABEL: phi_after_gep_nonconstant_out_of_bounds_a:219; CHECK: __stack_chk_guard220; AIX: __ssp_canary_word221define i32 @phi_after_gep_nonconstant_out_of_bounds_a(i32 %k, i32 %n) #0 {222entry:223 %var1 = alloca i32, align 4224 %var2 = alloca i32, align 4225 store i32 0, ptr %var1, align 4226 store i32 0, ptr %var2, align 4227 %cmp = icmp ne i32 %k, 0228 br i1 %cmp, label %if, label %else229 230if:231 br label %then232 233else:234 %gep2 = getelementptr inbounds i32, ptr %var2, i32 %n235 br label %then236 237then:238 %ptr = phi ptr [ %var1, %if ], [ %gep2, %else ]239 %ret = load i32, ptr %ptr, align 4240 ret i32 %ret241}242 243; CHECK-LABEL: phi_after_gep_nonconstant_out_of_bounds_b:244; CHECK: __stack_chk_guard245; AIX: __ssp_canary_word246define i32 @phi_after_gep_nonconstant_out_of_bounds_b(i32 %k, i32 %n) #0 {247entry:248 %var1 = alloca i32, align 4249 %var2 = alloca i32, align 4250 store i32 0, ptr %var1, align 4251 store i32 0, ptr %var2, align 4252 %cmp = icmp ne i32 %k, 0253 br i1 %cmp, label %if, label %else254 255if:256 %gep1 = getelementptr inbounds i32, ptr %var1, i32 %n257 br label %then258 259else:260 br label %then261 262then:263 %ptr = phi ptr [ %gep1, %if ], [ %var2, %else ]264 %ret = load i32, ptr %ptr, align 4265 ret i32 %ret266}267 268%struct.outer = type { %struct.inner, %struct.inner }269%struct.inner = type { i32, i32 }270 271; CHECK-LABEL: struct_in_bounds:272; CHECK-NOT: __stack_chk_guard273; AIX-NOT: __ssp_canary_word274define void @struct_in_bounds() #0 {275 %var = alloca %struct.outer, align 4276 %outergep = getelementptr inbounds %struct.outer, ptr %var, i32 0, i32 1277 %innergep = getelementptr inbounds %struct.inner, ptr %outergep, i32 0, i32 1278 store i32 0, ptr %innergep, align 4279 ret void280}281 282; CHECK-LABEL: struct_constant_out_of_bounds_a:283; CHECK: __stack_chk_guard284; AIX: __ssp_canary_word285define void @struct_constant_out_of_bounds_a() #0 {286 %var = alloca %struct.outer, align 4287 %outergep = getelementptr inbounds %struct.outer, ptr %var, i32 1, i32 0288 store i32 0, ptr %outergep, align 4289 ret void290}291 292; CHECK-LABEL: struct_constant_out_of_bounds_b:293; Here the offset is out-of-bounds of the addressed struct.inner member, but294; still within bounds of the outer struct so no stack guard is needed.295; CHECK-NOT: __stack_chk_guard296; AIX-NOT: __ssp_canary_word297define void @struct_constant_out_of_bounds_b() #0 {298 %var = alloca %struct.outer, align 4299 %innergep = getelementptr inbounds %struct.inner, ptr %var, i32 1, i32 0300 store i32 0, ptr %innergep, align 4301 ret void302}303 304; CHECK-LABEL: struct_constant_out_of_bounds_c:305; Here we are out-of-bounds of both the inner and outer struct.306; CHECK: __stack_chk_guard307; AIX: __ssp_canary_word308define void @struct_constant_out_of_bounds_c() #0 {309 %var = alloca %struct.outer, align 4310 %outergep = getelementptr inbounds %struct.outer, ptr %var, i32 0, i32 1311 %innergep = getelementptr inbounds %struct.inner, ptr %outergep, i32 1, i32 0312 store i32 0, ptr %innergep, align 4313 ret void314}315 316; CHECK-LABEL: struct_nonconstant_out_of_bounds_a:317; CHECK: __stack_chk_guard318; AIX: __ssp_canary_word319define void @struct_nonconstant_out_of_bounds_a(i32 %n) #0 {320 %var = alloca %struct.outer, align 4321 %outergep = getelementptr inbounds %struct.outer, ptr %var, i32 %n, i32 0322 store i32 0, ptr %outergep, align 4323 ret void324}325 326; CHECK-LABEL: struct_nonconstant_out_of_bounds_b:327; CHECK: __stack_chk_guard328; AIX: __ssp_canary_word329define void @struct_nonconstant_out_of_bounds_b(i32 %n) #0 {330 %var = alloca %struct.outer, align 4331 %innergep = getelementptr inbounds %struct.inner, ptr %var, i32 %n, i32 0332 store i32 0, ptr %innergep, align 4333 ret void334}335 336; CHECK-LABEL: bitcast_smaller_load337; CHECK-NOT: __stack_chk_guard338; AIX-NOT: __ssp_canary_word339define i32 @bitcast_smaller_load() #0 {340 %var = alloca i64, align 4341 store i64 0, ptr %var, align 4342 %ret = load i32, ptr %var, align 4343 ret i32 %ret344}345 346; CHECK-LABEL: bitcast_same_size_load347; CHECK-NOT: __stack_chk_guard348; AIX-NOT: __ssp_canary_word349define i32 @bitcast_same_size_load() #0 {350 %var = alloca i64, align 4351 store i64 0, ptr %var, align 4352 %gep = getelementptr inbounds %struct.inner, ptr %var, i32 0, i32 1353 %ret = load i32, ptr %gep, align 4354 ret i32 %ret355}356 357; CHECK-LABEL: bitcast_larger_load358; CHECK: __stack_chk_guard359; AIX: __ssp_canary_word360define i64 @bitcast_larger_load() #0 {361 %var = alloca i32, align 4362 store i32 0, ptr %var, align 4363 %ret = load i64, ptr %var, align 4364 ret i64 %ret365}366 367; CHECK-LABEL: bitcast_larger_store368; CHECK: __stack_chk_guard369; AIX: __ssp_canary_word370define i32 @bitcast_larger_store() #0 {371 %var = alloca i32, align 4372 store i64 0, ptr %var, align 4373 %ret = load i32, ptr %var, align 4374 ret i32 %ret375}376 377; CHECK-LABEL: bitcast_larger_cmpxchg378; CHECK: __stack_chk_guard379; AIX: __ssp_canary_word380define i64 @bitcast_larger_cmpxchg(i64 %desired, i64 %new) #0 {381 %var = alloca i32, align 4382 %pair = cmpxchg ptr %var, i64 %desired, i64 %new seq_cst monotonic383 %ret = extractvalue { i64, i1 } %pair, 0384 ret i64 %ret385}386 387; CHECK-LABEL: bitcast_larger_atomic_rmw388; CHECK: __stack_chk_guard389; AIX: __ssp_canary_word390define i64 @bitcast_larger_atomic_rmw() #0 {391 %var = alloca i32, align 4392 %ret = atomicrmw add ptr %var, i64 1 monotonic393 ret i64 %ret394}395 396%struct.packed = type <{ i16, i32 }>397 398; CHECK-LABEL: bitcast_overlap399; CHECK: __stack_chk_guard400; AIX: __ssp_canary_word401define i32 @bitcast_overlap() #0 {402 %var = alloca i32, align 4403 %gep = getelementptr inbounds %struct.packed, ptr %var, i32 0, i32 1404 %ret = load i32, ptr %gep, align 2405 ret i32 %ret406}407 408%struct.multi_dimensional = type { [10 x [10 x i32]], i32 }409 410; CHECK-LABEL: multi_dimensional_array411; CHECK: __stack_chk_guard412; AIX: __ssp_canary_word413define i32 @multi_dimensional_array() #0 {414 %var = alloca %struct.multi_dimensional, align 4415 %gep2 = getelementptr inbounds [10 x [10 x i32]], ptr %var, i32 0, i32 10416 %gep3 = getelementptr inbounds [10 x i32], ptr %gep2, i32 0, i32 5417 %ret = load i32, ptr %gep3, align 4418 ret i32 %ret419}420 421attributes #0 = { sspstrong }422 423!llvm.module.flags = !{!0}424!0 = !{i32 7, !"direct-access-external-data", i32 1}425