about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorSimonas Kazlauskas <git@kazlauskas.me>2021-03-08 01:59:10 +0200
committerSimonas Kazlauskas <git@kazlauskas.me>2021-03-10 12:21:43 +0200
commit0517acd54353869b2fbfc50af61ea7bd1fd309e0 (patch)
treea3670ca840e1c6def8f4be36a7419f2682488863 /src/test/codegen
parent861872bc453bde79b83ff99d443d035225f10e87 (diff)
downloadrust-0517acd54353869b2fbfc50af61ea7bd1fd309e0.tar.gz
rust-0517acd54353869b2fbfc50af61ea7bd1fd309e0.zip
Remove the -Zinsert-sideeffect
This removes all of the code we had in place to work-around LLVM's
handling of forward progress. From this removal excluded is a workaround
where we'd insert a `sideeffect` into clearly infinite loops such as
`loop {}`. This code remains conditionally effective when the LLVM
version is earlier than 12.0, which fixed the forward progress related
miscompilations at their root.
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/loop.rs15
-rw-r--r--src/test/codegen/non-terminate/infinite-loop-1.rs3
-rw-r--r--src/test/codegen/non-terminate/infinite-loop-2.rs3
-rw-r--r--src/test/codegen/non-terminate/infinite-recursion.rs3
-rw-r--r--src/test/codegen/non-terminate/nonempty-infinite-loop.rs29
5 files changed, 35 insertions, 18 deletions
diff --git a/src/test/codegen/loop.rs b/src/test/codegen/loop.rs
deleted file mode 100644
index e54298eed05..00000000000
--- a/src/test/codegen/loop.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// compile-flags: -C opt-level=3
-
-#![crate_type = "lib"]
-
-// CHECK-LABEL: @check_loop
-#[no_mangle]
-pub fn check_loop() -> u8 {
-    // CHECK-NOT: unreachable
-    call_looper()
-}
-
-#[no_mangle]
-fn call_looper() -> ! {
-    loop {}
-}
diff --git a/src/test/codegen/non-terminate/infinite-loop-1.rs b/src/test/codegen/non-terminate/infinite-loop-1.rs
index 56b360e0a7f..8f9a53d19d4 100644
--- a/src/test/codegen/non-terminate/infinite-loop-1.rs
+++ b/src/test/codegen/non-terminate/infinite-loop-1.rs
@@ -1,4 +1,5 @@
-// compile-flags: -C opt-level=3 -Z insert-sideeffect
+// min-llvm-version: 12.0
+// compile-flags: -C opt-level=3
 
 #![crate_type = "lib"]
 
diff --git a/src/test/codegen/non-terminate/infinite-loop-2.rs b/src/test/codegen/non-terminate/infinite-loop-2.rs
index 2921ab6dc04..a4c76de1e3b 100644
--- a/src/test/codegen/non-terminate/infinite-loop-2.rs
+++ b/src/test/codegen/non-terminate/infinite-loop-2.rs
@@ -1,4 +1,5 @@
-// compile-flags: -C opt-level=3 -Z insert-sideeffect
+// min-llvm-version: 12.0
+// compile-flags: -C opt-level=3
 
 #![crate_type = "lib"]
 
diff --git a/src/test/codegen/non-terminate/infinite-recursion.rs b/src/test/codegen/non-terminate/infinite-recursion.rs
index 1f292ce379f..ccb22afbc7a 100644
--- a/src/test/codegen/non-terminate/infinite-recursion.rs
+++ b/src/test/codegen/non-terminate/infinite-recursion.rs
@@ -1,4 +1,5 @@
-// compile-flags: -C opt-level=3 -Z insert-sideeffect
+// min-llvm-version: 12.0
+// compile-flags: -C opt-level=3
 
 #![crate_type = "lib"]
 
diff --git a/src/test/codegen/non-terminate/nonempty-infinite-loop.rs b/src/test/codegen/non-terminate/nonempty-infinite-loop.rs
new file mode 100644
index 00000000000..896b7e8721c
--- /dev/null
+++ b/src/test/codegen/non-terminate/nonempty-infinite-loop.rs
@@ -0,0 +1,29 @@
+// min-llvm-version: 12.0
+// compile-flags: -C opt-level=3
+
+#![crate_type = "lib"]
+
+// Verify that we don't miscompile this even if rustc didn't apply the trivial loop detection to
+// insert the sideeffect intrinsic.
+
+fn infinite_loop() -> u8 {
+    let mut x = 0;
+    // CHECK-NOT: sideeffect
+    loop {
+        if x == 42 {
+            x = 0;
+        } else {
+            x = 42;
+        }
+    }
+}
+
+// CHECK-LABEL: @test
+#[no_mangle]
+fn test() -> u8 {
+    // CHECK-NOT: unreachable
+    // CHECK: br label %{{.+}}
+    // CHECK-NOT: unreachable
+    let x = infinite_loop();
+    x
+}