From 64cc56b31d9f0b624733afeb7465e93901257ebd Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 15 Aug 2023 11:14:01 +0200 Subject: [PATCH 1/3] Update LLVM submodule --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 7c612e1732f39..1833c2be108ae 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 7c612e1732f3976fcfe29526ad796cbb6174b829 +Subproject commit 1833c2be108aefcb5d25f6280cf9763b1feb8005 From 62ca87f45d57b98c79b76d00a6d6a49fd28e3b1e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 15 Aug 2023 11:30:36 +0200 Subject: [PATCH 2/3] Add test for #114691 --- tests/ui/match/issue-114691.rs | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/ui/match/issue-114691.rs diff --git a/tests/ui/match/issue-114691.rs b/tests/ui/match/issue-114691.rs new file mode 100644 index 0000000000000..cc17d9ecf05c6 --- /dev/null +++ b/tests/ui/match/issue-114691.rs @@ -0,0 +1,39 @@ +// run-pass + +// This test used to be miscompiled by LLVM 17. +#![allow(dead_code)] + +enum Pass { + Opaque { + clear_color: [f32; 4], + with_depth_pre_pass: bool, + }, + Transparent, +} + +enum LoadOp { + Clear, + Load, +} + +#[inline(never)] +fn check(x: Option) { + assert!(x.is_none()); +} + +#[inline(never)] +fn test(mode: Pass) { + check(match mode { + Pass::Opaque { + with_depth_pre_pass: true, + .. + } + | Pass::Transparent => None, + _ => Some(LoadOp::Clear), + }); +} + +fn main() { + println!("Hello, world!"); + test(Pass::Transparent); +} From c12c0841ad01d1239a1bd009610da2263ecde40b Mon Sep 17 00:00:00 2001 From: DianQK Date: Sat, 12 Aug 2023 00:24:25 +0800 Subject: [PATCH 3/3] Cherry-pick test for issue #114312 --- tests/codegen/issues/issue-114312.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/codegen/issues/issue-114312.rs diff --git a/tests/codegen/issues/issue-114312.rs b/tests/codegen/issues/issue-114312.rs new file mode 100644 index 0000000000000..e2fbcef721ef3 --- /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), + } +}