2018-11-03 09:13:10 +00:00
|
|
|
//@ revisions: NO-OPT SIZE-OPT SPEED-OPT
|
2018-11-18 18:51:56 +00:00
|
|
|
//@[NO-OPT] compile-flags: -Copt-level=0 -Ccodegen-units=1
|
|
|
|
//@[SIZE-OPT] compile-flags: -Copt-level=s -Ccodegen-units=1
|
|
|
|
//@[SPEED-OPT] compile-flags: -Copt-level=3 -Ccodegen-units=1
|
2018-11-03 09:13:10 +00:00
|
|
|
|
|
|
|
#![feature(optimize_attribute)]
|
2024-05-29 04:11:20 +00:00
|
|
|
#![crate_type = "rlib"]
|
2018-11-03 09:13:10 +00:00
|
|
|
|
2021-03-27 22:11:24 +00:00
|
|
|
// CHECK-LABEL: define{{.*}}i32 @nothing
|
2018-11-18 18:51:56 +00:00
|
|
|
// CHECK-SAME: [[NOTHING_ATTRS:#[0-9]+]]
|
|
|
|
// SIZE-OPT: ret i32 4
|
2023-04-17 07:16:07 +00:00
|
|
|
// SPEED-OPT: ret i32 4
|
2018-11-03 09:13:10 +00:00
|
|
|
#[no_mangle]
|
|
|
|
pub fn nothing() -> i32 {
|
|
|
|
2 + 2
|
|
|
|
}
|
|
|
|
|
2021-03-27 22:11:24 +00:00
|
|
|
// CHECK-LABEL: define{{.*}}i32 @size
|
2018-11-18 18:51:56 +00:00
|
|
|
// CHECK-SAME: [[SIZE_ATTRS:#[0-9]+]]
|
|
|
|
// SIZE-OPT: ret i32 6
|
|
|
|
// SPEED-OPT: ret i32 6
|
2018-11-03 09:13:10 +00:00
|
|
|
#[optimize(size)]
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn size() -> i32 {
|
2018-11-18 18:51:56 +00:00
|
|
|
3 + 3
|
2018-11-03 09:13:10 +00:00
|
|
|
}
|
|
|
|
|
2021-03-27 22:11:24 +00:00
|
|
|
// CHECK-LABEL: define{{.*}}i32 @speed
|
2018-11-18 18:51:56 +00:00
|
|
|
// NO-OPT-SAME: [[NOTHING_ATTRS]]
|
|
|
|
// SPEED-OPT-SAME: [[NOTHING_ATTRS]]
|
|
|
|
// SIZE-OPT-SAME: [[SPEED_ATTRS:#[0-9]+]]
|
|
|
|
// SIZE-OPT: ret i32 8
|
|
|
|
// SPEED-OPT: ret i32 8
|
2018-11-03 09:13:10 +00:00
|
|
|
#[optimize(speed)]
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn speed() -> i32 {
|
2018-11-18 18:51:56 +00:00
|
|
|
4 + 4
|
2018-11-03 09:13:10 +00:00
|
|
|
}
|
2018-11-18 18:51:56 +00:00
|
|
|
|
|
|
|
// 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{{.*}}
|
|
|
|
|
|
|
|
// SIZE-OPT: attributes [[SPEED_ATTRS]]
|
|
|
|
// SIZE-OPT-NOT: minsize
|
|
|
|
// SIZE-OPT-NOT: optsize
|