-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Adjust -Ctarget-cpu=native
handling in cg_llvm
#83084
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
Merged
Changes from all commits
Commits
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
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,41 @@ | ||
// assembly-output: emit-asm | ||
// needs-llvm-components: x86 | ||
// revisions: TWOFLAGS SINGLEFLAG | ||
// compile-flags: --target=x86_64-unknown-linux-gnu | ||
// [TWOFLAGS] compile-flags: -C target-feature=+rdrnd -C target-feature=+rdseed | ||
// [SINGLEFLAG] compile-flags: -C target-feature=+rdrnd,+rdseed | ||
|
||
// Target features set via flags aren't necessarily reflected in the IR, so the only way to test | ||
// them is to build code that requires the features to be enabled to work. | ||
// | ||
// In this particular test if `rdrnd,rdseed` somehow didn't make it to LLVM, the instruction | ||
// selection should crash. | ||
// | ||
// > LLVM ERROR: Cannot select: 0x7f00f400c010: i32,i32,ch = X86ISD::RDSEED 0x7f00f400bfa8:2 | ||
// > In function: foo | ||
// | ||
// See also src/test/codegen/target-feature-overrides.rs | ||
#![feature(no_core, lang_items, link_llvm_intrinsics, abi_unadjusted)] | ||
#![crate_type = "lib"] | ||
#![no_core] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
#[lang = "copy"] | ||
trait Copy {} | ||
|
||
// Use of these requires target features to be enabled | ||
extern "unadjusted" { | ||
#[link_name = "llvm.x86.rdrand.32"] | ||
fn x86_rdrand32_step() -> (u32, i32); | ||
#[link_name = "llvm.x86.rdseed.32"] | ||
fn x86_rdseed32_step() -> (u32, i32); | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe fn foo() -> (u32, u32) { | ||
// CHECK-LABEL: foo: | ||
// CHECK: rdrand | ||
// CHECK: rdseed | ||
(x86_rdrand32_step().0, x86_rdseed32_step().0) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
// revisions: COMPAT INCOMPAT | ||
// needs-llvm-components: x86 | ||
// compile-flags: --target=x86_64-unknown-linux-gnu -Copt-level=3 | ||
// [COMPAT] compile-flags: -Ctarget-feature=+avx2,+avx | ||
// [INCOMPAT] compile-flags: -Ctarget-feature=-avx2,-avx | ||
|
||
// See also src/test/assembly/target-feature-multiple.rs | ||
#![feature(no_core, lang_items)] | ||
#![crate_type = "lib"] | ||
#![no_core] | ||
|
||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
#[lang = "copy"] | ||
trait Copy {} | ||
|
||
extern "C" { | ||
fn peach() -> u32; | ||
} | ||
|
||
#[inline] | ||
#[target_feature(enable = "avx")] | ||
#[no_mangle] | ||
pub unsafe fn apple() -> u32 { | ||
// CHECK-LABEL: @apple() | ||
// CHECK-SAME: [[APPLEATTRS:#[0-9]+]] { | ||
// CHECK: {{.*}}call{{.*}}@peach | ||
peach() | ||
} | ||
|
||
// target features same as global (not reflected or overriden in IR) | ||
#[no_mangle] | ||
pub unsafe fn banana() -> u32 { | ||
// CHECK-LABEL: @banana() | ||
// CHECK-SAME: [[BANANAATTRS:#[0-9]+]] { | ||
// COMPAT: {{.*}}call{{.*}}@peach | ||
// INCOMPAT: {{.*}}call{{.*}}@apple | ||
apple() // Compatible for inline in COMPAT revision and can't be inlined in INCOMPAT | ||
} | ||
|
||
// CHECK: attributes [[APPLEATTRS]] | ||
// COMPAT-SAME: "target-features"="+avx2,+avx,+avx" | ||
// INCOMPAT-SAME: "target-features"="-avx2,-avx,+avx" | ||
// CHECK: attributes [[BANANAATTRS]] | ||
// CHECK-NOT: target-features | ||
// CHECK-SAME: } |
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.