2024-05-20 14:40:50 -05:00
|
|
|
//@ compile-flags: -O
|
|
|
|
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
2024-06-09 08:25:12 -05:00
|
|
|
pub enum K {
|
2024-05-20 14:40:50 -05:00
|
|
|
A(Box<[i32]>),
|
|
|
|
B(Box<[u8]>),
|
|
|
|
C(Box<[String]>),
|
|
|
|
D(Box<[u16]>),
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: @get_len
|
2024-06-09 08:25:12 -05:00
|
|
|
// CHECK-NEXT: {{.*}}:
|
|
|
|
// CHECK-NEXT: getelementptr inbounds
|
2024-06-11 02:45:16 -05:00
|
|
|
// CHECK-NEXT: load [[TYPE:i(32|64)]]
|
|
|
|
// CHECK-NEXT: ret [[TYPE]]
|
2024-06-09 08:25:12 -05:00
|
|
|
#[no_mangle]
|
|
|
|
pub fn get_len(arg: &K) -> usize {
|
2024-05-20 14:40:50 -05:00
|
|
|
match arg {
|
2024-06-09 08:25:12 -05:00
|
|
|
K::A(ref lst) => lst.len(),
|
|
|
|
K::B(ref lst) => lst.len(),
|
|
|
|
K::C(ref lst) => lst.len(),
|
|
|
|
K::D(ref lst) => lst.len(),
|
2024-05-20 14:40:50 -05:00
|
|
|
}
|
|
|
|
}
|