xref: /llvm-project/llvm/test/CodeGen/AArch64/setjmp-bti-no-enforcement.ll (revision 5ddce70ef0e5a641d7fea95e31fc5e2439cb98cb)
1; RUN: llc -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s --check-prefix=NOBTI
2; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel < %s | FileCheck %s --check-prefix=NOBTI
3; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel < %s | FileCheck %s --check-prefix=NOBTI
4; RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=+no-bti-at-return-twice < %s | \
5; RUN: FileCheck %s --check-prefix=NOBTI
6; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -mattr=+no-bti-at-return-twice < %s | \
7; RUN: FileCheck %s --check-prefix=NOBTI
8; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel -mattr=+no-bti-at-return-twice < %s | \
9; RUN: FileCheck %s --check-prefix=NOBTI
10
11; Same as setjmp-bti.ll except that we do not enable branch target enforcement for this
12; module. There should be no combination of options that leads to a bti being emitted.
13
14; C source
15; --------
16; extern int setjmp(ptr);
17; extern void notsetjmp(void);
18;
19; void bbb(void) {
20;   setjmp(0);
21;   int (*fnptr)(ptr) = setjmp;
22;   fnptr(0);
23;   notsetjmp();
24; }
25
26define void @bbb() {
27; NOBTI-LABEL: bbb:
28; NOBTI:     bl setjmp
29; NOBTI-NOT: hint #36
30; NOBTI:     blr x{{[0-9]+}}
31; NOBTI-NOT: hint #36
32; NOBTI:     bl notsetjmp
33; NOBTI-NOT: hint #36
34
35entry:
36  %fnptr = alloca ptr, align 8
37  %call = call i32 @setjmp(ptr noundef null) #0
38  store ptr @setjmp, ptr %fnptr, align 8
39  %0 = load ptr, ptr %fnptr, align 8
40  %call1 = call i32 %0(ptr noundef null) #0
41  call void @notsetjmp()
42  ret void
43}
44
45declare i32 @setjmp(ptr noundef) #0
46declare void @notsetjmp()
47
48attributes #0 = { returns_twice }
49
50; !llvm.module.flags = !{!0}
51; !0 = !{i32 8, !"branch-target-enforcement", i32 1}
52