1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=ve | FileCheck %s 3; RUN: llc < %s -mtriple=ve -relocation-model=pic \ 4; RUN: | FileCheck %s --check-prefix=PIC 5 6;;; Check stack frame allocation of a function which does not calls other 7;;; functions under following conditions and combinations of them: 8;;; - access variable or not 9;;; - no stack object, a stack object using BP, or a stack object not using BP 10;;; - isPositionIndependent or not 11 12@data = external global i8, align 1 13 14; Function Attrs: norecurse nounwind readnone 15define i8* @test_frame0(i8* nocapture readnone %0, i8* readnone returned %1) { 16; CHECK-LABEL: test_frame0: 17; CHECK: # %bb.0: 18; CHECK-NEXT: or %s0, 0, %s1 19; CHECK-NEXT: b.l.t (, %s10) 20; 21; PIC-LABEL: test_frame0: 22; PIC: # %bb.0: 23; PIC-NEXT: or %s0, 0, %s1 24; PIC-NEXT: b.l.t (, %s10) 25 ret i8* %1 26} 27 28; Function Attrs: nofree nounwind 29define nonnull i8* @test_frame32(i8* nocapture readonly %0) { 30; CHECK-LABEL: test_frame32: 31; CHECK: # %bb.0: 32; CHECK-NEXT: adds.l %s11, -32, %s11 33; CHECK-NEXT: brge.l.t %s11, %s8, .LBB1_2 34; CHECK-NEXT: # %bb.1: 35; CHECK-NEXT: ld %s61, 24(, %s14) 36; CHECK-NEXT: or %s62, 0, %s0 37; CHECK-NEXT: lea %s63, 315 38; CHECK-NEXT: shm.l %s63, (%s61) 39; CHECK-NEXT: shm.l %s8, 8(%s61) 40; CHECK-NEXT: shm.l %s11, 16(%s61) 41; CHECK-NEXT: monc 42; CHECK-NEXT: or %s0, 0, %s62 43; CHECK-NEXT: .LBB1_2: 44; CHECK-NEXT: ld1b.zx %s1, (, %s0) 45; CHECK-NEXT: lea %s0, (, %s11) 46; CHECK-NEXT: st1b %s1, (, %s11) 47; CHECK-NEXT: adds.l %s11, 32, %s11 48; CHECK-NEXT: b.l.t (, %s10) 49; 50; PIC-LABEL: test_frame32: 51; PIC: # %bb.0: 52; PIC-NEXT: adds.l %s11, -32, %s11 53; PIC-NEXT: brge.l.t %s11, %s8, .LBB1_2 54; PIC-NEXT: # %bb.1: 55; PIC-NEXT: ld %s61, 24(, %s14) 56; PIC-NEXT: or %s62, 0, %s0 57; PIC-NEXT: lea %s63, 315 58; PIC-NEXT: shm.l %s63, (%s61) 59; PIC-NEXT: shm.l %s8, 8(%s61) 60; PIC-NEXT: shm.l %s11, 16(%s61) 61; PIC-NEXT: monc 62; PIC-NEXT: or %s0, 0, %s62 63; PIC-NEXT: .LBB1_2: 64; PIC-NEXT: ld1b.zx %s1, (, %s0) 65; PIC-NEXT: lea %s0, (, %s11) 66; PIC-NEXT: st1b %s1, (, %s11) 67; PIC-NEXT: adds.l %s11, 32, %s11 68; PIC-NEXT: b.l.t (, %s10) 69 %2 = alloca [32 x i8], align 1 70 %3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0 71 call void @llvm.lifetime.start.p0i8(i64 32, i8* nonnull %3) 72 %4 = load i8, i8* %0, align 1 73 store volatile i8 %4, i8* %3, align 1 74 call void @llvm.lifetime.end.p0i8(i64 32, i8* nonnull %3) 75 ret i8* %3 76} 77 78; Function Attrs: argmemonly nofree nosync nounwind willreturn 79declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) 80 81; Function Attrs: argmemonly nofree nosync nounwind willreturn 82declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) 83 84; Function Attrs: nofree nounwind 85define noalias nonnull i8* @test_align32(i32 signext %0, i8* nocapture readonly %1) { 86; CHECK-LABEL: test_align32: 87; CHECK: # %bb.0: 88; CHECK-NEXT: st %s9, (, %s11) 89; CHECK-NEXT: st %s10, 8(, %s11) 90; CHECK-NEXT: st %s17, 40(, %s11) 91; CHECK-NEXT: or %s9, 0, %s11 92; CHECK-NEXT: lea %s11, -288(, %s11) 93; CHECK-NEXT: and %s11, %s11, (59)1 94; CHECK-NEXT: or %s17, 0, %s11 95; CHECK-NEXT: brge.l.t %s11, %s8, .LBB2_2 96; CHECK-NEXT: # %bb.1: 97; CHECK-NEXT: ld %s61, 24(, %s14) 98; CHECK-NEXT: or %s62, 0, %s0 99; CHECK-NEXT: lea %s63, 315 100; CHECK-NEXT: shm.l %s63, (%s61) 101; CHECK-NEXT: shm.l %s8, 8(%s61) 102; CHECK-NEXT: shm.l %s11, 16(%s61) 103; CHECK-NEXT: monc 104; CHECK-NEXT: or %s0, 0, %s62 105; CHECK-NEXT: .LBB2_2: 106; CHECK-NEXT: or %s2, 0, %s1 107; CHECK-NEXT: lea %s0, 15(, %s0) 108; CHECK-NEXT: and %s0, -16, %s0 109; CHECK-NEXT: lea %s1, __ve_grow_stack_align@lo 110; CHECK-NEXT: and %s1, %s1, (32)0 111; CHECK-NEXT: lea.sl %s12, __ve_grow_stack_align@hi(, %s1) 112; CHECK-NEXT: or %s1, -32, (0)1 113; CHECK-NEXT: bsic %s10, (, %s12) 114; CHECK-NEXT: lea %s0, 240(, %s11) 115; CHECK-NEXT: ld1b.zx %s1, (, %s2) 116; CHECK-NEXT: lea %s0, 31(, %s0) 117; CHECK-NEXT: and %s2, -32, %s0 118; CHECK-NEXT: lea %s0, 256(, %s17) 119; CHECK-NEXT: st1b %s1, (, %s2) 120; CHECK-NEXT: or %s11, 0, %s9 121; CHECK-NEXT: ld %s17, 40(, %s11) 122; CHECK-NEXT: ld %s10, 8(, %s11) 123; CHECK-NEXT: ld %s9, (, %s11) 124; CHECK-NEXT: b.l.t (, %s10) 125; 126; PIC-LABEL: test_align32: 127; PIC: # %bb.0: 128; PIC-NEXT: st %s9, (, %s11) 129; PIC-NEXT: st %s10, 8(, %s11) 130; PIC-NEXT: st %s15, 24(, %s11) 131; PIC-NEXT: st %s16, 32(, %s11) 132; PIC-NEXT: st %s17, 40(, %s11) 133; PIC-NEXT: or %s9, 0, %s11 134; PIC-NEXT: lea %s11, -288(, %s11) 135; PIC-NEXT: and %s11, %s11, (59)1 136; PIC-NEXT: or %s17, 0, %s11 137; PIC-NEXT: brge.l.t %s11, %s8, .LBB2_2 138; PIC-NEXT: # %bb.1: 139; PIC-NEXT: ld %s61, 24(, %s14) 140; PIC-NEXT: or %s62, 0, %s0 141; PIC-NEXT: lea %s63, 315 142; PIC-NEXT: shm.l %s63, (%s61) 143; PIC-NEXT: shm.l %s8, 8(%s61) 144; PIC-NEXT: shm.l %s11, 16(%s61) 145; PIC-NEXT: monc 146; PIC-NEXT: or %s0, 0, %s62 147; PIC-NEXT: .LBB2_2: 148; PIC-NEXT: or %s2, 0, %s1 149; PIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24) 150; PIC-NEXT: and %s15, %s15, (32)0 151; PIC-NEXT: sic %s16 152; PIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15) 153; PIC-NEXT: lea %s0, 15(, %s0) 154; PIC-NEXT: and %s0, -16, %s0 155; PIC-NEXT: lea %s12, __ve_grow_stack_align@plt_lo(-24) 156; PIC-NEXT: and %s12, %s12, (32)0 157; PIC-NEXT: sic %s16 158; PIC-NEXT: lea.sl %s12, __ve_grow_stack_align@plt_hi(%s16, %s12) 159; PIC-NEXT: or %s1, -32, (0)1 160; PIC-NEXT: bsic %s10, (, %s12) 161; PIC-NEXT: lea %s0, 240(, %s11) 162; PIC-NEXT: ld1b.zx %s1, (, %s2) 163; PIC-NEXT: lea %s0, 31(, %s0) 164; PIC-NEXT: and %s2, -32, %s0 165; PIC-NEXT: lea %s0, 256(, %s17) 166; PIC-NEXT: st1b %s1, (, %s2) 167; PIC-NEXT: or %s11, 0, %s9 168; PIC-NEXT: ld %s17, 40(, %s11) 169; PIC-NEXT: ld %s16, 32(, %s11) 170; PIC-NEXT: ld %s15, 24(, %s11) 171; PIC-NEXT: ld %s10, 8(, %s11) 172; PIC-NEXT: ld %s9, (, %s11) 173; PIC-NEXT: b.l.t (, %s10) 174 %3 = alloca [32 x i8], align 32 175 %4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0 176 call void @llvm.lifetime.start.p0i8(i64 32, i8* nonnull %4) 177 %5 = sext i32 %0 to i64 178 %6 = alloca i8, i64 %5, align 32 179 %7 = load i8, i8* %1, align 1 180 store volatile i8 %7, i8* %6, align 32 181 call void @llvm.lifetime.end.p0i8(i64 32, i8* nonnull %4) 182 ret i8* %4 183} 184 185; Function Attrs: nofree norecurse nounwind 186define i8* @test_frame0_var(i8* returned %0, i8* nocapture readnone %1) { 187; CHECK-LABEL: test_frame0_var: 188; CHECK: # %bb.0: 189; CHECK-NEXT: lea %s1, data@lo 190; CHECK-NEXT: and %s1, %s1, (32)0 191; CHECK-NEXT: lea.sl %s1, data@hi(, %s1) 192; CHECK-NEXT: ld1b.zx %s1, (, %s1) 193; CHECK-NEXT: st1b %s1, (, %s0) 194; CHECK-NEXT: b.l.t (, %s10) 195; 196; PIC-LABEL: test_frame0_var: 197; PIC: # %bb.0: 198; PIC-NEXT: st %s15, 24(, %s11) 199; PIC-NEXT: st %s16, 32(, %s11) 200; PIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24) 201; PIC-NEXT: and %s15, %s15, (32)0 202; PIC-NEXT: sic %s16 203; PIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15) 204; PIC-NEXT: lea %s1, data@got_lo 205; PIC-NEXT: and %s1, %s1, (32)0 206; PIC-NEXT: lea.sl %s1, data@got_hi(, %s1) 207; PIC-NEXT: ld %s1, (%s1, %s15) 208; PIC-NEXT: ld1b.zx %s1, (, %s1) 209; PIC-NEXT: st1b %s1, (, %s0) 210; PIC-NEXT: ld %s16, 32(, %s11) 211; PIC-NEXT: ld %s15, 24(, %s11) 212; PIC-NEXT: b.l.t (, %s10) 213 %3 = load i8, i8* @data, align 1 214 store i8 %3, i8* %0, align 1 215 ret i8* %0 216} 217 218; Function Attrs: nofree nounwind 219define nonnull i8* @test_frame32_var(i8* nocapture readnone %0) { 220; CHECK-LABEL: test_frame32_var: 221; CHECK: # %bb.0: 222; CHECK-NEXT: adds.l %s11, -32, %s11 223; CHECK-NEXT: brge.l.t %s11, %s8, .LBB4_2 224; CHECK-NEXT: # %bb.1: 225; CHECK-NEXT: ld %s61, 24(, %s14) 226; CHECK-NEXT: or %s62, 0, %s0 227; CHECK-NEXT: lea %s63, 315 228; CHECK-NEXT: shm.l %s63, (%s61) 229; CHECK-NEXT: shm.l %s8, 8(%s61) 230; CHECK-NEXT: shm.l %s11, 16(%s61) 231; CHECK-NEXT: monc 232; CHECK-NEXT: or %s0, 0, %s62 233; CHECK-NEXT: .LBB4_2: 234; CHECK-NEXT: lea %s0, data@lo 235; CHECK-NEXT: and %s0, %s0, (32)0 236; CHECK-NEXT: lea.sl %s0, data@hi(, %s0) 237; CHECK-NEXT: ld1b.zx %s1, (, %s0) 238; CHECK-NEXT: lea %s0, (, %s11) 239; CHECK-NEXT: st1b %s1, (, %s11) 240; CHECK-NEXT: adds.l %s11, 32, %s11 241; CHECK-NEXT: b.l.t (, %s10) 242; 243; PIC-LABEL: test_frame32_var: 244; PIC: # %bb.0: 245; PIC-NEXT: st %s15, 24(, %s11) 246; PIC-NEXT: st %s16, 32(, %s11) 247; PIC-NEXT: adds.l %s11, -32, %s11 248; PIC-NEXT: brge.l.t %s11, %s8, .LBB4_2 249; PIC-NEXT: # %bb.1: 250; PIC-NEXT: ld %s61, 24(, %s14) 251; PIC-NEXT: or %s62, 0, %s0 252; PIC-NEXT: lea %s63, 315 253; PIC-NEXT: shm.l %s63, (%s61) 254; PIC-NEXT: shm.l %s8, 8(%s61) 255; PIC-NEXT: shm.l %s11, 16(%s61) 256; PIC-NEXT: monc 257; PIC-NEXT: or %s0, 0, %s62 258; PIC-NEXT: .LBB4_2: 259; PIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24) 260; PIC-NEXT: and %s15, %s15, (32)0 261; PIC-NEXT: sic %s16 262; PIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15) 263; PIC-NEXT: lea %s0, data@got_lo 264; PIC-NEXT: and %s0, %s0, (32)0 265; PIC-NEXT: lea.sl %s0, data@got_hi(, %s0) 266; PIC-NEXT: ld %s0, (%s0, %s15) 267; PIC-NEXT: ld1b.zx %s1, (, %s0) 268; PIC-NEXT: lea %s0, (, %s11) 269; PIC-NEXT: st1b %s1, (, %s11) 270; PIC-NEXT: adds.l %s11, 32, %s11 271; PIC-NEXT: ld %s16, 32(, %s11) 272; PIC-NEXT: ld %s15, 24(, %s11) 273; PIC-NEXT: b.l.t (, %s10) 274 %2 = alloca [32 x i8], align 1 275 %3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0 276 call void @llvm.lifetime.start.p0i8(i64 32, i8* nonnull %3) 277 %4 = load i8, i8* @data, align 1 278 store volatile i8 %4, i8* %3, align 1 279 call void @llvm.lifetime.end.p0i8(i64 32, i8* nonnull %3) 280 ret i8* %3 281} 282 283; Function Attrs: nofree nounwind 284define noalias nonnull i8* @test_align32_var(i32 signext %0, i8* nocapture readonly %1) { 285; CHECK-LABEL: test_align32_var: 286; CHECK: # %bb.0: 287; CHECK-NEXT: st %s9, (, %s11) 288; CHECK-NEXT: st %s10, 8(, %s11) 289; CHECK-NEXT: st %s17, 40(, %s11) 290; CHECK-NEXT: or %s9, 0, %s11 291; CHECK-NEXT: lea %s11, -288(, %s11) 292; CHECK-NEXT: and %s11, %s11, (59)1 293; CHECK-NEXT: or %s17, 0, %s11 294; CHECK-NEXT: brge.l.t %s11, %s8, .LBB5_2 295; CHECK-NEXT: # %bb.1: 296; CHECK-NEXT: ld %s61, 24(, %s14) 297; CHECK-NEXT: or %s62, 0, %s0 298; CHECK-NEXT: lea %s63, 315 299; CHECK-NEXT: shm.l %s63, (%s61) 300; CHECK-NEXT: shm.l %s8, 8(%s61) 301; CHECK-NEXT: shm.l %s11, 16(%s61) 302; CHECK-NEXT: monc 303; CHECK-NEXT: or %s0, 0, %s62 304; CHECK-NEXT: .LBB5_2: 305; CHECK-NEXT: or %s2, 0, %s1 306; CHECK-NEXT: lea %s0, 15(, %s0) 307; CHECK-NEXT: and %s0, -16, %s0 308; CHECK-NEXT: lea %s1, __ve_grow_stack_align@lo 309; CHECK-NEXT: and %s1, %s1, (32)0 310; CHECK-NEXT: lea.sl %s12, __ve_grow_stack_align@hi(, %s1) 311; CHECK-NEXT: or %s1, -32, (0)1 312; CHECK-NEXT: bsic %s10, (, %s12) 313; CHECK-NEXT: lea %s0, 240(, %s11) 314; CHECK-NEXT: ld1b.zx %s1, (, %s2) 315; CHECK-NEXT: lea %s0, 31(, %s0) 316; CHECK-NEXT: and %s2, -32, %s0 317; CHECK-NEXT: lea %s0, 256(, %s17) 318; CHECK-NEXT: st1b %s1, (, %s2) 319; CHECK-NEXT: or %s11, 0, %s9 320; CHECK-NEXT: ld %s17, 40(, %s11) 321; CHECK-NEXT: ld %s10, 8(, %s11) 322; CHECK-NEXT: ld %s9, (, %s11) 323; CHECK-NEXT: b.l.t (, %s10) 324; 325; PIC-LABEL: test_align32_var: 326; PIC: # %bb.0: 327; PIC-NEXT: st %s9, (, %s11) 328; PIC-NEXT: st %s10, 8(, %s11) 329; PIC-NEXT: st %s15, 24(, %s11) 330; PIC-NEXT: st %s16, 32(, %s11) 331; PIC-NEXT: st %s17, 40(, %s11) 332; PIC-NEXT: or %s9, 0, %s11 333; PIC-NEXT: lea %s11, -288(, %s11) 334; PIC-NEXT: and %s11, %s11, (59)1 335; PIC-NEXT: or %s17, 0, %s11 336; PIC-NEXT: brge.l.t %s11, %s8, .LBB5_2 337; PIC-NEXT: # %bb.1: 338; PIC-NEXT: ld %s61, 24(, %s14) 339; PIC-NEXT: or %s62, 0, %s0 340; PIC-NEXT: lea %s63, 315 341; PIC-NEXT: shm.l %s63, (%s61) 342; PIC-NEXT: shm.l %s8, 8(%s61) 343; PIC-NEXT: shm.l %s11, 16(%s61) 344; PIC-NEXT: monc 345; PIC-NEXT: or %s0, 0, %s62 346; PIC-NEXT: .LBB5_2: 347; PIC-NEXT: or %s2, 0, %s1 348; PIC-NEXT: lea %s15, _GLOBAL_OFFSET_TABLE_@pc_lo(-24) 349; PIC-NEXT: and %s15, %s15, (32)0 350; PIC-NEXT: sic %s16 351; PIC-NEXT: lea.sl %s15, _GLOBAL_OFFSET_TABLE_@pc_hi(%s16, %s15) 352; PIC-NEXT: lea %s0, 15(, %s0) 353; PIC-NEXT: and %s0, -16, %s0 354; PIC-NEXT: lea %s12, __ve_grow_stack_align@plt_lo(-24) 355; PIC-NEXT: and %s12, %s12, (32)0 356; PIC-NEXT: sic %s16 357; PIC-NEXT: lea.sl %s12, __ve_grow_stack_align@plt_hi(%s16, %s12) 358; PIC-NEXT: or %s1, -32, (0)1 359; PIC-NEXT: bsic %s10, (, %s12) 360; PIC-NEXT: lea %s0, 240(, %s11) 361; PIC-NEXT: ld1b.zx %s1, (, %s2) 362; PIC-NEXT: lea %s0, 31(, %s0) 363; PIC-NEXT: and %s2, -32, %s0 364; PIC-NEXT: lea %s0, 256(, %s17) 365; PIC-NEXT: st1b %s1, (, %s2) 366; PIC-NEXT: or %s11, 0, %s9 367; PIC-NEXT: ld %s17, 40(, %s11) 368; PIC-NEXT: ld %s16, 32(, %s11) 369; PIC-NEXT: ld %s15, 24(, %s11) 370; PIC-NEXT: ld %s10, 8(, %s11) 371; PIC-NEXT: ld %s9, (, %s11) 372; PIC-NEXT: b.l.t (, %s10) 373 %3 = alloca [32 x i8], align 32 374 %4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0 375 call void @llvm.lifetime.start.p0i8(i64 32, i8* nonnull %4) 376 %5 = sext i32 %0 to i64 377 %6 = alloca i8, i64 %5, align 32 378 %7 = load i8, i8* %1, align 1 379 store volatile i8 %7, i8* %6, align 32 380 call void @llvm.lifetime.end.p0i8(i64 32, i8* nonnull %4) 381 ret i8* %4 382} 383