1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes --check-attributes 2; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=9 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM 3; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=9 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM 4; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM 5; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM 6 7target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 8 9; Test cases specifically designed for "align" attribute. 10; We use FIXME's to indicate problems and missing attributes. 11 12 13; TEST 1 14define i32* @test1(i32* align 8 %0) #0 { 15; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn 16; IS__TUNIT____-LABEL: define {{[^@]+}}@test1 17; IS__TUNIT____-SAME: (i32* nofree readnone returned align 8 "no-capture-maybe-returned" [[TMP0:%.*]]) 18; IS__TUNIT____-NEXT: ret i32* [[TMP0]] 19; 20; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn 21; IS__CGSCC____-LABEL: define {{[^@]+}}@test1 22; IS__CGSCC____-SAME: (i32* nofree readnone returned align 8 "no-capture-maybe-returned" [[TMP0:%.*]]) 23; IS__CGSCC____-NEXT: ret i32* [[TMP0]] 24; 25 ret i32* %0 26} 27 28; TEST 2 29define i32* @test2(i32* %0) #0 { 30; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn 31; IS__TUNIT____-LABEL: define {{[^@]+}}@test2 32; IS__TUNIT____-SAME: (i32* nofree readnone returned "no-capture-maybe-returned" [[TMP0:%.*]]) 33; IS__TUNIT____-NEXT: ret i32* [[TMP0]] 34; 35; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn 36; IS__CGSCC____-LABEL: define {{[^@]+}}@test2 37; IS__CGSCC____-SAME: (i32* nofree readnone returned "no-capture-maybe-returned" [[TMP0:%.*]]) 38; IS__CGSCC____-NEXT: ret i32* [[TMP0]] 39; 40 ret i32* %0 41} 42 43; TEST 3 44define i32* @test3(i32* align 8 %0, i32* align 4 %1, i1 %2) #0 { 45; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn 46; IS__TUNIT____-LABEL: define {{[^@]+}}@test3 47; IS__TUNIT____-SAME: (i32* nofree readnone align 8 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 4 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) 48; IS__TUNIT____-NEXT: [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]] 49; IS__TUNIT____-NEXT: ret i32* [[RET]] 50; 51; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn 52; IS__CGSCC____-LABEL: define {{[^@]+}}@test3 53; IS__CGSCC____-SAME: (i32* nofree readnone align 8 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 4 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) 54; IS__CGSCC____-NEXT: [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]] 55; IS__CGSCC____-NEXT: ret i32* [[RET]] 56; 57 %ret = select i1 %2, i32* %0, i32* %1 58 ret i32* %ret 59} 60 61; TEST 4 62define i32* @test4(i32* align 32 %0, i32* align 32 %1, i1 %2) #0 { 63; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn 64; IS__TUNIT____-LABEL: define {{[^@]+}}@test4 65; IS__TUNIT____-SAME: (i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) 66; IS__TUNIT____-NEXT: [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]] 67; IS__TUNIT____-NEXT: ret i32* [[RET]] 68; 69; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn 70; IS__CGSCC____-LABEL: define {{[^@]+}}@test4 71; IS__CGSCC____-SAME: (i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP0:%.*]], i32* nofree readnone align 32 "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) 72; IS__CGSCC____-NEXT: [[RET:%.*]] = select i1 [[TMP2]], i32* [[TMP0]], i32* [[TMP1]] 73; IS__CGSCC____-NEXT: ret i32* [[RET]] 74; 75 %ret = select i1 %2, i32* %0, i32* %1 76 ret i32* %ret 77} 78 79; TEST 5 80declare i32* @unknown() 81declare align 8 i32* @align8() 82 83 84define i32* @test5_1() { 85; CHECK-LABEL: define {{[^@]+}}@test5_1() 86; CHECK-NEXT: [[RET:%.*]] = tail call align 8 i32* @unknown() 87; CHECK-NEXT: ret i32* [[RET]] 88; 89 %ret = tail call align 8 i32* @unknown() 90 ret i32* %ret 91} 92 93define i32* @test5_2() { 94; CHECK-LABEL: define {{[^@]+}}@test5_2() 95; CHECK-NEXT: [[RET:%.*]] = tail call align 8 i32* @align8() 96; CHECK-NEXT: ret i32* [[RET]] 97; 98 %ret = tail call i32* @align8() 99 ret i32* %ret 100} 101 102; TEST 6 103; SCC 104define i32* @test6_1() #0 { 105; NOT_CGSCC_NPM: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable 106; NOT_CGSCC_NPM-LABEL: define {{[^@]+}}@test6_1() 107; NOT_CGSCC_NPM-NEXT: unreachable 108; 109; IS__CGSCC_NPM: Function Attrs: nofree noinline norecurse noreturn nosync nounwind readnone uwtable willreturn 110; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test6_1() 111; IS__CGSCC_NPM-NEXT: unreachable 112; 113 %ret = tail call i32* @test6_2() 114 ret i32* %ret 115} 116 117define i32* @test6_2() #0 { 118; NOT_CGSCC_NPM: Function Attrs: nofree noinline noreturn nosync nounwind readnone uwtable 119; NOT_CGSCC_NPM-LABEL: define {{[^@]+}}@test6_2() 120; NOT_CGSCC_NPM-NEXT: unreachable 121; 122; IS__CGSCC_NPM: Function Attrs: nofree noinline norecurse noreturn nosync nounwind readnone uwtable willreturn 123; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test6_2() 124; IS__CGSCC_NPM-NEXT: unreachable 125; 126 %ret = tail call i32* @test6_1() 127 ret i32* %ret 128} 129 130 131; char a1 __attribute__((aligned(8))); 132; char a2 __attribute__((aligned(16))); 133; 134; char* f1(char* a ){ 135; return a?a:f2(&a1); 136; } 137; char* f2(char* a){ 138; return a?f1(a):f3(&a2); 139; } 140; 141; char* f3(char* a){ 142; return a?&a1: f1(&a2); 143; } 144 145@a1 = common global i8 0, align 8 146@a2 = common global i8 0, align 16 147 148; Function Attrs: nounwind readnone ssp uwtable 149define internal i8* @f1(i8* readnone %0) local_unnamed_addr #0 { 150; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn 151; IS__TUNIT____-LABEL: define {{[^@]+}}@f1 152; IS__TUNIT____-SAME: (i8* noalias nofree noundef nonnull readnone returned align 8 dereferenceable(1) "no-capture-maybe-returned" [[TMP0:%.*]]) local_unnamed_addr 153; IS__TUNIT____-NEXT: br label [[TMP3:%.*]] 154; IS__TUNIT____: 2: 155; IS__TUNIT____-NEXT: unreachable 156; IS__TUNIT____: 3: 157; IS__TUNIT____-NEXT: ret i8* [[TMP0]] 158; 159; IS__CGSCC_OPM: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn 160; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@f1 161; IS__CGSCC_OPM-SAME: (i8* nofree noundef nonnull readnone returned align 8 dereferenceable(1) "no-capture-maybe-returned" [[TMP0:%.*]]) local_unnamed_addr 162; IS__CGSCC_OPM-NEXT: br label [[TMP3:%.*]] 163; IS__CGSCC_OPM: 2: 164; IS__CGSCC_OPM-NEXT: unreachable 165; IS__CGSCC_OPM: 3: 166; IS__CGSCC_OPM-NEXT: ret i8* [[TMP0]] 167; 168; IS__CGSCC_NPM: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn 169; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@f1() local_unnamed_addr 170; IS__CGSCC_NPM-NEXT: br label [[TMP2:%.*]] 171; IS__CGSCC_NPM: 1: 172; IS__CGSCC_NPM-NEXT: unreachable 173; IS__CGSCC_NPM: 2: 174; IS__CGSCC_NPM-NEXT: ret i8* @a1 175; 176 %2 = icmp eq i8* %0, null 177 br i1 %2, label %3, label %5 178 179; <label>:3: ; preds = %1 180 %4 = tail call i8* @f2(i8* nonnull @a1) 181 %l = load i8, i8* %4 182 br label %5 183 184; <label>:5: ; preds = %1, %3 185 %6 = phi i8* [ %4, %3 ], [ %0, %1 ] 186 ret i8* %6 187} 188 189; Function Attrs: nounwind readnone ssp uwtable 190define internal i8* @f2(i8* readnone %0) local_unnamed_addr #0 { 191 %2 = icmp eq i8* %0, null 192 br i1 %2, label %5, label %3 193 194; <label>:3: ; preds = %1 195 196 %4 = tail call i8* @f1(i8* nonnull %0) 197 br label %7 198 199; <label>:5: ; preds = %1 200 %6 = tail call i8* @f3(i8* nonnull @a2) 201 br label %7 202 203; <label>:7: ; preds = %5, %3 204 %8 = phi i8* [ %4, %3 ], [ %6, %5 ] 205 ret i8* %8 206} 207 208; Function Attrs: nounwind readnone ssp uwtable 209define internal i8* @f3(i8* readnone %0) local_unnamed_addr #0 { 210 %2 = icmp eq i8* %0, null 211 br i1 %2, label %3, label %5 212 213; <label>:3: ; preds = %1 214 %4 = tail call i8* @f1(i8* nonnull @a2) 215 br label %5 216 217; <label>:5: ; preds = %1, %3 218 %6 = phi i8* [ %4, %3 ], [ @a1, %1 ] 219 ret i8* %6 220} 221 222; TEST 7 223; Better than IR information 224define align 4 i8* @test7() #0 { 225; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn 226; IS__TUNIT____-LABEL: define {{[^@]+}}@test7() 227; IS__TUNIT____-NEXT: [[C:%.*]] = tail call i8* @f1(i8* noalias nofree noundef nonnull readnone align 8 dereferenceable(1) "no-capture-maybe-returned" @a1) 228; IS__TUNIT____-NEXT: ret i8* [[C]] 229; 230; IS__CGSCC_OPM: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn 231; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@test7() 232; IS__CGSCC_OPM-NEXT: [[C:%.*]] = tail call i8* @f1(i8* noalias nofree noundef nonnull readnone align 8 dereferenceable(1) @a1) 233; IS__CGSCC_OPM-NEXT: ret i8* [[C]] 234; 235; IS__CGSCC_NPM: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn 236; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@test7() 237; IS__CGSCC_NPM-NEXT: [[C:%.*]] = tail call noundef nonnull align 8 dereferenceable(1) i8* @f1() 238; IS__CGSCC_NPM-NEXT: ret i8* [[C]] 239; 240 %c = tail call i8* @f1(i8* align 8 dereferenceable(1) @a1) 241 ret i8* %c 242} 243 244; TEST 7b 245; Function Attrs: nounwind readnone ssp uwtable 246define internal i8* @f1b(i8* readnone %0) local_unnamed_addr #0 { 247; IS__CGSCC_OPM: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn 248; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@f1b 249; IS__CGSCC_OPM-SAME: (i8* nofree noundef nonnull readnone returned align 8 dereferenceable(1) "no-capture-maybe-returned" [[TMP0:%.*]]) local_unnamed_addr 250; IS__CGSCC_OPM-NEXT: br label [[TMP3:%.*]] 251; IS__CGSCC_OPM: 2: 252; IS__CGSCC_OPM-NEXT: unreachable 253; IS__CGSCC_OPM: 3: 254; IS__CGSCC_OPM-NEXT: ret i8* [[TMP0]] 255; 256; IS__CGSCC_NPM: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn 257; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@f1b() local_unnamed_addr 258; IS__CGSCC_NPM-NEXT: br label [[TMP2:%.*]] 259; IS__CGSCC_NPM: 1: 260; IS__CGSCC_NPM-NEXT: unreachable 261; IS__CGSCC_NPM: 2: 262; IS__CGSCC_NPM-NEXT: ret i8* undef 263; 264 %2 = icmp eq i8* %0, null 265 br i1 %2, label %3, label %5 266 267; <label>:3: ; preds = %1 268 %4 = tail call i8* @f2b(i8* nonnull @a1) 269 %l = load i8, i8* %4 270 store i8 %l, i8* @a1 271 br label %5 272 273; <label>:5: ; preds = %1, %3 274 %6 = phi i8* [ %4, %3 ], [ %0, %1 ] 275 ret i8* %6 276} 277 278; Function Attrs: nounwind readnone ssp uwtable 279define internal i8* @f2b(i8* readnone %0) local_unnamed_addr #0 { 280; 281 %2 = icmp eq i8* %0, null 282 br i1 %2, label %5, label %3 283 284; <label>:3: ; preds = %1 285 286 %4 = tail call i8* @f1b(i8* nonnull %0) 287 br label %7 288 289; <label>:5: ; preds = %1 290 %6 = tail call i8* @f3b(i8* nonnull @a2) 291 br label %7 292 293; <label>:7: ; preds = %5, %3 294 %8 = phi i8* [ %4, %3 ], [ %6, %5 ] 295 ret i8* %8 296} 297 298; Function Attrs: nounwind readnone ssp uwtable 299define internal i8* @f3b(i8* readnone %0) local_unnamed_addr #0 { 300; 301 %2 = icmp eq i8* %0, null 302 br i1 %2, label %3, label %5 303 304; <label>:3: ; preds = %1 305 %4 = tail call i8* @f1b(i8* nonnull @a2) 306 br label %5 307 308; <label>:5: ; preds = %1, %3 309 %6 = phi i8* [ %4, %3 ], [ @a1, %1 ] 310 ret i8* %6 311} 312 313define align 4 i32* @test7b(i32* align 32 %p) #0 { 314; IS__TUNIT____: Function Attrs: nofree noinline nosync nounwind readnone uwtable willreturn 315; IS__TUNIT____-LABEL: define {{[^@]+}}@test7b 316; IS__TUNIT____-SAME: (i32* nofree readnone returned align 32 "no-capture-maybe-returned" [[P:%.*]]) 317; IS__TUNIT____-NEXT: ret i32* [[P]] 318; 319; IS__CGSCC____: Function Attrs: nofree noinline norecurse nosync nounwind readnone uwtable willreturn 320; IS__CGSCC____-LABEL: define {{[^@]+}}@test7b 321; IS__CGSCC____-SAME: (i32* nofree readnone returned align 32 "no-capture-maybe-returned" [[P:%.*]]) 322; IS__CGSCC____-NEXT: ret i32* [[P]] 323; 324 tail call i8* @f1b(i8* align 8 dereferenceable(1) @a1) 325 ret i32* %p 326} 327 328; TEST 8 329define void @test8_helper() { 330; CHECK-LABEL: define {{[^@]+}}@test8_helper() 331; CHECK-NEXT: [[PTR0:%.*]] = tail call i32* @unknown() 332; CHECK-NEXT: [[PTR1:%.*]] = tail call align 4 i32* @unknown() 333; CHECK-NEXT: [[PTR2:%.*]] = tail call align 8 i32* @unknown() 334; CHECK-NEXT: tail call void @test8(i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone [[PTR0]]) 335; CHECK-NEXT: tail call void @test8(i32* noalias nocapture readnone align 8 [[PTR2]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]]) 336; CHECK-NEXT: tail call void @test8(i32* noalias nocapture readnone align 8 [[PTR2]], i32* noalias nocapture readnone align 4 [[PTR1]], i32* noalias nocapture readnone align 4 [[PTR1]]) 337; CHECK-NEXT: ret void 338; 339 %ptr0 = tail call i32* @unknown() 340 %ptr1 = tail call align 4 i32* @unknown() 341 %ptr2 = tail call align 8 i32* @unknown() 342 343 tail call void @test8(i32* %ptr1, i32* %ptr1, i32* %ptr0) 344 tail call void @test8(i32* %ptr2, i32* %ptr1, i32* %ptr1) 345 tail call void @test8(i32* %ptr2, i32* %ptr1, i32* %ptr1) 346 ret void 347} 348 349declare void @user_i32_ptr(i32* nocapture readnone) nounwind 350define internal void @test8(i32* %a, i32* %b, i32* %c) { 351; IS__TUNIT____: Function Attrs: nounwind 352; IS__TUNIT____-LABEL: define {{[^@]+}}@test8 353; IS__TUNIT____-SAME: (i32* noalias nocapture readnone align 4 [[A:%.*]], i32* noalias nocapture readnone align 4 [[B:%.*]], i32* noalias nocapture readnone [[C:%.*]]) 354; IS__TUNIT____-NEXT: call void @user_i32_ptr(i32* noalias nocapture readnone align 4 [[A]]) 355; IS__TUNIT____-NEXT: call void @user_i32_ptr(i32* noalias nocapture readnone align 4 [[B]]) 356; IS__TUNIT____-NEXT: call void @user_i32_ptr(i32* noalias nocapture readnone [[C]]) 357; IS__TUNIT____-NEXT: ret void 358; 359; IS__CGSCC____: Function Attrs: nounwind 360; IS__CGSCC____-LABEL: define {{[^@]+}}@test8 361; IS__CGSCC____-SAME: (i32* nocapture readnone align 4 [[A:%.*]], i32* nocapture readnone align 4 [[B:%.*]], i32* nocapture readnone [[C:%.*]]) 362; IS__CGSCC____-NEXT: call void @user_i32_ptr(i32* noalias nocapture readnone align 4 [[A]]) 363; IS__CGSCC____-NEXT: call void @user_i32_ptr(i32* noalias nocapture readnone align 4 [[B]]) 364; IS__CGSCC____-NEXT: call void @user_i32_ptr(i32* noalias nocapture readnone [[C]]) 365; IS__CGSCC____-NEXT: ret void 366; 367 call void @user_i32_ptr(i32* %a) 368 call void @user_i32_ptr(i32* %b) 369 call void @user_i32_ptr(i32* %c) 370 ret void 371} 372 373declare void @test9_helper(i32* %A) 374define void @test9_traversal(i1 %cnd, i32* align 4 %B, i32* align 8 %C) { 375; CHECK-LABEL: define {{[^@]+}}@test9_traversal 376; CHECK-SAME: (i1 [[CND:%.*]], i32* align 4 [[B:%.*]], i32* align 8 [[C:%.*]]) 377; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CND]], i32* [[B]], i32* [[C]] 378; CHECK-NEXT: call void @test9_helper(i32* align 4 [[SEL]]) 379; CHECK-NEXT: ret void 380; 381 %sel = select i1 %cnd, i32* %B, i32* %C 382 call void @test9_helper(i32* %sel) 383 ret void 384} 385 386; FIXME: This will work with an upcoming patch (D66618 or similar) 387; define align 32 i32* @test10a(i32* align 32 "no-capture-maybe-returned" %p) 388; FIXME: This will work with an upcoming patch (D66618 or similar) 389; store i32 1, i32* %r, align 32 390; FIXME: This will work with an upcoming patch (D66618 or similar) 391; store i32 -1, i32* %g1, align 32 392define i32* @test10a(i32* align 32 %p) { 393; CHECK: Function Attrs: nofree nosync nounwind 394; CHECK-LABEL: define {{[^@]+}}@test10a 395; CHECK-SAME: (i32* nofree nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P:%.*]]) 396; CHECK-NEXT: [[L:%.*]] = load i32, i32* [[P]], align 32 397; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[L]], 0 398; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]] 399; CHECK: t: 400; CHECK-NEXT: [[R:%.*]] = call i32* @test10a(i32* nofree nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P]]) 401; CHECK-NEXT: store i32 1, i32* [[R]], align 4 402; CHECK-NEXT: [[G0:%.*]] = getelementptr i32, i32* [[P]], i32 8 403; CHECK-NEXT: br label [[E:%.*]] 404; CHECK: f: 405; CHECK-NEXT: [[G1:%.*]] = getelementptr i32, i32* [[P]], i32 8 406; CHECK-NEXT: store i32 -1, i32* [[G1]], align 4 407; CHECK-NEXT: br label [[E]] 408; CHECK: e: 409; CHECK-NEXT: [[PHI:%.*]] = phi i32* [ [[G0]], [[T]] ], [ [[G1]], [[F]] ] 410; CHECK-NEXT: ret i32* [[PHI]] 411; 412 %l = load i32, i32* %p 413 %c = icmp eq i32 %l, 0 414 br i1 %c, label %t, label %f 415t: 416 %r = call i32* @test10a(i32* %p) 417 store i32 1, i32* %r 418 %g0 = getelementptr i32, i32* %p, i32 8 419 br label %e 420f: 421 %g1 = getelementptr i32, i32* %p, i32 8 422 store i32 -1, i32* %g1 423 br label %e 424e: 425 %phi = phi i32* [%g0, %t], [%g1, %f] 426 ret i32* %phi 427} 428 429; FIXME: This will work with an upcoming patch (D66618 or similar) 430; define align 32 i32* @test10b(i32* align 32 "no-capture-maybe-returned" %p) 431; FIXME: This will work with an upcoming patch (D66618 or similar) 432; store i32 1, i32* %r, align 32 433; FIXME: This will work with an upcoming patch (D66618 or similar) 434; store i32 -1, i32* %g1, align 32 435define i32* @test10b(i32* align 32 %p) { 436; CHECK: Function Attrs: nofree nosync nounwind 437; CHECK-LABEL: define {{[^@]+}}@test10b 438; CHECK-SAME: (i32* nofree nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P:%.*]]) 439; CHECK-NEXT: [[L:%.*]] = load i32, i32* [[P]], align 32 440; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[L]], 0 441; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]] 442; CHECK: t: 443; CHECK-NEXT: [[R:%.*]] = call i32* @test10b(i32* nofree nonnull align 32 dereferenceable(4) "no-capture-maybe-returned" [[P]]) 444; CHECK-NEXT: store i32 1, i32* [[R]], align 4 445; CHECK-NEXT: [[G0:%.*]] = getelementptr i32, i32* [[P]], i32 8 446; CHECK-NEXT: br label [[E:%.*]] 447; CHECK: f: 448; CHECK-NEXT: [[G1:%.*]] = getelementptr i32, i32* [[P]], i32 -8 449; CHECK-NEXT: store i32 -1, i32* [[G1]], align 4 450; CHECK-NEXT: br label [[E]] 451; CHECK: e: 452; CHECK-NEXT: [[PHI:%.*]] = phi i32* [ [[G0]], [[T]] ], [ [[G1]], [[F]] ] 453; CHECK-NEXT: ret i32* [[PHI]] 454; 455 %l = load i32, i32* %p 456 %c = icmp eq i32 %l, 0 457 br i1 %c, label %t, label %f 458t: 459 %r = call i32* @test10b(i32* %p) 460 store i32 1, i32* %r 461 %g0 = getelementptr i32, i32* %p, i32 8 462 br label %e 463f: 464 %g1 = getelementptr i32, i32* %p, i32 -8 465 store i32 -1, i32* %g1 466 br label %e 467e: 468 %phi = phi i32* [%g0, %t], [%g1, %f] 469 ret i32* %phi 470} 471 472 473define i64 @test11(i32* %p) { 474; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn 475; IS__TUNIT____-LABEL: define {{[^@]+}}@test11 476; IS__TUNIT____-SAME: (i32* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[P:%.*]]) 477; IS__TUNIT____-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 478; IS__TUNIT____-NEXT: [[RET:%.*]] = load i64, i64* [[P_CAST]], align 8 479; IS__TUNIT____-NEXT: ret i64 [[RET]] 480; 481; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn 482; IS__CGSCC____-LABEL: define {{[^@]+}}@test11 483; IS__CGSCC____-SAME: (i32* nocapture nofree nonnull readonly align 8 dereferenceable(8) [[P:%.*]]) 484; IS__CGSCC____-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 485; IS__CGSCC____-NEXT: [[RET:%.*]] = load i64, i64* [[P_CAST]], align 8 486; IS__CGSCC____-NEXT: ret i64 [[RET]] 487; 488 %p-cast = bitcast i32* %p to i64* 489 %ret = load i64, i64* %p-cast, align 8 490 ret i64 %ret 491} 492 493; TEST 12 494; Test for deduction using must-be-executed-context and GEP instruction 495 496; FXIME: %p should have nonnull 497define i64 @test12-1(i32* align 4 %p) { 498; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn 499; IS__TUNIT____-LABEL: define {{[^@]+}}@test12-1 500; IS__TUNIT____-SAME: (i32* nocapture nofree readonly align 16 [[P:%.*]]) 501; IS__TUNIT____-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 502; IS__TUNIT____-NEXT: [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1 503; IS__TUNIT____-NEXT: [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3 504; IS__TUNIT____-NEXT: [[RET:%.*]] = load i64, i64* [[ARRAYIDX1]], align 16 505; IS__TUNIT____-NEXT: ret i64 [[RET]] 506; 507; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn 508; IS__CGSCC____-LABEL: define {{[^@]+}}@test12-1 509; IS__CGSCC____-SAME: (i32* nocapture nofree readonly align 16 [[P:%.*]]) 510; IS__CGSCC____-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 511; IS__CGSCC____-NEXT: [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1 512; IS__CGSCC____-NEXT: [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3 513; IS__CGSCC____-NEXT: [[RET:%.*]] = load i64, i64* [[ARRAYIDX1]], align 16 514; IS__CGSCC____-NEXT: ret i64 [[RET]] 515; 516 %p-cast = bitcast i32* %p to i64* 517 %arrayidx0 = getelementptr i64, i64* %p-cast, i64 1 518 %arrayidx1 = getelementptr i64, i64* %arrayidx0, i64 3 519 %ret = load i64, i64* %arrayidx1, align 16 520 ret i64 %ret 521} 522 523define i64 @test12-2(i32* align 4 %p) { 524; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn 525; IS__TUNIT____-LABEL: define {{[^@]+}}@test12-2 526; IS__TUNIT____-SAME: (i32* nocapture nofree nonnull readonly align 16 dereferenceable(8) [[P:%.*]]) 527; IS__TUNIT____-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 528; IS__TUNIT____-NEXT: [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0 529; IS__TUNIT____-NEXT: [[RET:%.*]] = load i64, i64* [[ARRAYIDX0]], align 16 530; IS__TUNIT____-NEXT: ret i64 [[RET]] 531; 532; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn 533; IS__CGSCC____-LABEL: define {{[^@]+}}@test12-2 534; IS__CGSCC____-SAME: (i32* nocapture nofree nonnull readonly align 16 dereferenceable(8) [[P:%.*]]) 535; IS__CGSCC____-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 536; IS__CGSCC____-NEXT: [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0 537; IS__CGSCC____-NEXT: [[RET:%.*]] = load i64, i64* [[ARRAYIDX0]], align 16 538; IS__CGSCC____-NEXT: ret i64 [[RET]] 539; 540 %p-cast = bitcast i32* %p to i64* 541 %arrayidx0 = getelementptr i64, i64* %p-cast, i64 0 542 %ret = load i64, i64* %arrayidx0, align 16 543 ret i64 %ret 544} 545 546; FXIME: %p should have nonnull 547define void @test12-3(i32* align 4 %p) { 548; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly 549; IS__TUNIT____-LABEL: define {{[^@]+}}@test12-3 550; IS__TUNIT____-SAME: (i32* nocapture nofree writeonly align 16 [[P:%.*]]) 551; IS__TUNIT____-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 552; IS__TUNIT____-NEXT: [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1 553; IS__TUNIT____-NEXT: [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3 554; IS__TUNIT____-NEXT: store i64 0, i64* [[ARRAYIDX1]], align 16 555; IS__TUNIT____-NEXT: ret void 556; 557; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly 558; IS__CGSCC____-LABEL: define {{[^@]+}}@test12-3 559; IS__CGSCC____-SAME: (i32* nocapture nofree writeonly align 16 [[P:%.*]]) 560; IS__CGSCC____-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 561; IS__CGSCC____-NEXT: [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1 562; IS__CGSCC____-NEXT: [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3 563; IS__CGSCC____-NEXT: store i64 0, i64* [[ARRAYIDX1]], align 16 564; IS__CGSCC____-NEXT: ret void 565; 566 %p-cast = bitcast i32* %p to i64* 567 %arrayidx0 = getelementptr i64, i64* %p-cast, i64 1 568 %arrayidx1 = getelementptr i64, i64* %arrayidx0, i64 3 569 store i64 0, i64* %arrayidx1, align 16 570 ret void 571} 572 573define void @test12-4(i32* align 4 %p) { 574; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly 575; IS__TUNIT____-LABEL: define {{[^@]+}}@test12-4 576; IS__TUNIT____-SAME: (i32* nocapture nofree nonnull writeonly align 16 dereferenceable(8) [[P:%.*]]) 577; IS__TUNIT____-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 578; IS__TUNIT____-NEXT: [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0 579; IS__TUNIT____-NEXT: store i64 0, i64* [[ARRAYIDX0]], align 16 580; IS__TUNIT____-NEXT: ret void 581; 582; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly 583; IS__CGSCC____-LABEL: define {{[^@]+}}@test12-4 584; IS__CGSCC____-SAME: (i32* nocapture nofree nonnull writeonly align 16 dereferenceable(8) [[P:%.*]]) 585; IS__CGSCC____-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 586; IS__CGSCC____-NEXT: [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0 587; IS__CGSCC____-NEXT: store i64 0, i64* [[ARRAYIDX0]], align 16 588; IS__CGSCC____-NEXT: ret void 589; 590 %p-cast = bitcast i32* %p to i64* 591 %arrayidx0 = getelementptr i64, i64* %p-cast, i64 0 592 store i64 0, i64* %arrayidx0, align 16 593 ret void 594} 595 596declare void @use(i64*) willreturn nounwind 597 598define void @test12-5(i32* align 4 %p) { 599; CHECK: Function Attrs: nounwind willreturn 600; CHECK-LABEL: define {{[^@]+}}@test12-5 601; CHECK-SAME: (i32* align 16 [[P:%.*]]) 602; CHECK-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 603; CHECK-NEXT: [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 1 604; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr i64, i64* [[ARRAYIDX0]], i64 3 605; CHECK-NEXT: tail call void @use(i64* align 16 [[ARRAYIDX1]]) 606; CHECK-NEXT: ret void 607; 608 %p-cast = bitcast i32* %p to i64* 609 %arrayidx0 = getelementptr i64, i64* %p-cast, i64 1 610 %arrayidx1 = getelementptr i64, i64* %arrayidx0, i64 3 611 tail call void @use(i64* align 16 %arrayidx1) 612 ret void 613} 614 615define void @test12-6(i32* align 4 %p) { 616; CHECK: Function Attrs: nounwind willreturn 617; CHECK-LABEL: define {{[^@]+}}@test12-6 618; CHECK-SAME: (i32* align 16 [[P:%.*]]) 619; CHECK-NEXT: [[P_CAST:%.*]] = bitcast i32* [[P]] to i64* 620; CHECK-NEXT: [[ARRAYIDX0:%.*]] = getelementptr i64, i64* [[P_CAST]], i64 0 621; CHECK-NEXT: tail call void @use(i64* align 16 [[ARRAYIDX0]]) 622; CHECK-NEXT: ret void 623; 624 %p-cast = bitcast i32* %p to i64* 625 %arrayidx0 = getelementptr i64, i64* %p-cast, i64 0 626 tail call void @use(i64* align 16 %arrayidx0) 627 ret void 628} 629 630define void @test13(i1 %c, i32* align 32 %dst) #0 { 631; IS__TUNIT____: Function Attrs: argmemonly nofree noinline nosync nounwind uwtable willreturn writeonly 632; IS__TUNIT____-LABEL: define {{[^@]+}}@test13 633; IS__TUNIT____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) 634; IS__TUNIT____-NEXT: br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]] 635; IS__TUNIT____: truebb: 636; IS__TUNIT____-NEXT: br label [[END:%.*]] 637; IS__TUNIT____: falsebb: 638; IS__TUNIT____-NEXT: br label [[END]] 639; IS__TUNIT____: end: 640; IS__TUNIT____-NEXT: [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ null, [[FALSEBB]] ] 641; IS__TUNIT____-NEXT: store i32 0, i32* [[PTR]], align 32 642; IS__TUNIT____-NEXT: ret void 643; 644; IS__CGSCC____: Function Attrs: argmemonly nofree noinline norecurse nosync nounwind uwtable willreturn writeonly 645; IS__CGSCC____-LABEL: define {{[^@]+}}@test13 646; IS__CGSCC____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) 647; IS__CGSCC____-NEXT: br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]] 648; IS__CGSCC____: truebb: 649; IS__CGSCC____-NEXT: br label [[END:%.*]] 650; IS__CGSCC____: falsebb: 651; IS__CGSCC____-NEXT: br label [[END]] 652; IS__CGSCC____: end: 653; IS__CGSCC____-NEXT: [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ null, [[FALSEBB]] ] 654; IS__CGSCC____-NEXT: store i32 0, i32* [[PTR]], align 32 655; IS__CGSCC____-NEXT: ret void 656; 657 br i1 %c, label %truebb, label %falsebb 658truebb: 659 br label %end 660falsebb: 661 br label %end 662end: 663 %ptr = phi i32* [ %dst, %truebb ], [ null, %falsebb ] 664 store i32 0, i32* %ptr 665 ret void 666} 667 668define void @test13-1(i1 %c, i32* align 32 %dst) { 669; IS__TUNIT____: Function Attrs: nofree nosync nounwind willreturn writeonly 670; IS__TUNIT____-LABEL: define {{[^@]+}}@test13-1 671; IS__TUNIT____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) 672; IS__TUNIT____-NEXT: br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]] 673; IS__TUNIT____: truebb: 674; IS__TUNIT____-NEXT: br label [[END:%.*]] 675; IS__TUNIT____: falsebb: 676; IS__TUNIT____-NEXT: br label [[END]] 677; IS__TUNIT____: end: 678; IS__TUNIT____-NEXT: [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 48 to i32*), [[FALSEBB]] ] 679; IS__TUNIT____-NEXT: store i32 0, i32* [[PTR]], align 16 680; IS__TUNIT____-NEXT: ret void 681; 682; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly 683; IS__CGSCC____-LABEL: define {{[^@]+}}@test13-1 684; IS__CGSCC____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) 685; IS__CGSCC____-NEXT: br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]] 686; IS__CGSCC____: truebb: 687; IS__CGSCC____-NEXT: br label [[END:%.*]] 688; IS__CGSCC____: falsebb: 689; IS__CGSCC____-NEXT: br label [[END]] 690; IS__CGSCC____: end: 691; IS__CGSCC____-NEXT: [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 48 to i32*), [[FALSEBB]] ] 692; IS__CGSCC____-NEXT: store i32 0, i32* [[PTR]], align 16 693; IS__CGSCC____-NEXT: ret void 694; 695 br i1 %c, label %truebb, label %falsebb 696truebb: 697 br label %end 698falsebb: 699 br label %end 700end: 701 %ptr = phi i32* [ %dst, %truebb ], [ inttoptr (i64 48 to i32*), %falsebb ] 702 store i32 0, i32* %ptr 703 ret void 704} 705 706define void @test13-2(i1 %c, i32* align 32 %dst) { 707; IS__TUNIT____: Function Attrs: nofree nosync nounwind willreturn writeonly 708; IS__TUNIT____-LABEL: define {{[^@]+}}@test13-2 709; IS__TUNIT____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) 710; IS__TUNIT____-NEXT: br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]] 711; IS__TUNIT____: truebb: 712; IS__TUNIT____-NEXT: br label [[END:%.*]] 713; IS__TUNIT____: falsebb: 714; IS__TUNIT____-NEXT: br label [[END]] 715; IS__TUNIT____: end: 716; IS__TUNIT____-NEXT: [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 160 to i32*), [[FALSEBB]] ] 717; IS__TUNIT____-NEXT: store i32 0, i32* [[PTR]], align 32 718; IS__TUNIT____-NEXT: ret void 719; 720; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly 721; IS__CGSCC____-LABEL: define {{[^@]+}}@test13-2 722; IS__CGSCC____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) 723; IS__CGSCC____-NEXT: br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]] 724; IS__CGSCC____: truebb: 725; IS__CGSCC____-NEXT: br label [[END:%.*]] 726; IS__CGSCC____: falsebb: 727; IS__CGSCC____-NEXT: br label [[END]] 728; IS__CGSCC____: end: 729; IS__CGSCC____-NEXT: [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 160 to i32*), [[FALSEBB]] ] 730; IS__CGSCC____-NEXT: store i32 0, i32* [[PTR]], align 32 731; IS__CGSCC____-NEXT: ret void 732; 733 br i1 %c, label %truebb, label %falsebb 734truebb: 735 br label %end 736falsebb: 737 br label %end 738end: 739 %ptr = phi i32* [ %dst, %truebb ], [ inttoptr (i64 160 to i32*), %falsebb ] 740 store i32 0, i32* %ptr 741 ret void 742} 743 744define void @test13-3(i1 %c, i32* align 32 %dst) { 745; IS__TUNIT____: Function Attrs: nofree nosync nounwind willreturn writeonly 746; IS__TUNIT____-LABEL: define {{[^@]+}}@test13-3 747; IS__TUNIT____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) 748; IS__TUNIT____-NEXT: br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]] 749; IS__TUNIT____: truebb: 750; IS__TUNIT____-NEXT: br label [[END:%.*]] 751; IS__TUNIT____: falsebb: 752; IS__TUNIT____-NEXT: br label [[END]] 753; IS__TUNIT____: end: 754; IS__TUNIT____-NEXT: [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 128 to i32*), [[FALSEBB]] ] 755; IS__TUNIT____-NEXT: store i32 0, i32* [[PTR]], align 32 756; IS__TUNIT____-NEXT: ret void 757; 758; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind willreturn writeonly 759; IS__CGSCC____-LABEL: define {{[^@]+}}@test13-3 760; IS__CGSCC____-SAME: (i1 [[C:%.*]], i32* nocapture nofree writeonly align 32 [[DST:%.*]]) 761; IS__CGSCC____-NEXT: br i1 [[C]], label [[TRUEBB:%.*]], label [[FALSEBB:%.*]] 762; IS__CGSCC____: truebb: 763; IS__CGSCC____-NEXT: br label [[END:%.*]] 764; IS__CGSCC____: falsebb: 765; IS__CGSCC____-NEXT: br label [[END]] 766; IS__CGSCC____: end: 767; IS__CGSCC____-NEXT: [[PTR:%.*]] = phi i32* [ [[DST]], [[TRUEBB]] ], [ inttoptr (i64 128 to i32*), [[FALSEBB]] ] 768; IS__CGSCC____-NEXT: store i32 0, i32* [[PTR]], align 32 769; IS__CGSCC____-NEXT: ret void 770; 771 br i1 %c, label %truebb, label %falsebb 772truebb: 773 br label %end 774falsebb: 775 br label %end 776end: 777 %ptr = phi i32* [ %dst, %truebb ], [ inttoptr (i64 128 to i32*), %falsebb ] 778 store i32 0, i32* %ptr 779 ret void 780} 781 782; Don't crash on ptr2int/int2ptr uses. 783define i64 @ptr2int(i32* %p) { 784; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn 785; IS__TUNIT____-LABEL: define {{[^@]+}}@ptr2int 786; IS__TUNIT____-SAME: (i32* nofree readnone [[P:%.*]]) 787; IS__TUNIT____-NEXT: [[P2I:%.*]] = ptrtoint i32* [[P]] to i64 788; IS__TUNIT____-NEXT: ret i64 [[P2I]] 789; 790; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn 791; IS__CGSCC____-LABEL: define {{[^@]+}}@ptr2int 792; IS__CGSCC____-SAME: (i32* nofree readnone [[P:%.*]]) 793; IS__CGSCC____-NEXT: [[P2I:%.*]] = ptrtoint i32* [[P]] to i64 794; IS__CGSCC____-NEXT: ret i64 [[P2I]] 795; 796 %p2i = ptrtoint i32* %p to i64 797 ret i64 %p2i 798} 799define i64* @int2ptr(i64 %i) { 800; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn 801; IS__TUNIT____-LABEL: define {{[^@]+}}@int2ptr 802; IS__TUNIT____-SAME: (i64 [[I:%.*]]) 803; IS__TUNIT____-NEXT: [[I2P:%.*]] = inttoptr i64 [[I]] to i64* 804; IS__TUNIT____-NEXT: ret i64* [[I2P]] 805; 806; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn 807; IS__CGSCC____-LABEL: define {{[^@]+}}@int2ptr 808; IS__CGSCC____-SAME: (i64 [[I:%.*]]) 809; IS__CGSCC____-NEXT: [[I2P:%.*]] = inttoptr i64 [[I]] to i64* 810; IS__CGSCC____-NEXT: ret i64* [[I2P]] 811; 812 %i2p = inttoptr i64 %i to i64* 813 ret i64* %i2p 814} 815 816; Use the store alignment only for the pointer operand. 817define void @aligned_store(i8* %Value, i8** %Ptr) { 818; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly 819; IS__TUNIT____-LABEL: define {{[^@]+}}@aligned_store 820; IS__TUNIT____-SAME: (i8* nofree writeonly [[VALUE:%.*]], i8** nocapture nofree nonnull writeonly align 32 dereferenceable(8) [[PTR:%.*]]) 821; IS__TUNIT____-NEXT: store i8* [[VALUE]], i8** [[PTR]], align 32 822; IS__TUNIT____-NEXT: ret void 823; 824; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly 825; IS__CGSCC____-LABEL: define {{[^@]+}}@aligned_store 826; IS__CGSCC____-SAME: (i8* nofree writeonly [[VALUE:%.*]], i8** nocapture nofree nonnull writeonly align 32 dereferenceable(8) [[PTR:%.*]]) 827; IS__CGSCC____-NEXT: store i8* [[VALUE]], i8** [[PTR]], align 32 828; IS__CGSCC____-NEXT: ret void 829; 830 store i8* %Value, i8** %Ptr, align 32 831 ret void 832} 833 834declare i8* @some_func(i8*) 835define void @align_call_op_not_store(i8* align 2048 %arg) { 836; CHECK-LABEL: define {{[^@]+}}@align_call_op_not_store 837; CHECK-SAME: (i8* align 2048 [[ARG:%.*]]) 838; CHECK-NEXT: [[UNKNOWN:%.*]] = call i8* @some_func(i8* align 2048 [[ARG]]) 839; CHECK-NEXT: store i8 0, i8* [[UNKNOWN]], align 1 840; CHECK-NEXT: ret void 841; 842 %unknown = call i8* @some_func(i8* %arg) 843 store i8 0, i8* %unknown 844 ret void 845} 846define void @align_store_after_bc(i32* align 2048 %arg) { 847; 848; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly 849; IS__TUNIT____-LABEL: define {{[^@]+}}@align_store_after_bc 850; IS__TUNIT____-SAME: (i32* nocapture nofree nonnull writeonly align 2048 dereferenceable(1) [[ARG:%.*]]) 851; IS__TUNIT____-NEXT: [[BC:%.*]] = bitcast i32* [[ARG]] to i8* 852; IS__TUNIT____-NEXT: store i8 0, i8* [[BC]], align 2048 853; IS__TUNIT____-NEXT: ret void 854; 855; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly 856; IS__CGSCC____-LABEL: define {{[^@]+}}@align_store_after_bc 857; IS__CGSCC____-SAME: (i32* nocapture nofree nonnull writeonly align 2048 dereferenceable(1) [[ARG:%.*]]) 858; IS__CGSCC____-NEXT: [[BC:%.*]] = bitcast i32* [[ARG]] to i8* 859; IS__CGSCC____-NEXT: store i8 0, i8* [[BC]], align 2048 860; IS__CGSCC____-NEXT: ret void 861; 862 %bc = bitcast i32* %arg to i8* 863 store i8 0, i8* %bc 864 ret void 865} 866 867; Make sure we do not annotate the callee of a must-tail call with an alignment 868; we cannot also put on the caller. 869@cnd = external global i1 870define i32 @musttail_callee_1(i32* %p) { 871; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind readonly willreturn 872; IS__TUNIT____-LABEL: define {{[^@]+}}@musttail_callee_1 873; IS__TUNIT____-SAME: (i32* nocapture nofree nonnull readonly dereferenceable(4) [[P:%.*]]) 874; IS__TUNIT____-NEXT: [[V:%.*]] = load i32, i32* [[P]], align 32 875; IS__TUNIT____-NEXT: ret i32 [[V]] 876; 877; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind readonly willreturn 878; IS__CGSCC____-LABEL: define {{[^@]+}}@musttail_callee_1 879; IS__CGSCC____-SAME: (i32* nocapture nofree nonnull readonly dereferenceable(4) [[P:%.*]]) 880; IS__CGSCC____-NEXT: [[V:%.*]] = load i32, i32* [[P]], align 32 881; IS__CGSCC____-NEXT: ret i32 [[V]] 882; 883 %v = load i32, i32* %p, align 32 884 ret i32 %v 885} 886define i32 @musttail_caller_1(i32* %p) { 887; IS__TUNIT____: Function Attrs: nofree nosync nounwind readonly willreturn 888; IS__TUNIT____-LABEL: define {{[^@]+}}@musttail_caller_1 889; IS__TUNIT____-SAME: (i32* nocapture nofree readonly [[P:%.*]]) 890; IS__TUNIT____-NEXT: [[C:%.*]] = load i1, i1* @cnd, align 1 891; IS__TUNIT____-NEXT: br i1 [[C]], label [[MT:%.*]], label [[EXIT:%.*]] 892; IS__TUNIT____: mt: 893; IS__TUNIT____-NEXT: [[V:%.*]] = musttail call i32 @musttail_callee_1(i32* nocapture nofree readonly [[P]]) 894; IS__TUNIT____-NEXT: ret i32 [[V]] 895; IS__TUNIT____: exit: 896; IS__TUNIT____-NEXT: ret i32 0 897; 898; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readonly willreturn 899; IS__CGSCC____-LABEL: define {{[^@]+}}@musttail_caller_1 900; IS__CGSCC____-SAME: (i32* nocapture nofree readonly [[P:%.*]]) 901; IS__CGSCC____-NEXT: [[C:%.*]] = load i1, i1* @cnd, align 1 902; IS__CGSCC____-NEXT: br i1 [[C]], label [[MT:%.*]], label [[EXIT:%.*]] 903; IS__CGSCC____: mt: 904; IS__CGSCC____-NEXT: [[V:%.*]] = musttail call i32 @musttail_callee_1(i32* nocapture nofree nonnull readonly dereferenceable(4) [[P]]) 905; IS__CGSCC____-NEXT: ret i32 [[V]] 906; IS__CGSCC____: exit: 907; IS__CGSCC____-NEXT: ret i32 0 908; 909 %c = load i1, i1* @cnd 910 br i1 %c, label %mt, label %exit 911mt: 912 %v = musttail call i32 @musttail_callee_1(i32* %p) 913 ret i32 %v 914exit: 915 ret i32 0 916} 917 918attributes #0 = { nounwind uwtable noinline } 919attributes #1 = { uwtable noinline } 920attributes #2 = { null_pointer_is_valid } 921