1 ; RUN: llc -mtriple=aarch64-none-linux-gnu -enable-machine-outliner < %s | FileCheck %s --check-prefix=BTI
2 ; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -enable-machine-outliner < %s | \
3 ; RUN: FileCheck %s --check-prefix=BTI
4 ; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel -enable-machine-outliner < %s | \
5 ; RUN: FileCheck %s --check-prefix=BTI
6 ; RUN: llc -mtriple=aarch64-none-linux-gnu -enable-machine-outliner -mattr=+no-bti-at-return-twice < %s | \
7 ; RUN: FileCheck %s --check-prefix=NOBTI
8 ; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -enable-machine-outliner -mattr=+no-bti-at-return-twice < %s | \
9 ; RUN: FileCheck %s --check-prefix=NOBTI
10 ; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel -enable-machine-outliner -mattr=+no-bti-at-return-twice < %s | \
11 ; RUN: FileCheck %s --check-prefix=NOBTI
13 ; Check that the outliner does not split up the call to setjmp and the bti after it.
14 ; When we do not insert a bti, it is allowed to move the setjmp call into an outlined function.
18 ; extern int setjmp(ptr);
20 ; int f(int a, int b, int c, int d) {
22 ; return 1 + a * (a + b) / (c + d);
25 ; int g(int a, int b, int c, int d) {
27 ; return 2 + a * (a + b) / (c + d);
30 define i32 @f(i32 noundef %a, i32 noundef %b, i32 noundef %c, i32 noundef %d) #0 {
32 ; BTI: bl OUTLINED_FUNCTION_1
35 ; BTI-NEXT: bl OUTLINED_FUNCTION_0
38 ; NOBTI: bl OUTLINED_FUNCTION_0
39 ; NOBTI-NEXT: bl OUTLINED_FUNCTION_1
42 %call = call i32 @setjmp(ptr noundef null) #1
43 %add = add nsw i32 %b, %a
44 %mul = mul nsw i32 %add, %a
45 %add1 = add nsw i32 %d, %c
46 %div = sdiv i32 %mul, %add1
47 %add2 = add nsw i32 %div, 1
51 declare i32 @setjmp(ptr noundef) #0
53 define i32 @g(i32 noundef %a, i32 noundef %b, i32 noundef %c, i32 noundef %d) #0 {
55 ; BTI: bl OUTLINED_FUNCTION_1
58 ; BTI-NEXT: bl OUTLINED_FUNCTION_0
61 ; NOBTI: bl OUTLINED_FUNCTION_0
62 ; NOBTI-NEXT: bl OUTLINED_FUNCTION_1
65 %call = call i32 @setjmp(ptr noundef null) #1
66 %add = add nsw i32 %b, %a
67 %mul = mul nsw i32 %add, %a
68 %add1 = add nsw i32 %d, %c
69 %div = sdiv i32 %mul, %add1
70 %add2 = add nsw i32 %div, 2
74 ; NOBTI-LABEL: OUTLINED_FUNCTION_0:
76 ; NOBTI: OUTLINED_FUNCTION_1:
79 attributes #0 = { "branch-target-enforcement" }
80 attributes #1 = { returns_twice }