185 lines · plain
1; RUN: llc < %s -mtriple=armv6-apple-ios5.0 -mattr=+vfp2 -arm-atomic-cfg-tidy=0 | FileCheck %s -check-prefix=CHECKV62; RUN: llc < %s -mtriple=thumbv7-apple-ios5.0 -arm-atomic-cfg-tidy=0 | FileCheck %s -check-prefix=CHECKT2D3; RUN: llc < %s -mtriple=armv6-linux-gnueabi -relocation-model=pic -mattr=+vfp2 -arm-atomic-cfg-tidy=0 \4; RUN: | FileCheck %s -check-prefix=CHECKELF5 6; Enable tailcall optimization for iOS 5.07; rdar://91200318 9@t = weak global ptr null ; <ptr> [#uses=1]10 11declare void @g(i32, i32, i32, i32)12 13define void @t1() "frame-pointer"="all" {14; CHECKELF-LABEL: t1:15; CHECKELF: bl g16 call void @g( i32 1, i32 2, i32 3, i32 4 )17 ret void18}19 20define void @t2() "frame-pointer"="none" {21; CHECKV6-LABEL: t2:22; CHECKV6: bx r023; CHECKT2D-LABEL: t2:24; CHECKT2D: ldr25; CHECKT2D-NEXT: ldr26; CHECKT2D-NEXT: bx r027 %tmp = load ptr, ptr @t ; <ptr> [#uses=1]28 %tmp.upgrd.2 = tail call i32 %tmp( ) ; <i32> [#uses=0]29 ret void30}31 32define void @t3() "frame-pointer"="all" {33; CHECKV6-LABEL: t3:34; CHECKV6: b _t235; CHECKELF-LABEL: t3:36; CHECKELF: b t237; CHECKT2D-LABEL: t3:38; CHECKT2D: b.w _t239 40 tail call void @t2( ) ; <i32> [#uses=0]41 ret void42}43 44; Sibcall optimization of expanded libcalls. rdar://870777745define double @t4(double %a) nounwind readonly ssp "frame-pointer"="all" {46entry:47; CHECKV6-LABEL: t4:48; CHECKV6: b _sin49; CHECKELF-LABEL: t4:50; CHECKELF: b sin51 %0 = tail call double @sin(double %a) nounwind readonly ; <double> [#uses=1]52 ret double %053}54 55define float @t5(float %a) nounwind readonly ssp "frame-pointer"="all" {56entry:57; CHECKV6-LABEL: t5:58; CHECKV6: b _sinf59; CHECKELF-LABEL: t5:60; CHECKELF: b sinf61 %0 = tail call float @sinf(float %a) nounwind readonly ; <float> [#uses=1]62 ret float %063}64 65declare float @sinf(float) nounwind readonly66 67declare double @sin(double) nounwind readonly68 69define i32 @t6(i32 %a, i32 %b) nounwind readnone "frame-pointer"="all" {70entry:71; CHECKV6-LABEL: t6:72; CHECKV6: b ___divsi373; CHECKELF-LABEL: t6:74; CHECKELF: b __aeabi_idiv75 %0 = sdiv i32 %a, %b76 ret i32 %077}78 79; Make sure the tail call instruction isn't deleted80; rdar://830933881declare void @foo() nounwind82 83define void @t7() nounwind "frame-pointer"="all" {84entry:85; CHECKT2D-LABEL: t7:86; CHECKT2D: it ne87; CHECKT2D-NEXT: bne.w _foo88; CHECKT2D-NEXT: LBB{{.*}}:89; CHECKT2D-NEXT: push90; CHECKT2D-NEXT: mov r7, sp91; CHECKT2D-NEXT: bl _foo92 br i1 undef, label %bb, label %bb1.lr.ph93 94bb1.lr.ph:95 tail call void @foo() nounwind96 unreachable97 98bb:99 tail call void @foo() nounwind100 ret void101}102 103; Make sure codegenprep is duplicating ret instructions to enable tail calls.104; rdar://11140249105define i32 @t8(i32 %x) nounwind ssp "frame-pointer"="none" {106entry:107; CHECKT2D-LABEL: t8:108; CHECKT2D-NOT: push109 %and = and i32 %x, 1110 %tobool = icmp eq i32 %and, 0111 br i1 %tobool, label %if.end, label %if.then112 113if.then: ; preds = %entry114; CHECKT2D: bne.w _a115 %call = tail call i32 @a(i32 %x) nounwind116 br label %return117 118if.end: ; preds = %entry119 %and1 = and i32 %x, 2120 %tobool2 = icmp eq i32 %and1, 0121 br i1 %tobool2, label %if.end5, label %if.then3122 123if.then3: ; preds = %if.end124; CHECKT2D: bmi.w _b125 %call4 = tail call i32 @b(i32 %x) nounwind126 br label %return127 128if.end5: ; preds = %if.end129; CHECKT2D: b.w _c130 %call6 = tail call i32 @c(i32 %x) nounwind131 br label %return132 133return: ; preds = %if.end5, %if.then3, %if.then134 %retval.0 = phi i32 [ %call, %if.then ], [ %call4, %if.then3 ], [ %call6, %if.end5 ]135 ret i32 %retval.0136}137 138declare i32 @a(i32)139 140declare i32 @b(i32)141 142declare i32 @c(i32)143 144; PR12419145; rdar://11195178146; Use the correct input chain for the tailcall node or else the call to147; _ZN9MutexLockD1Ev would be lost.148%class.MutexLock = type { i8 }149 150@x = external global i32, align 4151 152define i32 @t9() nounwind "frame-pointer"="all" {153; CHECKT2D-LABEL: t9:154; CHECKT2D: bl __ZN9MutexLockC1Ev155; CHECKT2D: bl __ZN9MutexLockD1Ev156; CHECKT2D: b.w ___divsi3157 %lock = alloca %class.MutexLock, align 1158 %1 = call ptr @_ZN9MutexLockC1Ev(ptr %lock)159 %2 = load i32, ptr @x, align 4160 %3 = sdiv i32 1000, %2161 %4 = call ptr @_ZN9MutexLockD1Ev(ptr %lock)162 ret i32 %3163}164 165declare ptr @_ZN9MutexLockC1Ev(ptr) unnamed_addr nounwind align 2166 167declare ptr @_ZN9MutexLockD1Ev(ptr) unnamed_addr nounwind align 2168 169; rdar://13827621170; Correctly preserve the input chain for the tailcall node in the bitcast case,171; otherwise the call to floorf is lost.172define float @libcall_tc_test2(ptr nocapture %a, float %b) "frame-pointer"="all" {173; CHECKT2D-LABEL: libcall_tc_test2:174; CHECKT2D: bl _floorf175; CHECKT2D: b.w _truncf176 %1 = load float, ptr %a, align 4177 %call = tail call float @floorf(float %1)178 store float %call, ptr %a, align 4179 %call1 = tail call float @truncf(float %b)180 ret float %call1181}182 183declare float @floorf(float) readnone184declare float @truncf(float) readnone185