]>
Commit | Line | Data |
---|---|---|
9fa01778 XL |
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 | |
5 | ||
6 | #![feature(optimize_attribute)] | |
7 | #![crate_type="rlib"] | |
8 | ||
cdc7bbd5 | 9 | // CHECK-LABEL: define{{.*}}i32 @nothing |
9fa01778 | 10 | // CHECK-SAME: [[NOTHING_ATTRS:#[0-9]+]] |
60c5eb7d | 11 | // NO-OPT: ret i32 4 |
9fa01778 XL |
12 | // SIZE-OPT: ret i32 4 |
13 | // SPEEC-OPT: ret i32 4 | |
14 | #[no_mangle] | |
15 | pub fn nothing() -> i32 { | |
16 | 2 + 2 | |
17 | } | |
18 | ||
cdc7bbd5 | 19 | // CHECK-LABEL: define{{.*}}i32 @size |
9fa01778 | 20 | // CHECK-SAME: [[SIZE_ATTRS:#[0-9]+]] |
60c5eb7d | 21 | // NO-OPT: ret i32 6 |
9fa01778 XL |
22 | // SIZE-OPT: ret i32 6 |
23 | // SPEED-OPT: ret i32 6 | |
24 | #[optimize(size)] | |
25 | #[no_mangle] | |
26 | pub fn size() -> i32 { | |
27 | 3 + 3 | |
28 | } | |
29 | ||
cdc7bbd5 | 30 | // CHECK-LABEL: define{{.*}}i32 @speed |
9fa01778 XL |
31 | // NO-OPT-SAME: [[NOTHING_ATTRS]] |
32 | // SPEED-OPT-SAME: [[NOTHING_ATTRS]] | |
33 | // SIZE-OPT-SAME: [[SPEED_ATTRS:#[0-9]+]] | |
60c5eb7d | 34 | // NO-OPT: ret i32 8 |
9fa01778 XL |
35 | // SIZE-OPT: ret i32 8 |
36 | // SPEED-OPT: ret i32 8 | |
37 | #[optimize(speed)] | |
38 | #[no_mangle] | |
39 | pub fn speed() -> i32 { | |
40 | 4 + 4 | |
41 | } | |
42 | ||
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{{.*}} | |
47 | ||
48 | // SIZE-OPT: attributes [[SPEED_ATTRS]] | |
49 | // SIZE-OPT-NOT: minsize | |
50 | // SIZE-OPT-NOT: optsize |