-
Notifications
You must be signed in to change notification settings - Fork 0
[AArch64][PAC] Emit a fatal error when ptrauth target feature is missing #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kovdan01
wants to merge
8
commits into
elf-pauth
Choose a base branch
from
dkovalev/check-pauth-subtarget-feature
base: elf-pauth
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e31206a
[AArch64][PAC] Emit a fatal error when ptrauth target feature is missing
kovdan01 ccfa70e
Pass `-debug` option to llc only on assertion-enabled builds
kovdan01 52afe42
Use `-debug-only=aarch64-expand-hardened-pseudos` instead of `-debug`
kovdan01 81cb742
Ensure that ptrauth subtarget feature is checked for ptrauth-returns
kovdan01 3821445
Ensure AUTH_CALL is not emitted when ptrauth subtarget feature is mis…
kovdan01 9ed8fc6
Use CHECK-NEXT instead of CHECK when suitable
kovdan01 bffc609
Add error messages for emitting LDRA* pseudos without PAuth subtarget…
kovdan01 8e30a83
Use opaque pointers
kovdan01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
61 changes: 61 additions & 0 deletions
61
llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-lowering-err-debug.ll
This file contains hidden or 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,61 @@ | ||
| ; REQUIRES: asserts | ||
| ; RUN: split-file %s %t && cd %t | ||
|
|
||
| ;--- MOVaddrPAC.ll | ||
|
|
||
| ; RUN: not --crash llc -debug-only=aarch64-expand-hardened-pseudos -mtriple aarch64-elf MOVaddrPAC.ll 2>&1 | \ | ||
| ; RUN: FileCheck MOVaddrPAC.ll | ||
|
|
||
| ; CHECK: Expanding: MOVaddrPAC @foo | ||
| ; CHECK-NEXT: {{^$}} | ||
| ; CHECK-NEXT: LLVM ERROR: pac instructions require ptrauth target feature | ||
|
|
||
| @foo.ptrauth = private constant { ptr, i32, i64, i64 } { ptr @foo, i32 0, i64 0, i64 0 }, section "llvm.ptrauth", align 8 | ||
|
|
||
| define ptr @bar() #0 { | ||
| ret ptr @foo.ptrauth | ||
| } | ||
|
|
||
| define private void @foo() { | ||
| ret void | ||
| } | ||
|
|
||
| attributes #0 = { "ptrauth-calls" "target-cpu"="generic" } | ||
|
|
||
| ;--- LOADgotPAC.ll | ||
|
|
||
| ; RUN: not --crash llc -debug-only=aarch64-expand-hardened-pseudos -mtriple aarch64-elf LOADgotPAC.ll 2>&1 | \ | ||
| ; RUN: FileCheck LOADgotPAC.ll | ||
|
|
||
| ; CHECK: Expanding: LOADgotPAC @foo | ||
| ; CHECK-NEXT: {{^$}} | ||
| ; CHECK-NEXT: LLVM ERROR: pac instructions require ptrauth target feature | ||
|
|
||
| @foo.ptrauth = private constant { ptr, i32, i64, i64 } { ptr @foo, i32 0, i64 0, i64 0 }, section "llvm.ptrauth", align 8 | ||
|
|
||
| define ptr @bar() #0 { | ||
| ret ptr @foo.ptrauth | ||
| } | ||
|
|
||
| declare void @foo() | ||
|
|
||
| attributes #0 = { "ptrauth-calls" "target-cpu"="generic" } | ||
|
|
||
| ;--- LOADauthptrgot.ll | ||
|
|
||
| ; RUN: not --crash llc -debug-only=aarch64-expand-hardened-pseudos -mtriple aarch64-elf LOADauthptrgot.ll 2>&1 | \ | ||
| ; RUN: FileCheck LOADauthptrgot.ll | ||
|
|
||
| ; CHECK: Expanding: {{.*}}LOADauthptrgot @g_weak | ||
| ; CHECK-NEXT: {{^$}} | ||
| ; CHECK-NEXT: LLVM ERROR: pac instructions require ptrauth target feature | ||
|
|
||
| define i8* @foo() #0 { | ||
| %tmp = bitcast { i8*, i32, i64, i64 }* @g_weak.ptrauth to i8* | ||
| ret i8* %tmp | ||
| } | ||
|
|
||
| @g_weak = extern_weak global i32 | ||
| @g_weak.ptrauth = private constant { i8*, i32, i64, i64 } { i8* bitcast (i32* @g_weak to i8*), i32 0, i64 0, i64 0 }, section "llvm.ptrauth" | ||
|
|
||
| attributes #0 = { "ptrauth-calls" "target-cpu"="generic" } | ||
86 changes: 86 additions & 0 deletions
86
llvm/test/CodeGen/AArch64/GlobalISel/ptrauth-lowering-err.ll
This file contains hidden or 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: split-file %s %t && cd %t | ||
|
|
||
| ;--- MOVaddrPAC.ll | ||
|
|
||
| ; RUN: not --crash llc -mtriple aarch64-elf MOVaddrPAC.ll 2>&1 | \ | ||
| ; RUN: FileCheck MOVaddrPAC.ll | ||
|
|
||
| ; CHECK: LLVM ERROR: pac instructions require ptrauth target feature | ||
|
|
||
| @foo.ptrauth = private constant { ptr, i32, i64, i64 } { ptr @foo, i32 0, i64 0, i64 0 }, section "llvm.ptrauth", align 8 | ||
|
|
||
| define ptr @bar() #0 { | ||
| ret ptr @foo.ptrauth | ||
| } | ||
|
|
||
| define private void @foo() { | ||
| ret void | ||
| } | ||
|
|
||
| attributes #0 = { "ptrauth-calls" "target-cpu"="generic" } | ||
|
|
||
| ;--- LOADgotPAC.ll | ||
|
|
||
| ; RUN: not --crash llc -mtriple aarch64-elf LOADgotPAC.ll 2>&1 | \ | ||
| ; RUN: FileCheck LOADgotPAC.ll | ||
|
|
||
| ; CHECK: LLVM ERROR: pac instructions require ptrauth target feature | ||
|
|
||
| @foo.ptrauth = private constant { ptr, i32, i64, i64 } { ptr @foo, i32 0, i64 0, i64 0 }, section "llvm.ptrauth", align 8 | ||
|
|
||
| define ptr @bar() #0 { | ||
| ret ptr @foo.ptrauth | ||
| } | ||
|
|
||
| declare void @foo() | ||
|
|
||
| attributes #0 = { "ptrauth-calls" "target-cpu"="generic" } | ||
|
|
||
| ;--- LOADauthptrgot.ll | ||
|
|
||
| ; RUN: not --crash llc -mtriple aarch64-elf LOADauthptrgot.ll 2>&1 | \ | ||
| ; RUN: FileCheck LOADauthptrgot.ll | ||
|
|
||
| ; CHECK: LLVM ERROR: pac instructions require ptrauth target feature | ||
|
|
||
| define i8* @foo() #0 { | ||
| %tmp = bitcast { i8*, i32, i64, i64 }* @g_weak.ptrauth to i8* | ||
| ret i8* %tmp | ||
| } | ||
|
|
||
| @g_weak = extern_weak global i32 | ||
| @g_weak.ptrauth = private constant { i8*, i32, i64, i64 } { i8* bitcast (i32* @g_weak to i8*), i32 0, i64 0, i64 0 }, section "llvm.ptrauth" | ||
|
||
|
|
||
| attributes #0 = { "ptrauth-calls" "target-cpu"="generic" } | ||
|
|
||
| ;--- ptrauth-returns.ll | ||
|
|
||
| ; RUN: not --crash llc -mtriple aarch64-elf ptrauth-returns.ll 2>&1 | \ | ||
| ; RUN: FileCheck ptrauth-returns.ll | ||
|
|
||
| ; CHECK: LLVM ERROR: aarch64 LR authentication requires ptrauth | ||
|
|
||
| define i32 @bar() #0 { | ||
| ret i32 42 | ||
| } | ||
|
|
||
| define i32 @foo() { | ||
| %tmp = call i32 @bar() | ||
| ret i32 %tmp | ||
| } | ||
|
|
||
| attributes #0 = { "ptrauth-returns" "target-cpu"="generic" } | ||
|
|
||
| ;--- auth-call.ll | ||
|
|
||
| ; RUN: not --crash llc -mtriple aarch64-elf auth-call.ll 2>&1 | \ | ||
| ; RUN: FileCheck auth-call.ll | ||
|
|
||
| ; CHECK: LLVM ERROR: Cannot select:{{.*}}AArch64ISD::AUTH_CALL | ||
|
|
||
| define void @bar(ptr %foo) #0 { | ||
| call void %foo() [ "ptrauth"(i32 0, i64 0) ] | ||
| ret void | ||
| } | ||
|
|
||
| attributes #0 = { "ptrauth-calls" "target-cpu"="generic" } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typed pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 8e30a83