diff options
| author | The 8472 <git@infinite-source.de> | 2025-08-15 01:20:37 +0200 |
|---|---|---|
| committer | The 8472 <git@infinite-source.de> | 2025-09-21 19:54:43 +0200 |
| commit | 5f0a68eb220c4aa780e0206ee6c6273413d8d5fd (patch) | |
| tree | 9934897f22209b1b45cef1c7706150e4a2f31259 | |
| parent | 6710835ae739ca326441ff6c63d24fb123858300 (diff) | |
| download | rust-5f0a68eb220c4aa780e0206ee6c6273413d8d5fd.tar.gz rust-5f0a68eb220c4aa780e0206ee6c6273413d8d5fd.zip | |
regression test for https://github.com/rust-lang/rust/issues/117763
| -rw-r--r-- | tests/codegen-llvm/issues/cows-dont-have-branches-117763.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/codegen-llvm/issues/cows-dont-have-branches-117763.rs b/tests/codegen-llvm/issues/cows-dont-have-branches-117763.rs new file mode 100644 index 00000000000..b97729fa146 --- /dev/null +++ b/tests/codegen-llvm/issues/cows-dont-have-branches-117763.rs @@ -0,0 +1,17 @@ +//@ 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-NOT: select + // CHECK-NOT: icmp + // CHECK: ret { ptr, {{i32|i64}} } + &*cow +} |
