-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[InstCombine] Combine ptrauth constant callee into bundle. #94706
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
Merged
ahmedbougacha
merged 5 commits into
llvm:main
from
ahmedbougacha:users/ahmedbougacha/ptrauth-instcombine-constant-callee
Jul 15, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
de79c48
[InstCombine] Combine ptrauth constant callee into bundle.
ahmedbougacha 1d00ba7
Remove now-unnecessary stripPointerCasts.
ahmedbougacha 0d01874
Merge branch 'main' into users/ahmedbougacha/ptrauth-instcombine-cons…
ahmedbougacha 539b69c
Update test following ptr cast changes.
ahmedbougacha 3ae1fd9
Address review feedback in tests.
ahmedbougacha 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
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,97 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
| ; RUN: opt < %s -passes=instcombine -S | FileCheck %s | ||
|
|
||
| declare i64 @f(i32) | ||
| declare ptr @f2(i32) | ||
|
|
||
| define i32 @test_ptrauth_call(i32 %a0) { | ||
| ; CHECK-LABEL: @test_ptrauth_call( | ||
| ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) | ||
| ; CHECK-NEXT: ret i32 [[V0]] | ||
| ; | ||
| %v0 = call i32 ptrauth(ptr @f, i32 0)(i32 %a0) [ "ptrauth"(i32 0, i64 0) ] | ||
| ret i32 %v0 | ||
| } | ||
|
|
||
| define i32 @test_ptrauth_call_disc(i32 %a0) { | ||
| ; CHECK-LABEL: @test_ptrauth_call_disc( | ||
| ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) | ||
| ; CHECK-NEXT: ret i32 [[V0]] | ||
| ; | ||
| %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i32 1, i64 5678) ] | ||
| ret i32 %v0 | ||
| } | ||
|
|
||
| @f_addr_disc.ref = constant ptr ptrauth(ptr @f, i32 1, i64 0, ptr @f_addr_disc.ref) | ||
|
|
||
| define i32 @test_ptrauth_call_addr_disc(i32 %a0) { | ||
| ; CHECK-LABEL: @test_ptrauth_call_addr_disc( | ||
| ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) | ||
| ; CHECK-NEXT: ret i32 [[V0]] | ||
| ; | ||
| %v0 = call i32 ptrauth(ptr @f, i32 1, i64 0, ptr @f_addr_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 ptrtoint (ptr @f_addr_disc.ref to i64)) ] | ||
| ret i32 %v0 | ||
| } | ||
|
|
||
| @f_both_disc.ref = constant ptr ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref) | ||
|
|
||
| define i32 @test_ptrauth_call_blend(i32 %a0) { | ||
| ; CHECK-LABEL: @test_ptrauth_call_blend( | ||
| ; CHECK-NEXT: [[V0:%.*]] = call i32 @f(i32 [[A0:%.*]]) | ||
| ; CHECK-NEXT: ret i32 [[V0]] | ||
| ; | ||
| %v = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 1234) | ||
| %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 %v) ] | ||
| ret i32 %v0 | ||
| } | ||
|
|
||
| define i64 @test_ptrauth_call_cast(i32 %a0) { | ||
| ; CHECK-LABEL: @test_ptrauth_call_cast( | ||
| ; CHECK-NEXT: [[V0:%.*]] = call i64 @f2(i32 [[A0:%.*]]) | ||
| ; CHECK-NEXT: ret i64 [[V0]] | ||
| ; | ||
| %v0 = call i64 ptrauth(ptr @f2, i32 0)(i32 %a0) [ "ptrauth"(i32 0, i64 0) ] | ||
| ret i64 %v0 | ||
| } | ||
|
|
||
| define i32 @test_ptrauth_call_mismatch_key(i32 %a0) { | ||
| ; CHECK-LABEL: @test_ptrauth_call_mismatch_key( | ||
| ; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i32 0, i64 5678) ] | ||
| ; CHECK-NEXT: ret i32 [[V0]] | ||
| ; | ||
| %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i32 0, i64 5678) ] | ||
| ret i32 %v0 | ||
| } | ||
|
|
||
| define i32 @test_ptrauth_call_mismatch_disc(i32 %a0) { | ||
| ; CHECK-LABEL: @test_ptrauth_call_mismatch_disc( | ||
| ; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 5678)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 0) ] | ||
| ; CHECK-NEXT: ret i32 [[V0]] | ||
| ; | ||
| %v0 = call i32 ptrauth(ptr @f, i32 1, i64 5678)(i32 %a0) [ "ptrauth"(i32 1, i64 0) ] | ||
| ret i32 %v0 | ||
| } | ||
|
|
||
| define i32 @test_ptrauth_call_mismatch_blend(i32 %a0) { | ||
| ; CHECK-LABEL: @test_ptrauth_call_mismatch_blend( | ||
| ; CHECK-NEXT: [[V:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) | ||
| ; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 [[V]]) ] | ||
| ; CHECK-NEXT: ret i32 [[V0]] | ||
| ; | ||
| %v = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_both_disc.ref to i64), i64 0) | ||
| %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 %v) ] | ||
| ret i32 %v0 | ||
| } | ||
|
|
||
| define i32 @test_ptrauth_call_mismatch_blend_addr(i32 %a0) { | ||
| ; CHECK-LABEL: @test_ptrauth_call_mismatch_blend_addr( | ||
| ; CHECK-NEXT: [[V:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) | ||
| ; CHECK-NEXT: [[V0:%.*]] = call i32 ptrauth (ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 [[A0:%.*]]) [ "ptrauth"(i32 1, i64 [[V]]) ] | ||
| ; CHECK-NEXT: ret i32 [[V0]] | ||
| ; | ||
| %v = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @f_addr_disc.ref to i64), i64 1234) | ||
| %v0 = call i32 ptrauth(ptr @f, i32 1, i64 1234, ptr @f_both_disc.ref)(i32 %a0) [ "ptrauth"(i32 1, i64 %v) ] | ||
| ret i32 %v0 | ||
| } | ||
|
|
||
| declare i64 @llvm.ptrauth.blend(i64, i64) | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.