Skip to content
/ rustc Public
forked from rust-lang/rust

Commit

Permalink
add codegen test for rust-lang#110797
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed May 20, 2024
1 parent 91d85f2 commit e040967
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/codegen/issues/issue-110797-enum-jump-same.rs
Original file line number Diff line number Diff line change
@@ -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(),
}
}

0 comments on commit e040967

Please sign in to comment.