1 # RUN: llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu \
2 # RUN: -start-before aarch64-sls-hardening \
3 # RUN: -stop-after aarch64-sls-hardening -o - %s \
4 # RUN: | FileCheck %s --check-prefixes=CHECK
6 # Check when the BLR SLS hardening encounters a BLR/BTI bundle, the BTI
7 # instruction remains after the BLR is replaced with a BL.
8 # These BLR/BTI bundles are produced when calling a returns_twice function
9 # (like setjmp) indirectly.
11 define dso_local void @fn() #0 {
13 %fnptr = alloca ptr, align 8
14 store ptr @setjmp, ptr %fnptr, align 8
15 %0 = load ptr, ptr %fnptr, align 8
16 %call1 = call i32 %0(ptr noundef null) #1
20 ; Function Attrs: returns_twice
21 declare i32 @setjmp(ptr noundef) #1
23 attributes #0 = { "target-features"="+harden-sls-blr" }
24 attributes #1 = { returns_twice }
26 !llvm.module.flags = !{!0}
27 !0 = !{i32 8, !"branch-target-enforcement", i32 1}
31 exposesReturnsTwice: true
32 tracksRegLiveness: true
35 - { id: 0, name: fnptr, type: default, offset: -8, size: 8, alignment: 8,
36 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
37 local-offset: -8, debug-info-variable: '', debug-info-expression: '',
38 debug-info-location: '' }
39 - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
40 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true,
41 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
43 debugValueSubstitutions: []
51 early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.1)
52 frame-setup CFI_INSTRUCTION def_cfa_offset 16
53 frame-setup CFI_INSTRUCTION offset $w30, -16
54 $x8 = ADRP target-flags(aarch64-page, aarch64-got) @setjmp
55 renamable $x8 = LDRXui killed $x8, target-flags(aarch64-pageoff, aarch64-got, aarch64-nc) @setjmp
56 STRXui renamable $x8, $sp, 1 :: (store (s64) into %ir.fnptr)
57 $x0 = ORRXrs $xzr, $xzr, 0
58 BUNDLE implicit-def $lr, implicit-def $w30, implicit killed $x8, implicit $sp {
59 BLR killed renamable $x8, implicit-def $lr, implicit $sp
62 ; CHECK: BUNDLE implicit-def $lr, implicit-def $w30, implicit killed $x8, implicit $sp {
63 ; CHECK-NEXT: BL <mcsymbol __llvm_slsblr_thunk_x8>, implicit-def $lr, implicit $sp, implicit killed $x8
66 early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.1)