-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Feat - #[inline(always)] + #[target_feature(enable = "....")] #2
#162460
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
Jamesbarford
wants to merge
5
commits into
rust-lang:main
Choose a base branch
from
Jamesbarford:feat/inline-always+target-feature-#2
base: main
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a176327
`#[inline(always] + #[target_feature(enable = "...")]`
Jamesbarford 7f6e246
Add & Update tests
Jamesbarford bedba2e
Remove errors for `#[inline(always] + `#[target_feature(enable = "...…
Jamesbarford e8bfac6
remove brittle test
Jamesbarford 751e4f1
Revert change to feature removed & update justification string
Jamesbarford 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
29 changes: 29 additions & 0 deletions
29
tests/codegen-llvm/inline-always-target-feature-mismatch.rs
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,29 @@ | ||
| //@ only-x86_64 | ||
| //@ min-llvm-version: 23 | ||
| //@ compile-flags: -Copt-level=3 | ||
|
|
||
| #![crate_type = "lib"] | ||
| #![feature(test)] | ||
| #![allow(unused_unsafe)] | ||
|
|
||
| use std::arch::x86_64::_bzhi_u64; | ||
|
|
||
| extern crate test; | ||
| use test::black_box as b; | ||
|
|
||
| #[inline(always)] | ||
| #[target_feature(enable = "bmi2")] | ||
| #[unsafe(no_mangle)] | ||
| pub unsafe fn callee_requires_bmi2() -> u64 { | ||
| // black box this as `_bzhi_u64(1, 2)` can evaluate to `1` at compile time and LLVM is smart | ||
| // enough to see that it then can ignore `bmi2` as this returns a constant. Which is safe to | ||
| // do. | ||
| b(_bzhi_u64(1, 2)) | ||
| } | ||
|
|
||
| #[unsafe(no_mangle)] | ||
| // CHECK-LABEL: define{{.*}} @caller_only() | ||
| // CHECK: [[TMP:%.+]] = tail call noundef i64 @callee_requires_bmi2() | ||
| pub unsafe fn caller_only() { | ||
| let _x = callee_requires_bmi2(); | ||
| } |
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,36 @@ | ||
| //@ add-minicore | ||
| //@ compile-flags: --target aarch64-unknown-linux-gnu -Zinline-mir=no -C no-prepopulate-passes -Copt-level=3 | ||
| //@ needs-llvm-components: aarch64 | ||
| //@ min-llvm-version: 23 | ||
|
|
||
| #![crate_type = "lib"] | ||
| #![feature(no_core, lang_items)] | ||
| #![no_core] | ||
|
|
||
| extern crate minicore; | ||
| use minicore::*; | ||
|
|
||
| #[inline(always)] | ||
| #[target_feature(enable = "neon")] | ||
| #[no_mangle] | ||
| pub fn single_target_feature() -> i32 { | ||
| 42 | ||
| } | ||
|
|
||
| #[inline(always)] | ||
| #[target_feature(enable = "neon,i8mm")] | ||
| #[no_mangle] | ||
| // CHECK: define{{( noundef)?}} i32 @multiple_target_features() unnamed_addr #1{{( !guid ![0-9]+)?}} { | ||
| pub fn multiple_target_features() -> i32 { | ||
| // CHECK: %_0 = call{{( noundef)?}} i32 @single_target_feature() #3 | ||
| single_target_feature() | ||
| } | ||
|
|
||
| #[no_mangle] | ||
| // CHECK: define{{( noundef)?}} i32 @inherits_from_global() unnamed_addr #2{{( !guid ![0-9]+)?}} { | ||
| pub fn inherits_from_global() -> i32 { | ||
| unsafe { | ||
| // CHECK: %_0 = call{{( noundef)?}} i32 @single_target_feature() #3 | ||
| single_target_feature() | ||
| } | ||
| } |
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
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.
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.
Removed lints never get removed from this file. Please undo the change here. You may want to update the justification string, but you have to keep the
register_removed.View changes since the review