Implement optimize(none) attribute

This commit is contained in:
clubby789 2024-12-09 19:00:43 +00:00
parent dee7d0e730
commit cd848c9f3e
8 changed files with 45 additions and 14 deletions

View file

@ -37,11 +37,23 @@ pub fn speed() -> i32 {
4 + 4
}
// CHECK-LABEL: define{{.*}}i32 @none
// CHECK-SAME: [[NONE_ATTRS:#[0-9]+]]
// SIZE-OPT: alloca
// SPEED-OPT: alloca
#[no_mangle]
#[optimize(none)]
pub fn none() -> i32 {
let arr = [0, 1, 2, 3, 4];
arr[4]
}
// NO-OPT-DAG: attributes [[SIZE_ATTRS]] = {{.*}}minsize{{.*}}optsize{{.*}}
// SPEED-OPT-DAG: attributes [[SIZE_ATTRS]] = {{.*}}minsize{{.*}}optsize{{.*}}
// SIZE-OPT-DAG: attributes [[NOTHING_ATTRS]] = {{.*}}optsize{{.*}}
// SIZE-OPT-DAG: attributes [[SIZE_ATTRS]] = {{.*}}minsize{{.*}}optsize{{.*}}
// CHECK-DAG: attributes [[NONE_ATTRS]] = {{.*}}noinline{{.*}}optnone{{.*}}
// SIZE-OPT: attributes [[SPEED_ATTRS]]
// SIZE-OPT-DAG: attributes [[SPEED_ATTRS]]
// SIZE-OPT-NOT: minsize
// SIZE-OPT-NOT: optsize

View file

@ -6,6 +6,9 @@ fn size() {}
#[optimize(speed)] //~ ERROR the `#[optimize]` attribute is an experimental feature
fn speed() {}
#[optimize(none)] //~ ERROR the `#[optimize]` attribute is an experimental feature
fn none() {}
#[optimize(banana)]
//~^ ERROR the `#[optimize]` attribute is an experimental feature
//~| ERROR E0722

View file

@ -21,6 +21,16 @@ LL | #[optimize(speed)]
error[E0658]: the `#[optimize]` attribute is an experimental feature
--> $DIR/feature-gate-optimize_attribute.rs:9:1
|
LL | #[optimize(none)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information
= help: add `#![feature(optimize_attribute)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: the `#[optimize]` attribute is an experimental feature
--> $DIR/feature-gate-optimize_attribute.rs:12:1
|
LL | #[optimize(banana)]
| ^^^^^^^^^^^^^^^^^^^
|
@ -29,12 +39,12 @@ LL | #[optimize(banana)]
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0722]: invalid argument
--> $DIR/feature-gate-optimize_attribute.rs:9:12
--> $DIR/feature-gate-optimize_attribute.rs:12:12
|
LL | #[optimize(banana)]
| ^^^^^^
error: aborting due to 4 previous errors
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0658, E0722.
For more information about an error, try `rustc --explain E0658`.