1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
; RUN: llc --force-dwarf-frame-section %s -o - | FileCheck %s
; RUN: llc --filetype=obj %s -o - | llvm-readelf -s --unwind - | FileCheck %s --check-prefix=UNWIND
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv7m-arm-none-eabi"
; -Oz
; __attribute__((noinline)) int h(int a, int b) { return a + b; }
;
; int f(int a, int b, int c, int d) {
; if (a < 0)
; return -1;
; a = h(11 * a - b, b);
; return 2 + a * (a + b) / (c + d);
; }
;
; int g(int a, int b, int c, int d) {
; if (a < 0)
; return -1;
; a = h(11 * a - b, b);
; return 1 + a * (a + b) / (c + d);
; }
define hidden i32 @h(i32 %a, i32 %b) local_unnamed_addr #0 {
entry:
%add = add nsw i32 %b, %a
ret i32 %add
}
define hidden i32 @f(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #0 {
entry:
%cmp = icmp slt i32 %a, 0
br i1 %cmp, label %return, label %if.end
if.end: ; preds = %entry
%mul = mul nsw i32 %a, 11
%sub = sub nsw i32 %mul, %b
%call = tail call i32 @h(i32 %sub, i32 %b)
%add = add nsw i32 %call, %b
%mul1 = mul nsw i32 %add, %call
%add2 = add nsw i32 %d, %c
%div = sdiv i32 %mul1, %add2
%add3 = add nsw i32 %div, 2
br label %return
return: ; preds = %entry, %if.end
%retval.0 = phi i32 [ %add3, %if.end ], [ -1, %entry ]
ret i32 %retval.0
}
; CHECK-LABEL: f:
; ...
; CHECK: pac r12, lr, sp
; CHECK-NEXT: .save {r4, r5, r6, lr}
; CHECK-NEXT: push {r4, r5, r6, lr}
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: .cfi_offset lr, -4
; CHECK-NEXT: .cfi_offset r6, -8
; CHECK-NEXT: .cfi_offset r5, -12
; CHECK-NEXT: .cfi_offset r4, -16
; CHECK-NEXT: .save {ra_auth_code}
; CHECK-NEXT: str r12, [sp, #-4]!
; CHECK-NEXT: .cfi_def_cfa_offset 20
; CHECK-NEXT: .cfi_offset ra_auth_code, -20
; CHECK-NEXT: .pad #4
; CHECK-NEXT: sub sp, #4
; CHECK-NEXT: .cfi_def_cfa_offset 24
; ...
; CHECK: bl OUTLINED_FUNCTION_0
; ...
; CHECK: add sp, #4
; CHECK-NEXT: ldr r12, [sp], #4
; CHECK-NEXT: pop.w {r4, r5, r6, lr}
; CHECK-NEXT: aut r12, lr, sp
; CHECK-NEXT: bx lr
define hidden i32 @g(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #0 {
entry:
%cmp = icmp slt i32 %a, 0
br i1 %cmp, label %return, label %if.end
if.end: ; preds = %entry
%mul = mul nsw i32 %a, 11
%sub = sub nsw i32 %mul, %b
%call = tail call i32 @h(i32 %sub, i32 %b)
%add = add nsw i32 %call, %b
%mul1 = mul nsw i32 %add, %call
%add2 = add nsw i32 %d, %c
%div = sdiv i32 %mul1, %add2
%add3 = add nsw i32 %div, 1
br label %return
return: ; preds = %entry, %if.end
%retval.0 = phi i32 [ %add3, %if.end ], [ -1, %entry ]
ret i32 %retval.0
}
; CHECK-LABEL: g:
; CHECK: pac r12, lr, sp
; CHECK-NEXT: .save {r4, r5, r6, lr}
; CHECK-NEXT: push {r4, r5, r6, lr}
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: .cfi_offset lr, -4
; CHECK-NEXT: .cfi_offset r6, -8
; CHECK-NEXT: .cfi_offset r5, -12
; CHECK-NEXT: .cfi_offset r4, -16
; CHECK-NEXT: .save {ra_auth_code}
; CHECK-NEXT: str r12, [sp, #-4]!
; CHECK-NEXT: .cfi_def_cfa_offset 20
; CHECK-NEXT: .cfi_offset ra_auth_code, -20
; CHECK-NEXT: .pad #4
; CHECK-NEXT: sub sp, #4
; CHECK-NEXT: .cfi_def_cfa_offset 24
; ...
; CHECK: bl OUTLINED_FUNCTION_0
; ...
; CHECK: add sp, #4
; CHECK-NEXT: ldr r12, [sp], #4
; CHECK-NEXT: pop.w {r4, r5, r6, lr}
; CHECK-NEXT: aut r12, lr, sp
; CHECK-NEXT: bx lr
; CHECK-LABEL: OUTLINED_FUNCTION_0:
; CHECK: pac r12, lr, sp
; CHECK-NEXT: .save {ra_auth_code, lr}
; CHECK-NEXT: strd r12, lr, [sp, #-8]!
; CHECK-NEXT: .cfi_def_cfa_offset 8
; CHECK-NEXT: .cfi_offset lr, -4
; CHECK-NEXT: .cfi_offset ra_auth_code, -8
; ...
; CHECK: ldrd r12, lr, [sp], #8
; CHECK-NEXT: .cfi_def_cfa_offset 0
; CHECK-NEXT: .cfi_restore lr
; CHECK-NEXT: .cfi_undefined ra_auth_code
; CHECK-NEXT: aut r12, lr, sp
; CHECK-NEXT: bx lr
attributes #0 = { minsize noinline norecurse nounwind optsize readnone uwtable }
!llvm.module.flags = !{!0, !1, !2}
!0 = !{i32 1, !"branch-target-enforcement", i32 0}
!1 = !{i32 1, !"sign-return-address", i32 1}
!2 = !{i32 1, !"sign-return-address-all", i32 0}
; UNWIND-LABEL: FunctionAddress: 0x4
; UNWIND: 0x00 ; vsp = vsp + 4
; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
; UNWIND-NEXT: 0xAA ; pop {r4, r5, r6, lr}
; UNWIND-LABEL: FunctionAddress: 0x30
; UNWIND: 0x00 ; vsp = vsp + 4
; UNWIND-NEXT: 0xB4 ; pop ra_auth_code
; UNWIND-NEXT: 0xAA ; pop {r4, r5, r6, lr}
; UNWIND-LABEL: FunctionAddress: 0x5C
; UNWIND: Model: CantUnwind
; UNWIND-LABEL: 0000005d {{.*}} OUTLINED_FUNCTION_0
; UNWIND-LABEL: 00000005 {{.*}} f
; UNWIND-LABEL: 00000031 {{.*}} g
|