69 lines · plain
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=CHECK5 6# Check when the BLR SLS hardening encounters a BLR/BTI bundle, the BTI7# instruction remains after the BLR is replaced with a BL.8# These BLR/BTI bundles are produced when calling a returns_twice function9# (like setjmp) indirectly.10--- |11 define dso_local void @fn() #0 {12 entry:13 %fnptr = alloca ptr, align 814 store ptr @setjmp, ptr %fnptr, align 815 %0 = load ptr, ptr %fnptr, align 816 %call1 = call i32 %0(ptr noundef null) #117 ret void18 }19 20 ; Function Attrs: returns_twice21 declare i32 @setjmp(ptr noundef) #122 23 attributes #0 = { "target-features"="+harden-sls-blr" }24 attributes #1 = { returns_twice }25 26 !llvm.module.flags = !{!0}27 !0 = !{i32 8, !"branch-target-enforcement", i32 1}28...29---30name: fn31exposesReturnsTwice: true32tracksRegLiveness: true33fixedStack: []34stack: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: '' }42callSites: []43debugValueSubstitutions: []44constants: []45machineFunctionInfo:46 hasRedZone: false47body: |48 bb.0.entry:49 liveins: $lr50 51 early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 :: (store (s64) into %stack.1)52 frame-setup CFI_INSTRUCTION def_cfa_offset 1653 frame-setup CFI_INSTRUCTION offset $w30, -1654 $x8 = ADRP target-flags(aarch64-page, aarch64-got) @setjmp55 renamable $x8 = LDRXui killed $x8, target-flags(aarch64-pageoff, aarch64-got, aarch64-nc) @setjmp56 STRXui renamable $x8, $sp, 1 :: (store (s64) into %ir.fnptr)57 $x0 = ORRXrs $xzr, $xzr, 058 BUNDLE implicit-def $lr, implicit-def $w30, implicit killed $x8, implicit $sp {59 BLR killed renamable $x8, implicit-def $lr, implicit $sp60 HINT 3661 }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 $x864 ; CHECK-NEXT: HINT 3665 ; CHECK-NEXT: }66 early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 :: (load (s64) from %stack.1)67 RET undef $lr68...69