Skip to content

Commit

Permalink
Add additional test cases for is_val_statically_known
Browse files Browse the repository at this point in the history
  • Loading branch information
Teapot4195 committed Jan 30, 2024
1 parent 7bdf705 commit a97ff2a
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/codegen/is_val_statically_known.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,41 @@ pub fn _bool_false(b: bool) -> i32 {
// CHECK: ret i32 2
_bool(b)
}

#[inline]
pub fn _iref(a: &u8) -> i32 {
if unsafe { is_val_statically_known(a) } { 5 } else { 4 }
}

// CHECK-LABEL: @_iref_borrow(
#[no_mangle]
pub fn _iref_borrow() -> i32 {
// CHECK: ret i32 4
_iref(&0)
}

// CHECK-LABEL: @_iref_arg(
#[no_mangle]
pub fn _iref_arg(a: &u8) -> i32 {
// CHECK: ret i32 4
_iref(a)
}

#[inline]
pub fn _slice_ref(a: &[u8]) -> i32 {
if unsafe { is_val_statically_known(a) } { 7 } else { 6 }
}

// CHECK-LABEL: @_slice_ref_borrow(
#[no_mangle]
pub fn _slice_ref_borrow() -> i32 {
// CHECK: ret i32 6
_slice_ref(&[0;3])
}

// CHECK-LABEL: @_slice_ref_arg(
#[no_mangle]
pub fn _slice_ref_arg(a: &[u8]) -> i32 {
// CHECK: ret i32 6
_slice_ref(a)
}

0 comments on commit a97ff2a

Please sign in to comment.