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 \ 5# RUN: --implicit-check-not=__llvm_slsblr_thunk_x7 6# RUN: llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu \ 7# RUN: -start-before aarch64-sls-hardening \ 8# RUN: -asm-verbose=0 -o - %s \ 9# RUN: | FileCheck %s --check-prefixes=ASM \ 10# RUN: --implicit-check-not=__llvm_slsblr_thunk_x7 11 12# Check that the BLR SLS hardening transforms a BLR into a BL with operands as 13# expected. 14--- | 15 @a = dso_local local_unnamed_addr global i32 (...)* null, align 8 16 @b = dso_local local_unnamed_addr global i32 0, align 4 17 18 define dso_local void @fn1() local_unnamed_addr "target-features"="+harden-sls-blr" { 19 entry: 20 %0 = load i32 ()*, i32 ()** bitcast (i32 (...)** @a to i32 ()**), align 8 21 %call = tail call i32 %0() nounwind 22 store i32 %call, i32* @b, align 4 23 ret void 24 } 25... 26--- 27name: fn1 28tracksRegLiveness: true 29body: | 30 ; CHECK-LABEL: name: fn1 31 bb.0.entry: 32 liveins: $lr 33 34 early-clobber $sp = frame-setup STRXpre killed $lr, $sp, -16 ; :: (store (s64) into %stack.0) 35 frame-setup CFI_INSTRUCTION def_cfa_offset 16 36 frame-setup CFI_INSTRUCTION offset $w30, -16 37 renamable $x8 = ADRP target-flags(aarch64-page) @a 38 renamable $x8 = LDRXui killed renamable $x8, target-flags(aarch64-pageoff, aarch64-nc) @a :: (dereferenceable load (s64) from `i32 ()** bitcast (i32 (...)** @a to i32 ()**)`) 39 BLRNoIP killed renamable $x8, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def $w0 40 ; CHECK: BL <mcsymbol __llvm_slsblr_thunk_x8>, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def $w0, implicit killed $x8 41 renamable $x8 = ADRP target-flags(aarch64-page) @b 42 STRWui killed renamable $w0, killed renamable $x8, target-flags(aarch64-pageoff, aarch64-nc) @b :: (store (s32) into @b) 43 early-clobber $sp, $lr = frame-destroy LDRXpost $sp, 16 ; :: (load (s64) from %stack.0) 44 RET undef $lr 45 46 47... 48 49# CHECK: name: __llvm_slsblr_thunk_x8 50# 51# CHECK: $x16 = ORRXrs $xzr, $x8, 0 52# CHECK-NEXT: BR $x16 53# CHECK-NEXT: SpeculationBarrierISBDSBEndBB 54 55# ASM-LABEL: __llvm_slsblr_thunk_x8: 56# ASM-NEXT: mov x16, x8 57# ASM-NEXT: br x16 58# ASM-NEXT: dsb sy 59# ASM-NEXT: isb 60