about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-06-11 14:18:27 -0400
committerOneirical <manchot@videotron.ca>2024-07-08 10:13:40 -0400
commita4c72b627535c5ed9c58f1efbbe36491a820511a (patch)
tree24169a83c28b6c737d22a0dfcadc6bda21ac28d8
parent59a4f02f836f74c4cf08f47d76c9f6069a2f8276 (diff)
downloadrust-a4c72b627535c5ed9c58f1efbbe36491a820511a.tar.gz
rust-a4c72b627535c5ed9c58f1efbbe36491a820511a.zip
rewrite intrinsic-unreachable to rmake
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/run-make/intrinsic-unreachable/Makefile12
-rw-r--r--tests/run-make/intrinsic-unreachable/rmake.rs19
3 files changed, 19 insertions, 13 deletions
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 31cb32d349a..1cc414ecdc6 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -47,7 +47,6 @@ run-make/foreign-rust-exceptions/Makefile
 run-make/incr-add-rust-src-component/Makefile
 run-make/incr-foreign-head-span/Makefile
 run-make/interdependent-c-libraries/Makefile
-run-make/intrinsic-unreachable/Makefile
 run-make/issue-107094/Makefile
 run-make/issue-109934-lto-debuginfo/Makefile
 run-make/issue-14698/Makefile
diff --git a/tests/run-make/intrinsic-unreachable/Makefile b/tests/run-make/intrinsic-unreachable/Makefile
deleted file mode 100644
index ff9cc57098c..00000000000
--- a/tests/run-make/intrinsic-unreachable/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-include ../tools.mk
-
-# needs-asm-support
-# ignore-windows-msvc
-#
-# Because of Windows exception handling, the code is not necessarily any shorter.
-# https://github.com/llvm-mirror/llvm/commit/64b2297786f7fd6f5fa24cdd4db0298fbf211466
-
-all:
-	$(RUSTC) -O --emit asm exit-ret.rs
-	$(RUSTC) -O --emit asm exit-unreachable.rs
-	test `wc -l < $(TMPDIR)/exit-unreachable.s` -lt `wc -l < $(TMPDIR)/exit-ret.s`
diff --git a/tests/run-make/intrinsic-unreachable/rmake.rs b/tests/run-make/intrinsic-unreachable/rmake.rs
new file mode 100644
index 00000000000..6c951147604
--- /dev/null
+++ b/tests/run-make/intrinsic-unreachable/rmake.rs
@@ -0,0 +1,19 @@
+// intrinsics::unreachable tells the compiler that a certain point in the code
+// is not reachable by any means, which enables some useful optimizations.
+// In this test, exit-unreachable contains this instruction and exit-ret does not,
+// which means the emitted artifacts should be shorter in length.
+// See https://github.com/rust-lang/rust/pull/16970
+
+//@ needs-asm-support
+//@ ignore-windows-msvc
+// Reason: Because of Windows exception handling, the code is not necessarily any shorter.
+
+use run_make_support::rustc;
+use std::io::BufReader;
+use std::fs::File;
+
+fn main() {
+    rustc().opt().emit("asm").input("exit-ret.rs").run();
+    rustc().opt().emit("asm").input("exit-unreachable.rs").run();
+    assert!(BufReader::new(File::open("exit-unreachable.s")).lines().count() < BufReader::new(File::open("exit-ret.s")).lines().count());
+}