Skip to content

Commit a97ff2a

Browse files
committed
Add additional test cases for is_val_statically_known
1 parent 7bdf705 commit a97ff2a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/codegen/is_val_statically_known.rs

+38
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,41 @@ pub fn _bool_false(b: bool) -> i32 {
4646
// CHECK: ret i32 2
4747
_bool(b)
4848
}
49+
50+
#[inline]
51+
pub fn _iref(a: &u8) -> i32 {
52+
if unsafe { is_val_statically_known(a) } { 5 } else { 4 }
53+
}
54+
55+
// CHECK-LABEL: @_iref_borrow(
56+
#[no_mangle]
57+
pub fn _iref_borrow() -> i32 {
58+
// CHECK: ret i32 4
59+
_iref(&0)
60+
}
61+
62+
// CHECK-LABEL: @_iref_arg(
63+
#[no_mangle]
64+
pub fn _iref_arg(a: &u8) -> i32 {
65+
// CHECK: ret i32 4
66+
_iref(a)
67+
}
68+
69+
#[inline]
70+
pub fn _slice_ref(a: &[u8]) -> i32 {
71+
if unsafe { is_val_statically_known(a) } { 7 } else { 6 }
72+
}
73+
74+
// CHECK-LABEL: @_slice_ref_borrow(
75+
#[no_mangle]
76+
pub fn _slice_ref_borrow() -> i32 {
77+
// CHECK: ret i32 6
78+
_slice_ref(&[0;3])
79+
}
80+
81+
// CHECK-LABEL: @_slice_ref_arg(
82+
#[no_mangle]
83+
pub fn _slice_ref_arg(a: &[u8]) -> i32 {
84+
// CHECK: ret i32 6
85+
_slice_ref(a)
86+
}

0 commit comments

Comments
 (0)