Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/codegen-llvm/issues/cows-dont-have-branches-117763.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ compile-flags: -Copt-level=3
//@ needs-deterministic-layouts

// Currently Vec<T> and &[T] have layouts that start with (pointer, len)
// which makes the conversion branchless.
// A nice-to-have property, not guaranteed.
#![crate_type = "cdylib"]

// CHECK-LABEL: @branchless_cow_slices
#[no_mangle]
pub fn branchless_cow_slices<'a>(cow: &'a std::borrow::Cow<'a, [u8]>) -> &'a [u8] {
// CHECK-NOT: br
// CHECK: ret { ptr, i64 }
&*cow
}
Loading