1 ; RUN: llc --verify-machineinstrs --force-dwarf-frame-section %s -o - | FileCheck %s
2 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
3 target triple = "thumbv7m-unknown-unknown-eabi"
6 ; __attribute__((noinline)) int h(int a, int b) { return a + b; }
8 ; int f(int a, int b, int c, int d) {
12 ; return 2 + a * (a + b) / (c + d);
15 ; int g(int a, int b, int c, int d) {
19 ; return 1 + a * (a + b) / (c + d);
21 ; Check CFI instructions inside the outlined function.
23 define dso_local i32 @h(i32 %a, i32 %b) local_unnamed_addr #0 {
25 %add = add nsw i32 %b, %a
29 define dso_local i32 @f(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #1 {
31 %cmp = icmp slt i32 %a, 0
32 br i1 %cmp, label %return, label %if.end
34 if.end: ; preds = %entry
35 %call = tail call i32 @h(i32 %a, i32 %b) #2
36 %add = add nsw i32 %call, %b
37 %mul = mul nsw i32 %add, %call
38 %add1 = add nsw i32 %d, %c
39 %div = sdiv i32 %mul, %add1
40 %add2 = add nsw i32 %div, 2
43 return: ; preds = %entry, %if.end
44 %retval.0 = phi i32 [ %add2, %if.end ], [ -1, %entry ]
48 define dso_local i32 @g(i32 %a, i32 %b, i32 %c, i32 %d) local_unnamed_addr #1 {
50 %cmp = icmp slt i32 %a, 0
51 br i1 %cmp, label %return, label %if.end
53 if.end: ; preds = %entry
54 %call = tail call i32 @h(i32 %a, i32 %b) #2
55 %add = add nsw i32 %call, %b
56 %mul = mul nsw i32 %add, %call
57 %add1 = add nsw i32 %d, %c
58 %div = sdiv i32 %mul, %add1
59 %add2 = add nsw i32 %div, 1
62 return: ; preds = %entry, %if.end
63 %retval.0 = phi i32 [ %add2, %if.end ], [ -1, %entry ]
67 ; CHECK-LABEL: OUTLINED_FUNCTION_0:
68 ; CHECK: str lr, [sp, #-8]!
69 ; CHECK-NEXT: .cfi_def_cfa_offset 8
70 ; CHECK-NEXT: .cfi_offset lr, -8
71 ; CHECK: ldr lr, [sp], #8
72 ; CHECK-NEXT: .cfi_def_cfa_offset 0
73 ; CHECK-NEXT: .cfi_restore lr
76 attributes #0 = { minsize noinline norecurse nounwind optsize readnone }
77 attributes #1 = { minsize norecurse nounwind optsize readnone }
78 attributes #2 = { minsize optsize }