about summary refs log tree commit diff
path: root/src/test/codegen/optimize-attr-1.rs
diff options
context:
space:
mode:
authorSimonas Kazlauskas <git@kazlauskas.me>2018-11-03 11:13:10 +0200
committerSimonas Kazlauskas <git@kazlauskas.me>2019-01-24 20:13:51 +0200
commitdcf5482cdacd166268f9672f34697dd1da05ceea (patch)
tree5945ae826146d08611fd60c98ec979de42c35255 /src/test/codegen/optimize-attr-1.rs
parentf38d0da89389c45067d37ba15e783c024088a09a (diff)
downloadrust-dcf5482cdacd166268f9672f34697dd1da05ceea.tar.gz
rust-dcf5482cdacd166268f9672f34697dd1da05ceea.zip
Add an idealistic test for optimize attribute
Alas it does not currently work, because of limitations in compiletest…
Diffstat (limited to 'src/test/codegen/optimize-attr-1.rs')
-rw-r--r--src/test/codegen/optimize-attr-1.rs49
1 files changed, 49 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 00000000000..b742a361da9
--- /dev/null
+++ b/src/test/codegen/optimize-attr-1.rs
@@ -0,0 +1,49 @@
+// revisions: NO-OPT SIZE-OPT SPEED-OPT
+// [NO-OPT]compile-flags: -Copt-level=0
+// [SIZE-OPT]compile-flags: -Copt-level=s
+// [SPEED-OPT]compile-flags: -Copt-level=3
+
+#![feature(optimize_attribute)]
+#![crate_type="rlib"]
+
+// NO-OPT: Function Attrs:{{.*}}optnone
+// NO-OPT-NOT: {{optsize|minsize}}
+// NO-OPT-NEXT: @nothing
+// NO-OPT: ret i32 %1
+//
+// SIZE-OPT: Function Attrs:{{.*}}optsize
+// SIZE-OPT-NOT: {{minsize|optnone}}
+// SIZE-OPT-NEXT: @nothing
+// SIZE-OPT-NEXT: start
+// SIZE-OPT-NEXT: ret i32 4
+//
+// SPEED-OPT: Function Attrs:
+// SPEED-OPT-NOT: {{minsize|optnone|optsize}}
+// SPEED-OPT-NEXT: @nothing
+// SPEED-OPT-NEXT: start
+// SPEED-OPT-NEXT: ret i32 4
+#[no_mangle]
+pub fn nothing() -> i32 {
+    2 + 2
+}
+
+// CHECK: Function Attrs:{{.*}} minsize{{.*}}optsize
+// CHECK-NEXT: @size
+// CHECK-NEXT: start
+// CHECK-NEXT: ret i32 4
+#[optimize(size)]
+#[no_mangle]
+pub fn size() -> i32 {
+    2 + 2
+}
+
+// CHECK: Function Attrs:
+// CHECK-NOT: {{minsize|optsize|optnone}}
+// CHECK-NEXT: @speed
+// CHECK-NEXT: start
+// CHECK-NEXT: ret i32 4
+#[optimize(speed)]
+#[no_mangle]
+pub fn speed() -> i32 {
+    2 + 2
+}