1 ; RUN: llc < %s -mtriple=armv7-apple-ios6.0 | FileCheck %s 2 ; RUN: llc < %s -mtriple=thumbv7-apple-ios6.0 | FileCheck %s -check-prefix=THUMB 3 ; RUN: llc < %s -mtriple=armv7-unknown-nacl-gnueabi | FileCheck %s -check-prefix=NACL 4 ; RUN: llc < %s -mtriple=armv5-none-linux-gnueabi | FileCheck %s -check-prefix=NOMOVT 5 6 ; NOMOVT-NOT: movt 7 8 ; rdar://9877866 9 %struct.SmallStruct = type { i32, [8 x i32], [37 x i8] } 10 %struct.LargeStruct = type { i32, [1001 x i8], [300 x i32] } 11 12 define i32 @f() nounwind ssp { 13 entry: 14 ; CHECK-LABEL: f: 15 ; CHECK: ldr 16 ; CHECK: str 17 ; CHECK-NOT:bne 18 ; THUMB-LABEL: f: 19 ; THUMB: ldr 20 ; THUMB: str 21 ; THUMB-NOT:bne 22 %st = alloca %struct.SmallStruct, align 4 23 %call = call i32 @e1(%struct.SmallStruct* byval %st) 24 ret i32 0 25 } 26 27 ; Generate a loop for large struct byval 28 define i32 @g() nounwind ssp { 29 entry: 30 ; CHECK-LABEL: g: 31 ; CHECK: ldr 32 ; CHECK: sub 33 ; CHECK: str 34 ; CHECK: bne 35 ; THUMB-LABEL: g: 36 ; THUMB: ldr 37 ; THUMB: sub 38 ; THUMB: str 39 ; THUMB: bne 40 ; NACL-LABEL: g: 41 ; Ensure that use movw instead of constpool for the loop trip count. But don't 42 ; match the __stack_chk_guard movw 43 ; NACL: movw r{{[1-9]}}, # 44 ; NACL: ldr 45 ; NACL: sub 46 ; NACL: str 47 ; NACL: bne 48 %st = alloca %struct.LargeStruct, align 4 49 %call = call i32 @e2(%struct.LargeStruct* byval %st) 50 ret i32 0 51 } 52 53 ; Generate a loop using NEON instructions 54 define i32 @h() nounwind ssp { 55 entry: 56 ; CHECK-LABEL: h: 57 ; CHECK: vld1 58 ; CHECK: sub 59 ; CHECK: vst1 60 ; CHECK: bne 61 ; THUMB-LABEL: h: 62 ; THUMB: vld1 63 ; THUMB: sub 64 ; THUMB: vst1 65 ; THUMB: bne 66 ; NACL: movw r{{[1-9]}}, # 67 ; NACL: vld1 68 ; NACL: sub 69 ; NACL: vst1 70 ; NACL: bne 71 %st = alloca %struct.LargeStruct, align 16 72 %call = call i32 @e3(%struct.LargeStruct* byval align 16 %st) 73 ret i32 0 74 } 75 76 declare i32 @e1(%struct.SmallStruct* nocapture byval %in) nounwind 77 declare i32 @e2(%struct.LargeStruct* nocapture byval %in) nounwind 78 declare i32 @e3(%struct.LargeStruct* nocapture byval align 16 %in) nounwind 79 80 ; rdar://12442472 81 ; We can't do tail call since address of s is passed to the callee and part of 82 ; s is in caller's local frame. 83 define void @f3(%struct.SmallStruct* nocapture byval %s) nounwind optsize { 84 ; CHECK-LABEL: f3 85 ; CHECK: bl _consumestruct 86 ; THUMB-LABEL: f3 87 ; THUMB: blx _consumestruct 88 entry: 89 %0 = bitcast %struct.SmallStruct* %s to i8* 90 tail call void @consumestruct(i8* %0, i32 80) optsize 91 ret void 92 } 93 94 define void @f4(%struct.SmallStruct* nocapture byval %s) nounwind optsize { 95 ; CHECK-LABEL: f4 96 ; CHECK: bl _consumestruct 97 ; THUMB-LABEL: f4 98 ; THUMB: blx _consumestruct 99 entry: 100 %addr = getelementptr inbounds %struct.SmallStruct, %struct.SmallStruct* %s, i32 0, i32 0 101 %0 = bitcast i32* %addr to i8* 102 tail call void @consumestruct(i8* %0, i32 80) optsize 103 ret void 104 } 105 106 ; We can do tail call here since s is in the incoming argument area. 107 define void @f5(i32 %a, i32 %b, i32 %c, i32 %d, %struct.SmallStruct* nocapture byval %s) nounwind optsize { 108 ; CHECK-LABEL: f5 109 ; CHECK: b _consumestruct 110 ; THUMB-LABEL: f5 111 ; THUMB: b.w _consumestruct 112 entry: 113 %0 = bitcast %struct.SmallStruct* %s to i8* 114 tail call void @consumestruct(i8* %0, i32 80) optsize 115 ret void 116 } 117 118 define void @f6(i32 %a, i32 %b, i32 %c, i32 %d, %struct.SmallStruct* nocapture byval %s) nounwind optsize { 119 ; CHECK-LABEL: f6 120 ; CHECK: b _consumestruct 121 ; THUMB-LABEL: f6 122 ; THUMB: b.w _consumestruct 123 entry: 124 %addr = getelementptr inbounds %struct.SmallStruct, %struct.SmallStruct* %s, i32 0, i32 0 125 %0 = bitcast i32* %addr to i8* 126 tail call void @consumestruct(i8* %0, i32 80) optsize 127 ret void 128 } 129 130 declare void @consumestruct(i8* nocapture %structp, i32 %structsize) nounwind 131 132 ; PR17309 133 %struct.I.8 = type { [10 x i32], [3 x i8] } 134 135 declare void @use_I(%struct.I.8* byval) 136 define void @test_I_16() { 137 ; CHECK-LABEL: test_I_16 138 ; CHECK: ldrb 139 ; CHECK: strb 140 ; THUMB-LABEL: test_I_16 141 ; THUMB: ldrb 142 ; THUMB: strb 143 entry: 144 call void @use_I(%struct.I.8* byval align 16 undef) 145 ret void 146 } 147