1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc -mtriple=thumbv8.1m.main-arm-none-eabi < %s | FileCheck %s --check-prefix=BTI
3 ; RUN: llc -mtriple=thumbv8.1m.main-arm-none-eabi -mattr=+no-bti-at-return-twice < %s | \
4 ; RUN: FileCheck %s --check-prefix=NOBTI
10 ; extern void bar(int x);
20 @buf = global [20 x i64] zeroinitializer, align 8
22 define i32 @foo(i32 %x) "branch-target-enforcement" {
24 ; BTI: @ %bb.0: @ %entry
26 ; BTI-NEXT: .save {r4, lr}
27 ; BTI-NEXT: push {r4, lr}
28 ; BTI-NEXT: mov r4, r0
29 ; BTI-NEXT: movw r0, :lower16:buf
30 ; BTI-NEXT: movt r0, :upper16:buf
33 ; BTI-NEXT: cmp r0, #0
35 ; BTI-NEXT: movne r0, #0
36 ; BTI-NEXT: popne {r4, pc}
37 ; BTI-NEXT: .LBB0_1: @ %if.else
38 ; BTI-NEXT: mov r0, r4
40 ; BTI-NEXT: mov r0, r4
41 ; BTI-NEXT: pop {r4, pc}
44 ; NOBTI: @ %bb.0: @ %entry
46 ; NOBTI-NEXT: .save {r4, lr}
47 ; NOBTI-NEXT: push {r4, lr}
48 ; NOBTI-NEXT: mov r4, r0
49 ; NOBTI-NEXT: movw r0, :lower16:buf
50 ; NOBTI-NEXT: movt r0, :upper16:buf
51 ; NOBTI-NEXT: bl setjmp
52 ; NOBTI-NEXT: cmp r0, #0
54 ; NOBTI-NEXT: movne r0, #0
55 ; NOBTI-NEXT: popne {r4, pc}
56 ; NOBTI-NEXT: .LBB0_1: @ %if.else
57 ; NOBTI-NEXT: mov r0, r4
59 ; NOBTI-NEXT: mov r0, r4
60 ; NOBTI-NEXT: pop {r4, pc}
63 %call = call i32 @setjmp(ptr @buf) #0
64 %tobool.not = icmp eq i32 %call, 0
65 br i1 %tobool.not, label %if.else, label %if.end
67 if.else: ; preds = %entry
68 call void @bar(i32 %x)
71 if.end: ; preds = %entry, %if.else
72 %x.addr.0 = phi i32 [ %x, %if.else ], [ 0, %entry ]
76 ;; Check that the BL to setjmp correctly clobbers LR
78 define i32 @baz() "branch-target-enforcement" {
80 ; BTI: @ %bb.0: @ %entry
82 ; BTI-NEXT: .save {r7, lr}
83 ; BTI-NEXT: push {r7, lr}
85 ; BTI-NEXT: sub sp, #160
86 ; BTI-NEXT: mov r0, sp
89 ; BTI-NEXT: movs r0, #0
90 ; BTI-NEXT: add sp, #160
91 ; BTI-NEXT: pop {r7, pc}
94 ; NOBTI: @ %bb.0: @ %entry
96 ; NOBTI-NEXT: .save {r7, lr}
97 ; NOBTI-NEXT: push {r7, lr}
98 ; NOBTI-NEXT: .pad #160
99 ; NOBTI-NEXT: sub sp, #160
100 ; NOBTI-NEXT: mov r0, sp
101 ; NOBTI-NEXT: bl setjmp
102 ; NOBTI-NEXT: movs r0, #0
103 ; NOBTI-NEXT: add sp, #160
104 ; NOBTI-NEXT: pop {r7, pc}
106 %outgoing_jb = alloca [20 x i64], align 8
107 %call = call i32 @setjmp(ptr %outgoing_jb) returns_twice
111 declare void @bar(i32)
112 declare i32 @setjmp(ptr) #0
114 attributes #0 = { returns_twice }