From ddb94dbd16760d6de5e3a9cbbffb66e161691786 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 20 May 2024 19:40:50 +0000 Subject: [PATCH] add codegen test for #110797 --- .../issues/issue-110797-enum-jump-same.rs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/codegen/issues/issue-110797-enum-jump-same.rs diff --git a/tests/codegen/issues/issue-110797-enum-jump-same.rs b/tests/codegen/issues/issue-110797-enum-jump-same.rs new file mode 100644 index 00000000000..bfd10c0a582 --- /dev/null +++ b/tests/codegen/issues/issue-110797-enum-jump-same.rs @@ -0,0 +1,27 @@ +//@ compile-flags: -O +// XXX: The x86-64 assembly get optimized correclty. But llvm-ir output is not until llvm 18? +//@ min-llvm-version: 18 + +#![crate_type = "lib"] + +pub enum K{ + A(Box<[i32]>), + B(Box<[u8]>), + C(Box<[String]>), + D(Box<[u16]>), +} + +#[no_mangle] +// CHECK-LABEL: @get_len +// CHECK: getelementptr inbounds +// CHECK-NEXT: load +// CHECK-NEXT: ret i64 +// CHECK-NOT: switch +pub fn get_len(arg: &K)->usize{ + match arg { + K::A(ref lst)=>lst.len(), + K::B(ref lst)=>lst.len(), + K::C(ref lst)=>lst.len(), + K::D(ref lst)=>lst.len(), + } +}