about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorDianQK <dianqk@dianqk.net>2023-08-12 00:24:25 +0800
committerNikita Popov <npopov@redhat.com>2023-08-15 11:33:45 +0200
commitc12c0841ad01d1239a1bd009610da2263ecde40b (patch)
treece02f0e5acae7b396560b89757f7f166c280c2ad /tests
parent62ca87f45d57b98c79b76d00a6d6a49fd28e3b1e (diff)
downloadrust-c12c0841ad01d1239a1bd009610da2263ecde40b.tar.gz
rust-c12c0841ad01d1239a1bd009610da2263ecde40b.zip
Cherry-pick test for issue #114312
Diffstat (limited to 'tests')
-rw-r--r--tests/codegen/issues/issue-114312.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/codegen/issues/issue-114312.rs b/tests/codegen/issues/issue-114312.rs
new file mode 100644
index 00000000000..e2fbcef721e
--- /dev/null
+++ b/tests/codegen/issues/issue-114312.rs
@@ -0,0 +1,27 @@
+// compile-flags: -O
+// min-llvm-version: 17
+// only-x86_64-unknown-linux-gnu
+
+// We want to check that this function does not mis-optimize to loop jumping.
+
+#![crate_type = "lib"]
+
+#[repr(C)]
+pub enum Expr {
+    Sum,
+    // must have more than usize data
+    Sub(usize, u8),
+}
+
+#[no_mangle]
+pub extern "C" fn issue_114312(expr: Expr) {
+    // CHECK-LABEL: @issue_114312(
+    // CHECK-NOT: readonly
+    // CHECK-SAME: byval
+    // CHECK-NEXT: start:
+    // CHECK-NEXT: ret void
+    match expr {
+        Expr::Sum => {}
+        Expr::Sub(_, _) => issue_114312(Expr::Sum),
+    }
+}