1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc -mtriple=thumbv7m-none-none-eabi < %s | FileCheck %s
4 target datalayout = "e-m:o-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
6 %struct.wibble = type { [30 x i8], i8, i32 }
7 %struct.eggs = type { i32, [30 x i8], i8, i8, i8, [3 x i8] }
9 @global = external global [3 x %struct.wibble], align 4
10 @global.1 = external global [3 x %struct.wibble], align 4
12 ; Test case to make sure calling an outlined function does not clobber LR used
13 ; by a tail call in caller.
14 define void @test(ptr nocapture noundef writeonly %arg, i32 noundef %arg1, i8 noundef zeroext %arg2) unnamed_addr #0 {
16 ; CHECK: @ %bb.0: @ %bb
17 ; CHECK-NEXT: cmp r1, #2
18 ; CHECK-NEXT: beq .LBB0_3
19 ; CHECK-NEXT: @ %bb.1: @ %bb
20 ; CHECK-NEXT: cmp r1, #1
21 ; CHECK-NEXT: bne .LBB0_5
22 ; CHECK-NEXT: @ %bb.2: @ %bb4
23 ; CHECK-NEXT: movs r1, #1
24 ; CHECK-NEXT: strb.w r1, [r0, #36]
25 ; CHECK-NEXT: movs r1, #30
26 ; CHECK-NEXT: strb.w r1, [r0, #34]
27 ; CHECK-NEXT: add.w r1, r2, r2, lsl #3
28 ; CHECK-NEXT: ldr r2, .LCPI0_1
29 ; CHECK-NEXT: b .LBB0_4
30 ; CHECK-NEXT: .LBB0_3: @ %bb14
31 ; CHECK-NEXT: movs r1, #1
32 ; CHECK-NEXT: strb.w r1, [r0, #36]
33 ; CHECK-NEXT: movs r1, #30
34 ; CHECK-NEXT: strb.w r1, [r0, #34]
35 ; CHECK-NEXT: add.w r1, r2, r2, lsl #3
36 ; CHECK-NEXT: ldr r2, .LCPI0_0
37 ; CHECK-NEXT: .LBB0_4: @ %bb4
38 ; CHECK-NEXT: add.w r1, r2, r1, lsl #2
39 ; CHECK-NEXT: adds r0, #4
40 ; CHECK-NEXT: movs r2, #30
41 ; CHECK-NEXT: b __aeabi_memcpy
42 ; CHECK-NEXT: .LBB0_5: @ %bb24
43 ; CHECK-NEXT: .save {r7, lr}
44 ; CHECK-NEXT: push {r7, lr}
45 ; CHECK-NEXT: bl wombat
48 ; CHECK-NEXT: pop {r7, pc}
49 ; CHECK-NEXT: .p2align 2
50 ; CHECK-NEXT: @ %bb.6:
51 ; CHECK-NEXT: .LCPI0_0:
52 ; CHECK-NEXT: .long global.1
53 ; CHECK-NEXT: .LCPI0_1:
54 ; CHECK-NEXT: .long global
56 %gep = getelementptr inbounds %struct.eggs, ptr %arg, i32 0, i32 4
57 %zext = zext i8 %arg2 to i32
58 switch i32 %arg1, label %bb24 [
64 store i8 1, ptr %gep, align 4, !tbaa !6
65 %gep5 = getelementptr inbounds [3 x %struct.wibble], ptr @global, i32 0, i32 %zext
66 %gep6 = getelementptr inbounds [3 x %struct.wibble], ptr @global, i32 0, i32 %zext, i32 2
67 %load = load i32, ptr %gep6, align 4, !tbaa !11
68 %gep7 = getelementptr inbounds [3 x %struct.wibble], ptr @global, i32 0, i32 %zext, i32 1
69 %load8 = load i8, ptr %gep7, align 2, !tbaa !13
70 %gep9 = getelementptr inbounds %struct.eggs, ptr %arg, i32 0, i32 3
71 %gep10 = getelementptr inbounds %struct.eggs, ptr %arg, i32 0, i32 2
72 store i8 30, ptr %gep10, align 2, !tbaa !16
73 %gep11 = getelementptr inbounds %struct.eggs, ptr %arg, i32 0, i32 1
74 tail call void @llvm.memcpy.p0.p0.i32(ptr noundef nonnull align 1 dereferenceable(30) %gep11, ptr noundef nonnull align 4 dereferenceable(30) %gep5, i32 30, i1 false)
78 store i8 1, ptr %gep, align 4, !tbaa !6
79 %gep16 = getelementptr inbounds [3 x %struct.wibble], ptr @global.1, i32 0, i32 %zext
80 %gep17 = getelementptr inbounds [3 x %struct.wibble], ptr @global.1, i32 0, i32 %zext, i32 2
81 %load18 = load i32, ptr %gep17, align 4, !tbaa !21
82 %gep19 = getelementptr inbounds [3 x %struct.wibble], ptr @global.1, i32 0, i32 %zext, i32 1
83 %load20 = load i8, ptr %gep19, align 2, !tbaa !23
84 %gep21 = getelementptr inbounds %struct.eggs, ptr %arg, i32 0, i32 3
85 %gep22 = getelementptr inbounds %struct.eggs, ptr %arg, i32 0, i32 2
86 store i8 30, ptr %gep22, align 2, !tbaa !16
87 %gep23 = getelementptr inbounds %struct.eggs, ptr %arg, i32 0, i32 1
88 tail call void @llvm.memcpy.p0.p0.i32(ptr noundef nonnull align 1 dereferenceable(30) %gep23, ptr noundef nonnull align 4 dereferenceable(30) %gep16, i32 30, i1 false)
92 tail call void @wombat()
93 tail call void asm sideeffect "", ""()
96 bb26: ; preds = %bb24, %bb14, %bb12, %bb4, %bb3
100 declare void @wombat()
102 declare void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg) #2
104 attributes #0 = { minsize noimplicitfloat nounwind optsize }
106 !6 = !{!7, !9, i64 36}
107 !7 = !{!"", !8, i64 0, !9, i64 4, !9, i64 34, !9, i64 35, !9, i64 36, !9, i64 37}
108 !8 = !{!"long", !9, i64 0}
109 !9 = !{!"omnipotent char", !10, i64 0}
110 !10 = !{!"Simple C/C++ TBAA"}
111 !11 = !{!12, !8, i64 32}
112 !12 = !{!"B", !9, i64 0, !9, i64 30, !8, i64 32}
113 !13 = !{!12, !9, i64 30}
114 !14 = !{!7, !8, i64 0}
115 !15 = !{!7, !9, i64 35}
116 !16 = !{!7, !9, i64 34}
117 !21 = !{!22, !8, i64 32}
118 !22 = !{!"A", !9, i64 0, !9, i64 30, !8, i64 32}
119 !23 = !{!22, !9, i64 30}