1; RUN: llc -verify-machineinstrs -enable-machine-outliner -mtriple \
2; RUN: aarch64-arm-linux-gnu %s -o - | FileCheck %s
3
4; Check that outlined functions use the dedicated RETAA/RETAB instructions
5; to sign their return address if available.
6
7define void @a() #0 {
8; CHECK-LABEL:      a:                                     // @a
9; CHECK:            // %bb.0:
10; CHECK-NEXT:               pacibsp
11; CHECK:                    bl [[OUTLINED_FUNC:OUTLINED_FUNCTION_[0-9]+]]
12  %1 = alloca i32, align 4
13  %2 = alloca i32, align 4
14  %3 = alloca i32, align 4
15  %4 = alloca i32, align 4
16  %5 = alloca i32, align 4
17  %6 = alloca i32, align 4
18  store i32 1, i32* %1, align 4
19  store i32 2, i32* %2, align 4
20  store i32 3, i32* %3, align 4
21  store i32 4, i32* %4, align 4
22  store i32 5, i32* %5, align 4
23  store i32 6, i32* %6, align 4
24; CHECK:                  retab
25; CHECK-NOT:              auti[a,b]sp
26  ret void
27}
28
29define void @b() #0 {
30; CHECK-LABEL:      b:                                     // @b
31; CHECK:            // %bb.0:
32; CHECK-NEXT:               pacibsp
33; CHECK:                    bl OUTLINED_FUNC
34  %1 = alloca i32, align 4
35  %2 = alloca i32, align 4
36  %3 = alloca i32, align 4
37  %4 = alloca i32, align 4
38  %5 = alloca i32, align 4
39  %6 = alloca i32, align 4
40  store i32 1, i32* %1, align 4
41  store i32 2, i32* %2, align 4
42  store i32 3, i32* %3, align 4
43  store i32 4, i32* %4, align 4
44  store i32 5, i32* %5, align 4
45  store i32 6, i32* %6, align 4
46; CHECK:                  retab
47; CHECK-NOT:              auti[a,b]sp
48  ret void
49}
50
51define void @c() #0 {
52; CHECK-LABEL:      c:                                     // @c
53; CHECK:            // %bb.0:
54; CHECK-NEXT:               pacibsp
55; CHECK:                    bl OUTLINED_FUNC
56  %1 = alloca i32, align 4
57  %2 = alloca i32, align 4
58  %3 = alloca i32, align 4
59  %4 = alloca i32, align 4
60  %5 = alloca i32, align 4
61  %6 = alloca i32, align 4
62  store i32 1, i32* %1, align 4
63  store i32 2, i32* %2, align 4
64  store i32 3, i32* %3, align 4
65  store i32 4, i32* %4, align 4
66  store i32 5, i32* %5, align 4
67  store i32 6, i32* %6, align 4
68; CHECK:                  retab
69; CHECK-NOT:              auti[a,b]sp
70  ret void
71}
72
73attributes #0 = { "sign-return-address"="all"
74                  "sign-return-address-key"="b_key"
75                  "target-features"="+v8.3a"
76                  nounwind }
77
78; CHECK:            OUTLINED_FUNC
79; CHECK:            // %bb.0:
80; CHECK-NEXT:               .cfi_b_key_frame
81; CHECK-NEXT:               pacibsp
82; CHECK:                    retab
83; CHECK-NOT:                auti[a,b]sp
84