about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2024-05-17 15:05:36 -0400
committerOneirical <manchot@videotron.ca>2024-05-22 22:43:21 -0400
commitddb81ce68047d6383a789c8da514e443faea8349 (patch)
tree4111f0af14cd90cce02936fdb952a4abb8457e6b
parentddba1dc97e83f22165b36dd6158477c49bbbd019 (diff)
downloadrust-ddb81ce68047d6383a789c8da514e443faea8349.tar.gz
rust-ddb81ce68047d6383a789c8da514e443faea8349.zip
rewrite and rename issue-46239
-rw-r--r--src/tools/run-make-support/src/rustc.rs6
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt1
-rw-r--r--tests/codegen/noalias-freeze.rs21
-rw-r--r--tests/run-make/issue-46239/Makefile6
-rw-r--r--tests/run-make/issue-46239/main.rs8
5 files changed, 27 insertions, 15 deletions
diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs
index d034826a830..f581204d5f1 100644
--- a/src/tools/run-make-support/src/rustc.rs
+++ b/src/tools/run-make-support/src/rustc.rs
@@ -64,6 +64,12 @@ impl Rustc {
         self
     }
 
+    /// Specify a specific optimization level.
+    pub fn opt_level(&mut self, option: &str) -> &mut Self {
+        self.cmd.arg(format!("-Copt-level={option}"));
+        self
+    }
+
     /// Specify type(s) of output files to generate.
     pub fn emit(&mut self, kinds: &str) -> &mut Self {
         self.cmd.arg(format!("--emit={kinds}"));
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 1a3d6f8d813..379d07ed22d 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -112,7 +112,6 @@ run-make/issue-37839/Makefile
 run-make/issue-37893/Makefile
 run-make/issue-38237/Makefile
 run-make/issue-40535/Makefile
-run-make/issue-46239/Makefile
 run-make/issue-47384/Makefile
 run-make/issue-47551/Makefile
 run-make/issue-51671/Makefile
diff --git a/tests/codegen/noalias-freeze.rs b/tests/codegen/noalias-freeze.rs
new file mode 100644
index 00000000000..8086f3afbbc
--- /dev/null
+++ b/tests/codegen/noalias-freeze.rs
@@ -0,0 +1,21 @@
+//@ compile-flags: -Copt-level=1
+
+// References returned by a Frozen pointer type
+// could be marked as "noalias", which caused miscompilation errors.
+// This test runs the most minimal possible code that can reproduce this bug,
+// and checks that noalias does not appear.
+// See https://github.com/rust-lang/rust/issues/46239
+
+#![crate_type = "lib"]
+
+fn project<T>(x: &(T,)) -> &T { &x.0 }
+
+fn dummy() {}
+
+// CHECK-LABEL: @foo(
+// CHECK-NOT: noalias
+#[no_mangle]
+pub fn foo() {
+    let f = (dummy as fn(),);
+    (*project(&f))();
+}
diff --git a/tests/run-make/issue-46239/Makefile b/tests/run-make/issue-46239/Makefile
deleted file mode 100644
index 0006ced2515..00000000000
--- a/tests/run-make/issue-46239/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# ignore-cross-compile
-include ../tools.mk
-
-all:
-	$(RUSTC) main.rs -C opt-level=1
-	$(call RUN,main)
diff --git a/tests/run-make/issue-46239/main.rs b/tests/run-make/issue-46239/main.rs
deleted file mode 100644
index b7df5cf4d81..00000000000
--- a/tests/run-make/issue-46239/main.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-fn project<T>(x: &(T,)) -> &T { &x.0 }
-
-fn dummy() {}
-
-fn main() {
-    let f = (dummy as fn(),);
-    (*project(&f))();
-}