300 lines · plain
1; RUN: llc < %s -mtriple=i686-pc-linux | FileCheck %s -check-prefix=LINUX -check-prefix=CHECK2; RUN: llc < %s -mtriple=i686-apple-darwin | FileCheck %s -check-prefix=DARWIN -check-prefix=CHECK3; RUN: llc < %s -mtriple=i686-pc-linux -stop-after=prologepilog | FileCheck %s --check-prefix=PEI4 5declare i32 @__gxx_personality_v0(...)6declare void @good(i32 %a, i32 %b, i32 %c, i32 %d)7declare void @large(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f)8declare void @empty()9 10; When we use an invoke, we expect a .cfi_escape GNU_ARGS_SIZE11; with size 16 before the invocation. Without FP, we also expect12; .cfi_adjust_cfa_offset after each push.13; Darwin should not generate pushes in either circumstance.14; CHECK-LABEL: test1_nofp:15; LINUX: .cfi_escape 0x2e, 0x1016; LINUX-NEXT: pushl $417; LINUX-NEXT: .cfi_adjust_cfa_offset 418; LINUX-NEXT: pushl $319; LINUX-NEXT: .cfi_adjust_cfa_offset 420; LINUX-NEXT: pushl $221; LINUX-NEXT: .cfi_adjust_cfa_offset 422; LINUX-NEXT: pushl $123; LINUX-NEXT: .cfi_adjust_cfa_offset 424; LINUX-NEXT: call25; LINUX-NEXT: addl $16, %esp26; LINUX: .cfi_adjust_cfa_offset -1627; DARWIN-NOT: .cfi_escape28; DARWIN-NOT: pushl29 30; PEI-LABEL: name: test1_nofp31; PEI: $esp = frame-setup SUB32ri $esp, 12, implicit-def dead $eflags32; PEI-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 1633; PEI-NOT: frame-setup CFI_INSTRUCTION34; PEI: ...35define void @test1_nofp() #0 personality ptr @__gxx_personality_v0 {36entry:37 invoke void @good(i32 1, i32 2, i32 3, i32 4)38 to label %continue unwind label %cleanup39continue:40 ret void41cleanup: 42 landingpad { ptr, i32 }43 cleanup44 ret void45}46 47; CHECK-LABEL: test1_fp:48; LINUX: .cfi_escape 0x2e, 0x1049; LINUX-NEXT: pushl $450; LINUX-NEXT: pushl $351; LINUX-NEXT: pushl $252; LINUX-NEXT: pushl $153; LINUX-NEXT: call54; LINUX-NEXT: addl $16, %esp55; DARWIN: pushl %ebp56; DARWIN-NOT: .cfi_escape57; DARWIN-NOT: pushl58define void @test1_fp() #1 personality ptr @__gxx_personality_v0 {59entry:60 invoke void @good(i32 1, i32 2, i32 3, i32 4)61 to label %continue unwind label %cleanup62continue:63 ret void64cleanup: 65 landingpad { ptr, i32 }66 cleanup67 ret void68}69 70; If the function has no handlers, we don't need to generate GNU_ARGS_SIZE,71; even if it has an unwind table. Without FP, we still need cfi_adjust_cfa_offset,72; so darwin should not generate pushes.73; CHECK-LABEL: test2_nofp:74; LINUX-NOT: .cfi_escape75; LINUX: pushl $476; LINUX-NEXT: .cfi_adjust_cfa_offset 477; LINUX-NEXT: pushl $378; LINUX-NEXT: .cfi_adjust_cfa_offset 479; LINUX-NEXT: pushl $280; LINUX-NEXT: .cfi_adjust_cfa_offset 481; LINUX-NEXT: pushl $182; LINUX-NEXT: .cfi_adjust_cfa_offset 483; LINUX-NEXT: call84; LINUX-NEXT: addl $28, %esp85; LINUX: .cfi_adjust_cfa_offset -2886; DARWIN-NOT: .cfi_escape87; DARWIN-NOT: pushl88define void @test2_nofp() #0 personality ptr @__gxx_personality_v0 {89entry:90 call void @good(i32 1, i32 2, i32 3, i32 4)91 ret void92}93 94; CHECK-LABEL: test2_fp:95; CHECK-NOT: .cfi_escape96; CHECK-NOT: .cfi_adjust_cfa_offset97; CHECK: pushl $498; CHECK-NEXT: pushl $399; CHECK-NEXT: pushl $2100; CHECK-NEXT: pushl $1101; CHECK-NEXT: call102; CHECK-NEXT: addl $24, %esp103define void @test2_fp() #1 personality ptr @__gxx_personality_v0 {104entry:105 call void @good(i32 1, i32 2, i32 3, i32 4)106 ret void107}108 109; If we did not end up using any pushes, no need for GNU_ARGS_SIZE or110; cfi_adjust_cfa_offset.111; CHECK-LABEL: test3_nofp:112; LINUX-NOT: .cfi_escape113; LINUX-NOT: .cfi_adjust_cfa_offset114; LINUX-NOT: pushl115; LINUX: retl116define void @test3_nofp() #0 personality ptr @__gxx_personality_v0 {117entry:118 invoke void @empty()119 to label %continue unwind label %cleanup120continue:121 ret void122cleanup: 123 landingpad { ptr, i32 }124 cleanup125 ret void126}127 128; If we did not end up using any pushes, no need for GNU_ARGS_SIZE or129; cfi_adjust_cfa_offset.130; CHECK-LABEL: test3_fp:131; LINUX: pushl %ebp132; LINUX-NOT: .cfi_escape133; LINUX-NOT: .cfi_adjust_cfa_offset134; LINUX-NOT: pushl135; LINUX: retl136define void @test3_fp() #1 personality ptr @__gxx_personality_v0 {137entry:138 invoke void @empty()139 to label %continue unwind label %cleanup140continue:141 ret void142cleanup: 143 landingpad { ptr, i32 }144 cleanup145 ret void146}147 148; Different sized stacks need different GNU_ARGS_SIZEs149; CHECK-LABEL: test4:150; LINUX: .cfi_escape 0x2e, 0x10151; LINUX-NEXT: pushl $4152; LINUX-NEXT: pushl $3153; LINUX-NEXT: pushl $2154; LINUX-NEXT: pushl $1155; LINUX-NEXT: call156; LINUX-NEXT: addl $16, %esp157; LINUX: .cfi_escape 0x2e, 0x20158; LINUX: subl $8, %esp159; LINUX-NEXT: pushl $11160; LINUX-NEXT: pushl $10161; LINUX-NEXT: pushl $9162; LINUX-NEXT: pushl $8163; LINUX-NEXT: pushl $7164; LINUX-NEXT: pushl $6165; LINUX-NEXT: calll large166; LINUX-NEXT: addl $32, %esp167define void @test4() #1 personality ptr @__gxx_personality_v0 {168entry:169 invoke void @good(i32 1, i32 2, i32 3, i32 4)170 to label %continue1 unwind label %cleanup171continue1:172 invoke void @large(i32 6, i32 7, i32 8, i32 9, i32 10, i32 11)173 to label %continue2 unwind label %cleanup174continue2:175 ret void 176cleanup: 177 landingpad { ptr, i32 }178 cleanup179 ret void180}181 182; If we did use pushes, we need to reset GNU_ARGS_SIZE before a call183; without parameters, but don't need to adjust the cfa offset184; CHECK-LABEL: test5_nofp:185; LINUX: .cfi_escape 0x2e, 0x10186; LINUX-NEXT: pushl $4187; LINUX-NEXT: .cfi_adjust_cfa_offset 4188; LINUX-NEXT: pushl $3189; LINUX-NEXT: .cfi_adjust_cfa_offset 4190; LINUX-NEXT: pushl $2191; LINUX-NEXT: .cfi_adjust_cfa_offset 4192; LINUX-NEXT: pushl $1193; LINUX-NEXT: .cfi_adjust_cfa_offset 4194; LINUX-NEXT: call195; LINUX-NEXT: addl $16, %esp196; LINUX: .cfi_adjust_cfa_offset -16197; LINUX-NOT: .cfi_adjust_cfa_offset198; LINUX: .cfi_escape 0x2e, 0x00199; LINUX-NOT: .cfi_adjust_cfa_offset200; LINUX: call201define void @test5_nofp() #0 personality ptr @__gxx_personality_v0 {202entry:203 invoke void @good(i32 1, i32 2, i32 3, i32 4)204 to label %continue1 unwind label %cleanup205continue1:206 invoke void @empty()207 to label %continue2 unwind label %cleanup208continue2:209 ret void 210cleanup: 211 landingpad { ptr, i32 }212 cleanup213 ret void214}215 216; CHECK-LABEL: test5_fp:217; LINUX: .cfi_escape 0x2e, 0x10218; LINUX-NEXT: pushl $4219; LINUX-NEXT: pushl $3220; LINUX-NEXT: pushl $2221; LINUX-NEXT: pushl $1222; LINUX-NEXT: call223; LINUX-NEXT: addl $16, %esp224; LINUX: .cfi_escape 0x2e, 0x00225; LINUX-NOT: .cfi_adjust_cfa_offset226; LINUX: call227define void @test5_fp() #1 personality ptr @__gxx_personality_v0 {228entry:229 invoke void @good(i32 1, i32 2, i32 3, i32 4)230 to label %continue1 unwind label %cleanup231continue1:232 invoke void @empty()233 to label %continue2 unwind label %cleanup234continue2:235 ret void 236cleanup: 237 landingpad { ptr, i32 }238 cleanup239 ret void240}241 242; FIXME: This is actually inefficient - we don't need to repeat the .cfi_escape twice.243; CHECK-LABEL: test6:244; LINUX: .cfi_escape 0x2e, 0x10245; LINUX: call246; LINUX: .cfi_escape 0x2e, 0x10247; LINUX: call248define void @test6() #1 personality ptr @__gxx_personality_v0 {249entry:250 invoke void @good(i32 1, i32 2, i32 3, i32 4)251 to label %continue1 unwind label %cleanup252continue1:253 invoke void @good(i32 5, i32 6, i32 7, i32 8)254 to label %continue2 unwind label %cleanup255continue2:256 ret void 257cleanup: 258 landingpad { ptr, i32 }259 cleanup260 ret void261}262 263; Darwin should generate pushes in the presense of FP and an unwind table,264; but not FP and invoke.265; CHECK-LABEL: test7:266; DARWIN: pushl %ebp267; DARWIN: movl %esp, %ebp268; DARWIN: .cfi_def_cfa_register %ebp269; DARWIN-NOT: .cfi_adjust_cfa_offset270; DARWIN: pushl $4271; DARWIN-NEXT: pushl $3272; DARWIN-NEXT: pushl $2273; DARWIN-NEXT: pushl $1274; DARWIN-NEXT: call275define void @test7() #1 personality ptr @__gxx_personality_v0 {276entry:277 call void @good(i32 1, i32 2, i32 3, i32 4)278 ret void279}280 281; CHECK-LABEL: test8:282; DARWIN: pushl %ebp283; DARWIN: movl %esp, %ebp284; DARWIN-NOT: .cfi_adjust_cfa_offset285; DARWIN-NOT: pushl286define void @test8() #1 personality ptr @__gxx_personality_v0 {287entry:288 invoke void @good(i32 1, i32 2, i32 3, i32 4)289 to label %continue unwind label %cleanup290continue:291 ret void292cleanup: 293 landingpad { ptr, i32 }294 cleanup295 ret void296}297 298attributes #0 = { optsize }299attributes #1 = { optsize "frame-pointer"="all" }300