-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Pass tune-cpu to LLVM #76830
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
Pass tune-cpu to LLVM #76830
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -497,8 +497,10 @@ point instructions in software. It takes one of the following values: | |
This instructs `rustc` to generate code specifically for a particular processor. | ||
|
||
You can run `rustc --print target-cpus` to see the valid options to pass | ||
here. Additionally, `native` can be passed to use the processor of the host | ||
machine. Each target has a default base CPU. | ||
here. Each target has a default base CPU. Special values include: | ||
|
||
* `native` can be passed to use the processor of the host machine. | ||
* `generic` refers to an LLVM target with minimal features but modern tuning. | ||
|
||
## target-feature | ||
|
||
|
@@ -530,6 +532,20 @@ This also supports the feature `+crt-static` and `-crt-static` to control | |
Each target and [`target-cpu`](#target-cpu) has a default set of enabled | ||
features. | ||
|
||
## tune-cpu | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving this option to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Annotated, but not moved yet since I don't know where unstable opts should be documented. |
||
|
||
This instructs `rustc` to schedule code specifically for a particular | ||
processor. This does not affect the compatibility (instruction sets or ABI), | ||
but should make your code slightly more efficient on the selected CPU. | ||
|
||
The valid options are the same as those for [`target-cpu`](#target-cpu). | ||
The default is `None`, which LLVM translates as the `target-cpu`. | ||
|
||
This is an unstable option. Use `-Z tune-cpu=machine` to specify a value. | ||
|
||
Due to limitations in LLVM (12.0.0-git9218f92), this option is currently | ||
effective only for x86 targets. | ||
|
||
[option-emit]: ../command-line-arguments.md#option-emit | ||
[option-o-optimize]: ../command-line-arguments.md#option-o-optimize | ||
[profile-guided optimization]: ../profile-guided-optimization.md | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// This test makes sure that functions get annotated with the proper | ||
// "tune-cpu" attribute in LLVM. | ||
|
||
// no-prefer-dynamic | ||
// ignore-tidy-linelength | ||
// compile-flags: -C no-prepopulate-passes -C panic=abort -C linker-plugin-lto -Cpasses=name-anon-globals -Z tune-cpu=generic | ||
|
||
#![crate_type = "staticlib"] | ||
|
||
// CHECK-LABEL: define {{.*}} @exported() {{.*}} #0 | ||
#[no_mangle] | ||
pub extern fn exported() { | ||
not_exported(); | ||
} | ||
|
||
// CHECK-LABEL: ; tune_cpu_on_functions::not_exported | ||
// CHECK-NEXT: ; Function Attrs: | ||
// CHECK-NEXT: define {{.*}}() {{.*}} #0 | ||
fn not_exported() {} | ||
|
||
// CHECK: attributes #0 = {{.*}} "tune-cpu"="{{.*}}" |
Uh oh!
There was an error while loading. Please reload this page.