summaryrefslogtreecommitdiffstats
path: root/src/test/codegen/optimize-attr-1.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/codegen/optimize-attr-1.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/codegen/optimize-attr-1.rs')
-rw-r--r--src/test/codegen/optimize-attr-1.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/test/codegen/optimize-attr-1.rs b/src/test/codegen/optimize-attr-1.rs
new file mode 100644
index 000000000..22abe06e7
--- /dev/null
+++ b/src/test/codegen/optimize-attr-1.rs
@@ -0,0 +1,50 @@
+// revisions: NO-OPT SIZE-OPT SPEED-OPT
+//[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
+
+#![feature(optimize_attribute)]
+#![crate_type="rlib"]
+
+// CHECK-LABEL: define{{.*}}i32 @nothing
+// CHECK-SAME: [[NOTHING_ATTRS:#[0-9]+]]
+// NO-OPT: ret i32 4
+// SIZE-OPT: ret i32 4
+// SPEEC-OPT: ret i32 4
+#[no_mangle]
+pub fn nothing() -> i32 {
+ 2 + 2
+}
+
+// CHECK-LABEL: define{{.*}}i32 @size
+// CHECK-SAME: [[SIZE_ATTRS:#[0-9]+]]
+// NO-OPT: ret i32 6
+// SIZE-OPT: ret i32 6
+// SPEED-OPT: ret i32 6
+#[optimize(size)]
+#[no_mangle]
+pub fn size() -> i32 {
+ 3 + 3
+}
+
+// CHECK-LABEL: define{{.*}}i32 @speed
+// NO-OPT-SAME: [[NOTHING_ATTRS]]
+// SPEED-OPT-SAME: [[NOTHING_ATTRS]]
+// SIZE-OPT-SAME: [[SPEED_ATTRS:#[0-9]+]]
+// NO-OPT: ret i32 8
+// SIZE-OPT: ret i32 8
+// SPEED-OPT: ret i32 8
+#[optimize(speed)]
+#[no_mangle]
+pub fn speed() -> i32 {
+ 4 + 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{{.*}}
+
+// SIZE-OPT: attributes [[SPEED_ATTRS]]
+// SIZE-OPT-NOT: minsize
+// SIZE-OPT-NOT: optsize