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 $__llvm_slsblr_thunk_x8 = comdat any
13 define dso_local void @fn() #0 {
15 %fnptr = alloca ptr, align 8
16 store ptr @setjmp, ptr %fnptr, align 8
17 %0 = load ptr, ptr %fnptr, align 8
18 %call1 = call i32 %0(ptr noundef null) #1
22 ; Function Attrs: returns_twice
23 declare i32 @setjmp(ptr noundef) #1
25 ; Function Attrs: naked nounwind
26 define linkonce_odr hidden void @__llvm_slsblr_thunk_x8() #2 comdat {
31 attributes #0 = { "target-features"="+harden-sls-blr" }
32 attributes #1 = { returns_twice }
33 attributes #2 = { naked nounwind }
35 !llvm.module.flags = !{!0}
36 !0 = !{i32 8, !"branch-target-enforcement", i32 1}
40 exposesReturnsTwice: true
41 tracksRegLiveness: true
44 - { id: 0, name: fnptr, type: default, offset: -8, size: 8, alignment: 8,
45 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
46 local-offset: -8, debug-info-variable: '', debug-info-expression: '',
47 debug-info-location: '' }
48 - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 16,
49 stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true,
50 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
52 debugValueSubstitutions: []
60 early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.1)
61 frame-setup CFI_INSTRUCTION def_cfa_offset 16
62 frame-setup CFI_INSTRUCTION offset $w30, -16
63 $x8 = ADRP target-flags(aarch64-page, aarch64-got) @setjmp
64 renamable $x8 = LDRXui killed $x8, target-flags(aarch64-pageoff, aarch64-got, aarch64-nc) @setjmp
65 STRXui renamable $x8, $sp, 1 :: (store (s64) into %ir.fnptr)
66 $x0 = ORRXrs $xzr, $xzr, 0
67 BUNDLE implicit-def $lr, implicit-def $w30, implicit killed $x8, implicit $sp {
68 BLR killed renamable $x8, implicit-def $lr, implicit $sp
71 ; CHECK: BUNDLE implicit-def $lr, implicit-def $w30, implicit killed $x8, implicit $sp {
72 ; CHECK-NEXT: BL <mcsymbol __llvm_slsblr_thunk_x8>, implicit-def $lr, implicit $sp, implicit killed $x8
75 early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.1)
79 name: __llvm_slsblr_thunk_x8
80 tracksRegLiveness: true
85 $x16 = ORRXrs $xzr, $x8, 0
87 SpeculationBarrierISBDSBEndBB