1 # RUN: llc -mtriple=aarch64-apple-darwin -run-pass=prologepilog \
2 # RUN: -run-pass=machine-outliner -verify-machineinstrs %s -o - | FileCheck %s
3 # Check that we save LR to a callee-saved register when possible.
4 # foo() should use a callee-saved register. However, bar() should not.
7 define void @foo() #0 {
11 define void @bar() #0 {
15 attributes #0 = { minsize noinline noredzone "frame-pointer"="all" }
18 # Make sure that when we outline and a register is available, we
19 # use it to save + restore LR instead of SP.
20 # Also make sure that we can call functions that require no save as the same
24 # CHECK-DAG: $x[[REG:[0-9]+]] = ORRXrs $xzr, $lr, 0
26 # CHECK-NEXT: $lr = ORRXrs $xzr, $x[[REG]], 0
28 # CHECK-DAG: $x[[REG]] = ORRXrs $xzr, $lr, 0
30 # CHECK-NEXT: $lr = ORRXrs $xzr, $x[[REG]], 0
32 # CHECK-DAG: $x[[REG]] = ORRXrs $xzr, $lr, 0
34 # CHECK-NEXT: $lr = ORRXrs $xzr, $x[[REG]], 0
36 # CHECK-NOT: $x[[REG]] = ORRXrs $xzr, $lr, 0
39 tracksRegLiveness: true
83 # Convoluted case that shows that we'll still save to the stack when there are
84 # no approprate registers available.
85 # The live-in lists do not contain x16 or x17 since including them would cause
86 # nothing to be outlined.
87 # They also deliberately don't contain x18 to show that on Darwin we won't store
89 # CHECK-LABEL: name: bar
90 # CHECK: early-clobber $sp = STRXpre $lr, $sp, -16
92 # CHECK-DAG: early-clobber $sp, $lr = LDRXpost $sp, 16
93 # CHECK: early-clobber $sp = STRXpre $lr, $sp, -16
95 # CHECK-DAG: early-clobber $sp, $lr = LDRXpost $sp, 16
96 # CHECK: early-clobber $sp = STRXpre $lr, $sp, -16
98 # CHECK-NEXT: early-clobber $sp, $lr = LDRXpost $sp, 16
100 tracksRegLiveness: true
103 liveins: $lr, $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x19, $x20, $x21, $x22, $x23, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28
105 $w10 = ORRWri $wzr, 1
106 $w10 = ORRWri $wzr, 1
107 $w10 = ORRWri $wzr, 1
108 $w10 = ORRWri $wzr, 1
109 $w10 = ORRWri $wzr, 1
110 $w12 = ORRWri $wzr, 2
112 liveins: $lr, $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x19, $x20, $x21, $x22, $x23, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28
113 $w10 = ORRWri $wzr, 1
114 $w10 = ORRWri $wzr, 1
115 $w10 = ORRWri $wzr, 1
116 $w10 = ORRWri $wzr, 1
117 $w10 = ORRWri $wzr, 1
118 $w12 = ORRWri $wzr, 2
120 liveins: $lr, $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x19, $x20, $x21, $x22, $x23, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28
121 $w10 = ORRWri $wzr, 1
122 $w10 = ORRWri $wzr, 1
123 $w10 = ORRWri $wzr, 1
124 $w10 = ORRWri $wzr, 1
125 $w10 = ORRWri $wzr, 1
126 $w12 = ORRWri $wzr, 2
128 liveins: $lr, $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x19, $x20, $x21, $x22, $x23, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28