diff options
| author | bors <bors@rust-lang.org> | 2021-03-10 14:03:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-10 14:03:00 +0000 |
| commit | 5fe790e3c40710ecb95ddaadb98b59a3bb4f8326 (patch) | |
| tree | 85393bce32f8f4f6ea0478ac44e0e8fa02ccabd4 /src/test/codegen | |
| parent | a4d9624242df6bfe6c0a298867dd2bd527263424 (diff) | |
| parent | 0517acd54353869b2fbfc50af61ea7bd1fd309e0 (diff) | |
| download | rust-5fe790e3c40710ecb95ddaadb98b59a3bb4f8326.tar.gz rust-5fe790e3c40710ecb95ddaadb98b59a3bb4f8326.zip | |
Auto merge of #82884 - nagisa:nagisa/remove-most-of-sideeffect-inserts, r=nikic
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.rs | 15 | ||||
| -rw-r--r-- | src/test/codegen/non-terminate/infinite-loop-1.rs | 3 | ||||
| -rw-r--r-- | src/test/codegen/non-terminate/infinite-loop-2.rs | 3 | ||||
| -rw-r--r-- | src/test/codegen/non-terminate/infinite-recursion.rs | 3 | ||||
| -rw-r--r-- | src/test/codegen/non-terminate/nonempty-infinite-loop.rs | 29 |
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 +} |
