1 // revisions: NO-OPT SIZE-OPT SPEED-OPT
2 //[NO-OPT] compile-flags: -Copt-level=0 -Ccodegen-units=1
3 //[SIZE-OPT] compile-flags: -Copt-level=s -Ccodegen-units=1
4 //[SPEED-OPT] compile-flags: -Copt-level=3 -Ccodegen-units=1
6 #![feature(optimize_attribute)]
9 // CHECK-LABEL: define{{.*}}i32 @nothing
10 // CHECK-SAME: [[NOTHING_ATTRS:#[0-9]+]]
12 // SIZE-OPT: ret i32 4
13 // SPEEC-OPT: ret i32 4
15 pub fn nothing() -> i32 {
19 // CHECK-LABEL: define{{.*}}i32 @size
20 // CHECK-SAME: [[SIZE_ATTRS:#[0-9]+]]
22 // SIZE-OPT: ret i32 6
23 // SPEED-OPT: ret i32 6
26 pub fn size() -> i32 {
30 // CHECK-LABEL: define{{.*}}i32 @speed
31 // NO-OPT-SAME: [[NOTHING_ATTRS]]
32 // SPEED-OPT-SAME: [[NOTHING_ATTRS]]
33 // SIZE-OPT-SAME: [[SPEED_ATTRS:#[0-9]+]]
35 // SIZE-OPT: ret i32 8
36 // SPEED-OPT: ret i32 8
39 pub fn speed() -> i32 {
43 // NO-OPT-DAG: attributes [[SIZE_ATTRS]] = {{.*}}minsize{{.*}}optsize{{.*}}
44 // SPEED-OPT-DAG: attributes [[SIZE_ATTRS]] = {{.*}}minsize{{.*}}optsize{{.*}}
45 // SIZE-OPT-DAG: attributes [[NOTHING_ATTRS]] = {{.*}}optsize{{.*}}
46 // SIZE-OPT-DAG: attributes [[SIZE_ATTRS]] = {{.*}}minsize{{.*}}optsize{{.*}}
48 // SIZE-OPT: attributes [[SPEED_ATTRS]]
49 // SIZE-OPT-NOT: minsize
50 // SIZE-OPT-NOT: optsize