1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00
llvm-mirror/test/CodeGen/AArch64/machine-outliner-retaddr-sign-sp-mod.ll
Pablo Barrio 1191117931 [AArch64][v8.3A] Avoid inserting implicit landing pads (PACI*SP)
PACI*SP have the advantage that they are in HINT space, meaning
they can be run successfully in hardware without PAuth support -
they will just behave as a NOP. However, PACI*SP are also implicit
landing pads (think of an extra BTI jc). Therefore, they allow
indirect jumps of all kinds into them, potentially inserting new
gadgets. This patch replaces PACI*SP by PACI* LR, SP when
compiling explicitly for hardware with full PAuth support. PACI*
is not in the HINT space, therefore it will fault when run in
hardware without PAuth support, but it is also not a landing pad,
making programs safer in newer HW.

Differential Revision: https://reviews.llvm.org/D101920
2021-06-24 18:24:32 +01:00

45 lines
1.6 KiB
LLVM

; RUN: llc -mtriple aarch64-arm-none-eabi -enable-machine-outliner \
; RUN: -verify-machineinstrs %s -o - | FileCheck %s
@v = common dso_local global i32* null, align 8
; CHECK-LABEL: foo: // @foo
; CHECK-NEXT: // %bb.0: // %entry
; CHECK-NEXT: pacia x30, sp
; CHECK-NOT: OUTLINED_FUNCTION_
; CHECK: retaa
define dso_local void @foo(i32 %x) #0 {
entry:
%0 = zext i32 %x to i64
%vla = alloca i32, i64 %0, align 4
store volatile i32* %vla, i32** @v, align 8
store volatile i32* %vla, i32** @v, align 8
store volatile i32* %vla, i32** @v, align 8
store volatile i32* %vla, i32** @v, align 8
store volatile i32* %vla, i32** @v, align 8
store volatile i32* %vla, i32** @v, align 8
ret void
}
; CHECK-LABEL: bar: // @bar
; CHECK-NEXT: // %bb.0: // %entry
; CHECK-NEXT: pacia x30, sp
; CHECK-NOT: OUTLINED_FUNCTION_
; CHECK: retaa
define dso_local void @bar(i32 %x) #0 {
entry:
%0 = zext i32 %x to i64
%vla = alloca i32, i64 %0, align 4
store volatile i32* null, i32** @v, align 8
store volatile i32* %vla, i32** @v, align 8
store volatile i32* %vla, i32** @v, align 8
store volatile i32* %vla, i32** @v, align 8
store volatile i32* %vla, i32** @v, align 8
store volatile i32* %vla, i32** @v, align 8
ret void
}
attributes #0 = { nounwind "target-features"="+v8.3a" "frame-pointer"="all" "sign-return-address"="all" "sign-return-address-key"="a_key" }
; CHECK-NOT: OUTLINED_FUNCTION_