about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-03-09 01:47:39 +0000
committerbors <bors@rust-lang.org>2021-03-09 01:47:39 +0000
commitbb3afe1e609b70ef2a8e75072e6eb5828416c012 (patch)
tree5096b96092241d2c6d4596be417607a8c19cfefb /src/test/codegen
parenteb476b172f12dfbbee386d027b1ad6c0bc203a9b (diff)
parent54add8dfcaceb1c8a0bf30ae22cebd681bd17c98 (diff)
downloadrust-bb3afe1e609b70ef2a8e75072e6eb5828416c012.tar.gz
rust-bb3afe1e609b70ef2a8e75072e6eb5828416c012.zip
Auto merge of #82911 - m-ou-se:rollup-rjomgja, r=m-ou-se
Rollup of 11 pull requests

Successful merges:

 - #82711 (Add documentation for string->Cow conversions)
 - #82767 (Update minifier dependency version)
 - #82800 (Move rustdoc UI tests into a subdirectory)
 - #82810 (Typo fix in Unstable book: `cargo cov` -> `cargo profdata`)
 - #82829 (Handle negative literals in cast overflow warning)
 - #82854 (Account for `if (let pat = expr) {}`)
 - #82870 (Add note about the `#[doc(no-inline)]` usage)
 - #82874 (Add codegen tests for some issues closed by LLVM 12)
 - #82881 (diagnostics: Be clear about "crate root" and `::foo` paths in resolve diagnostics)
 - #82888 (Grammar Fixes)
 - #82897 ([.mailmap] Add entry for Ramkumar Ramachandra)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/issue-73031.rs27
-rw-r--r--src/test/codegen/issue-75546.rs16
-rw-r--r--src/test/codegen/issue-77812.rs33
3 files changed, 76 insertions, 0 deletions
diff --git a/src/test/codegen/issue-73031.rs b/src/test/codegen/issue-73031.rs
new file mode 100644
index 00000000000..6ba4d707f42
--- /dev/null
+++ b/src/test/codegen/issue-73031.rs
@@ -0,0 +1,27 @@
+// min-llvm-version: 12.0.0
+// compile-flags: -O
+#![crate_type = "lib"]
+
+// Test that LLVM can eliminate the unreachable `All::None` branch.
+
+pub enum All {
+    None,
+    Foo,
+    Bar,
+}
+
+// CHECK-LABEL: @issue_73031
+#[no_mangle]
+pub fn issue_73031(a: &mut All, q: i32) -> i32 {
+    *a = if q == 5 {
+        All::Foo
+    } else {
+        All::Bar
+    };
+    match *a {
+        // CHECK-NOT: panic
+        All::None => panic!(),
+        All::Foo => 1,
+        All::Bar => 2,
+    }
+}
diff --git a/src/test/codegen/issue-75546.rs b/src/test/codegen/issue-75546.rs
new file mode 100644
index 00000000000..49e4d4c7ec5
--- /dev/null
+++ b/src/test/codegen/issue-75546.rs
@@ -0,0 +1,16 @@
+// min-llvm-version: 12.0.0
+// compile-flags: -O
+#![crate_type = "lib"]
+
+// Test that LLVM can eliminate the impossible `i == 0` check.
+
+// CHECK-LABEL: @issue_75546
+#[no_mangle]
+pub fn issue_75546() {
+    let mut i = 1u32;
+    while i < u32::MAX {
+        // CHECK-NOT: panic
+        if i == 0 { panic!(); }
+        i += 1;
+    }
+}
diff --git a/src/test/codegen/issue-77812.rs b/src/test/codegen/issue-77812.rs
new file mode 100644
index 00000000000..95042579adb
--- /dev/null
+++ b/src/test/codegen/issue-77812.rs
@@ -0,0 +1,33 @@
+// min-llvm-version: 12.0.0
+// compile-flags: -O
+#![crate_type = "lib"]
+
+// Test that LLVM can eliminate the unreachable `Variant::Zero` branch.
+
+#[derive(Copy, Clone, Eq, PartialEq)]
+pub enum Variant {
+    Zero,
+    One,
+    Two,
+}
+
+extern {
+    fn exf1();
+    fn exf2();
+}
+
+pub static mut GLOBAL: Variant = Variant::Zero;
+
+// CHECK-LABEL: @issue_77812
+#[no_mangle]
+pub unsafe fn issue_77812() {
+    let g = GLOBAL;
+    if g != Variant::Zero {
+        match g {
+            Variant::One => exf1(),
+            Variant::Two => exf2(),
+            // CHECK-NOT: panic
+            Variant::Zero => panic!(),
+        }
+    }
+}