1 ; RUN: llc -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s --check-prefix=BTI
2 ; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel < %s | FileCheck %s --check-prefix=BTI
3 ; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel < %s | FileCheck %s --check-prefix=BTI
4 ; RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=+harden-sls-blr< %s | FileCheck %s --check-prefix=BTISLS
5 ; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -mattr=+harden-sls-blr< %s | FileCheck %s --check-prefix=BTISLS
6 ; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel -mattr=+harden-sls-blr< %s | FileCheck %s --check-prefix=BTISLS
7 ; RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=+no-bti-at-return-twice < %s | \
8 ; RUN: FileCheck %s --check-prefix=NOBTI
9 ; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -mattr=+no-bti-at-return-twice < %s | \
10 ; RUN: FileCheck %s --check-prefix=NOBTI
11 ; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel -mattr=+no-bti-at-return-twice < %s | \
12 ; RUN: FileCheck %s --check-prefix=NOBTI
16 ; extern int setjmp(ptr);
17 ; extern void notsetjmp(void);
21 ; setjmp(0); // With the attributes removed.
22 ; int (*fnptr)(ptr) = setjmp;
23 ; fnptr(0); // With attributes added.
27 define void @bbb() #1 {
33 ; BTI: blr x{{[0-9]+}}
40 ; BTISLS-NEXT: hint #36
42 ; BTISLS-NEXT: hint #36
43 ; BTISLS: bl __llvm_slsblr_thunk_x{{[0-9]+}}
44 ; BTISLS-NEXT: hint #36
45 ; BTISLS: bl notsetjmp
46 ; BTISLS-NOT: hint #36
53 ; NOBTI: blr x{{[0-9]+}}
58 %fnptr = alloca ptr, align 8
59 ; The frontend may apply attributes to the call, but it doesn't have to. We
60 ; should be looking at the call base, which looks past that to the called function.
61 %call = call i32 @setjmp(ptr noundef null) #0
62 %call1 = call i32 @setjmp(ptr noundef null)
63 store ptr @setjmp, ptr %fnptr, align 8
64 %0 = load ptr, ptr %fnptr, align 8
65 ; Clang does not attach the attribute here but if it did, it should work.
66 %call2 = call i32 %0(ptr noundef null) #0
67 call void @notsetjmp()
71 declare i32 @setjmp(ptr noundef) #0
72 declare void @notsetjmp()
74 attributes #0 = { returns_twice }
75 attributes #1 = { "branch-target-enforcement" }