Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AArch64] - Generate pointer authentication instructions
- Generate pointer authentication instructions - The functions instrumented depend on function attribtues: all (all functions instrumentent) non-leaf (only those that spill LR) none - Function epilogues sign the LR before spilling to the stack and authenticate the LR once restored - If the target is v8.3a or greater than can use the combined authenticate and return instruction Differential revision: https://reviews.llvm.org/D49793 llvm-svn: 340018
- Loading branch information
Luke Cheeseman
committed
Aug 17, 2018
1 parent
7d27251
commit 64dcdec
Showing
2 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
; RUN: llc -mtriple=aarch64-none-eabi < %s | FileCheck %s | ||
|
||
; CHECK-LABEL: @leaf | ||
; CHECK-NOT: paci{{[a,b]}}sp | ||
; CHECK-NOT: auti{{[a,b]}}sp | ||
define i32 @leaf(i32 %x) { | ||
ret i32 %x | ||
} | ||
|
||
; CHECK-LABEL: @leaf_sign_none | ||
; CHECK-NOT: paci{{[a,b]}}sp | ||
; CHECK-NOT: auti{{[a,b]}}sp | ||
define i32 @leaf_sign_none(i32 %x) "sign-return-address"="none" { | ||
ret i32 %x | ||
} | ||
|
||
; CHECK-LABEL: @leaf_sign_non_leaf | ||
; CHECK-NOT: paci{{[a,b]}}sp | ||
; CHECK-NOT: auti{{[a,b]}}sp | ||
define i32 @leaf_sign_non_leaf(i32 %x) "sign-return-address"="non-leaf" { | ||
ret i32 %x | ||
} | ||
|
||
; CHECK-LABEL: @leaf_sign_all | ||
; CHECK: paciasp | ||
; CHECK: autiasp | ||
; CHECK-NEXT: ret | ||
define i32 @leaf_sign_all(i32 %x) "sign-return-address"="all" { | ||
ret i32 %x | ||
} | ||
|
||
; CHECK: @leaf_clobbers_lr | ||
; CHECK: paciasp | ||
; CHECK-NEXT: str x30, [sp, #-16]! | ||
; CHECK: ldr x30, [sp], #16 | ||
; CHECK-NEXT: autiasp | ||
; CHECK-NEXT: ret | ||
define i64 @leaf_clobbers_lr(i64 %x) "sign-return-address"="non-leaf" { | ||
call void asm sideeffect "mov x30, $0", "r,~{lr}"(i64 %x) #1 | ||
ret i64 %x | ||
} | ||
|
||
declare i32 @foo(i32) | ||
|
||
; CHECK: @non_leaf_sign_all | ||
; CHECK: paciasp | ||
; CHECK: autiasp | ||
; CHECK-NEXT: ret | ||
define i32 @non_leaf_sign_all(i32 %x) "sign-return-address"="all" { | ||
%call = call i32 @foo(i32 %x) | ||
ret i32 %call | ||
} | ||
|
||
; CHECK: @non_leaf_sign_non_leaf | ||
; CHECK: paciasp | ||
; CHECK-NEXT: str x30, [sp, #-16]! | ||
; CHECK: ldr x30, [sp], #16 | ||
; CHECK-NEXT: autiasp | ||
; CHECK-NEXT: ret | ||
define i32 @non_leaf_sign_non_leaf(i32 %x) "sign-return-address"="non-leaf" { | ||
%call = call i32 @foo(i32 %x) | ||
ret i32 %call | ||
} | ||
|
||
; CHECK-LABEL: @leaf_sign_all_v83 | ||
; CHECK: paciasp | ||
; CHECK-NOT: ret | ||
; CHECK-NEXT: retaa | ||
; CHECK-NOT: ret | ||
define i32 @leaf_sign_all_v83(i32 %x) "sign-return-address"="all" "target-features"="+v8.3a" { | ||
ret i32 %x | ||
} | ||
|
||
declare fastcc i64 @bar(i64) | ||
|
||
; CHECK-LABEL: @spill_lr_and_tail_call | ||
; CHECK: paciasp | ||
; CHECK-NEXT: str x30, [sp, #-16]! | ||
; CHECK: ldr x30, [sp], #16 | ||
; CHECK-NEXT: autiasp | ||
; CHECK-NEXT: b bar | ||
define fastcc void @spill_lr_and_tail_call(i64 %x) "sign-return-address"="all" { | ||
call void asm sideeffect "mov x30, $0", "r,~{lr}"(i64 %x) #1 | ||
tail call fastcc i64 @bar(i64 %x) | ||
ret void | ||
} |