Skip to content

Refactor sized Rc/Arc allocation/initialization#152600

Open
alexcrichton wants to merge 1 commit intorust-lang:mainfrom
alexcrichton:refactor-more-rc
Open

Refactor sized Rc/Arc allocation/initialization#152600
alexcrichton wants to merge 1 commit intorust-lang:mainfrom
alexcrichton:refactor-more-rc

Conversation

@alexcrichton
Copy link
Member

This commit refactors the Rc and Arc types in the standard library to have a new narrow waist for all allocations of sized types. Specifically a new {Rc,Arc}::from_box_uninit_inner function is added which takes an entirely-uninitialized Box pointer, initializes the reference counts, and then returns Rc/Arc where the payload is MaybeUninit<T>. This is purely an internal refactor of functions at this time and doesn't expose any new API surface area for either Arc or Rc.

It's also worth noting that there remain two primary ways of allocating Rc/Arc, like before. Notably allocating Rc<[T]> is not possible with this helper because MaybeUninit does not support unsized types at this time. It's hoped though that in the future if this is supported that all allocations of Rc/Arc could be funneled through this method.

While this refactor was done I went through a number of other constructors/etc and simplified the implementations to use combinations of other APIs of Rc/Arc, removing a number of unsafe blocks along the way.

The overall goal of this refactor is to move towards this discussion on Zulip. Eventually the from_box_uninit_inner function would perhaps be exposed as a From impl on Rc and Arc, or maybe a public inherent function. This would require making the {Rc,Arc}Inner types public, however, so this part is deferred for a future ACP. In the meantime though I thought that this pattern of initialization was pretty nifty and would be a good internal refactoring to do in the meantime regardless.

This commit refactors the `Rc` and `Arc` types in the standard library
to have a new narrow waist for all allocations of sized types.
Specifically a new `{Rc,Arc}::from_box_uninit_inner` function is added
which takes an entirely-uninitialized `Box` pointer, initializes the
reference counts, and then returns `Rc`/`Arc` where the payload is
`MaybeUninit<T>`. This is purely an internal refactor of functions at
this time and doesn't expose any new API surface area for either `Arc`
or `Rc`.

It's also worth noting that there remain two primary ways of allocating
`Rc`/`Arc`, like before. Notably allocating `Rc<[T]>` is not possible
with this helper because `MaybeUninit` does not support unsized types at
this time. It's hoped though that in the future if this is supported
that all allocations of `Rc`/`Arc` could be funneled through this
method.

While this refactor was done I went through a number of other
constructors/etc and simplified the implementations to use combinations
of other APIs of `Rc`/`Arc`, removing a number of `unsafe` blocks along
the way.

The overall goal of this refactor is to move towards [this discussion on
Zulip][Zulip]. Eventually the `from_box_uninit_inner` function would
perhaps be exposed as a `From` impl on `Rc` and `Arc`, or maybe a public
inherent function. This would require making the `{Rc,Arc}Inner` types
public, however, so this part is deferred for a future ACP. In the
meantime though I thought that this pattern of initialization was pretty
nifty and would be a good internal refactoring to do in the meantime
regardless.

[Zulip]: https://rust-lang.zulipchat.com/#narrow/channel/197181-t-libs.2Fwg-allocators/topic/Fallible.20allocation.20of.20.60Arc.3CT.3E.60.20w.2Fout.20all.20of.20.60allocator_api.60/near/569793763
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 14, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 7 candidates
  • Random selection from Mark-Simulacrum, joboet

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[group]Runner Image Provisioner
Hosted Compute Agent
Version: 20260123.484
Commit: 6bd6555ca37d84114959e1c76d2c01448ff61c5d
Build Date: 2026-01-23T19:41:17Z
Worker ID: {70bdb43e-083a-441f-9085-3591e829a033}
Azure Region: southcentralus
##[endgroup]
##[group]VM Image
- OS: Linux (arm64)
- Source: Partner
- Name: Ubuntu 24.04 by Arm Limited
---
REPOSITORY                                   TAG       IMAGE ID       CREATED       SIZE
ghcr.io/dependabot/dependabot-updater-core   latest    afc745c7535d   2 weeks ago   783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:faae3d3a1dedd24cde388bb506bbacc0f7ed1eae99ebac129af66acd8540c84a
deleted: sha256:afc745c7535da1bb12f92c273b9a7e9c52c3f12c5873714b2542da259c6d9769
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
test [ui] tests/ui/abi/abi-sysv64-register-usage.rs ... ignored, ignored when the architecture is aarch64
test [ui] tests/ui/abi/abi-typo-unstable.rs#feature_disabled ... ok
test [ui] tests/ui/abi/abi-typo-unstable.rs#feature_enabled ... ok
test [ui] tests/ui/abi/anon-extern-mod.rs ... ok
test [ui] tests/ui/abi/avr-sram.rs#disable_sram ... ok
test [ui] tests/ui/abi/arm-unadjusted-intrinsic.rs#aarch64 ... ok
test [ui] tests/ui/abi/avr-sram.rs#has_sram ... ok
test [ui] tests/ui/abi/avr-sram.rs#no_sram ... ok
test [ui] tests/ui/abi/arm-unadjusted-intrinsic.rs#arm ... ok
test [ui] tests/ui/abi/bad-custom.rs ... ok
test [ui] tests/ui/abi/c-stack-as-value.rs ... ok
test [ui] tests/ui/abi/c-zst.rs#aarch64-darwin ... ok
test [ui] tests/ui/abi/c-zst.rs#powerpc-linux ... ok
---
test [ui] tests/ui/asm/aarch64/may_unwind.rs ... ok
test [ui] tests/ui/asm/aarch64/type-check-2.rs ... ok
test [ui] tests/ui/asm/aarch64/type-check-3.rs ... ok
test [ui] tests/ui/asm/aarch64/type-f16.rs ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#r82 ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#hf ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#sf ... ok
test [ui] tests/ui/asm/asm-with-nested-closure.rs ... ok
test [ui] tests/ui/asm/arm-low-dreg.rs ... ok
test [ui] tests/ui/asm/binary_asm_labels.rs ... ignored, only executed when the architecture is x86_64
test [ui] tests/ui/asm/aarch64/sym.rs ... ok
test [ui] tests/ui/asm/cfg-parse-error.rs ... ok
---
test [ui] tests/ui/const-generics/occurs-check/unused-substs-2.rs ... ok
test [ui] tests/ui/const-generics/occurs-check/unused-substs-3.rs ... ok
test [ui] tests/ui/const-generics/occurs-check/unused-substs-4.rs ... ok
test [ui] tests/ui/const-generics/occurs-check/unused-substs-5.rs ... ok
test [ui] tests/ui/const-generics/ogca/basic-fail.rs ... ok
test [ui] tests/ui/const-generics/ogca/basic.rs ... ok
test [ui] tests/ui/const-generics/ogca/coherence-ambiguous.rs ... ok
test [ui] tests/ui/const-generics/ogca/rhs-but-not-root.rs ... ok
test [ui] tests/ui/const-generics/outer-lifetime-in-const-generic-default.rs ... ok
test [ui] tests/ui/const-generics/opaque_types.rs ... ok
test [ui] tests/ui/const-generics/opaque_types2.rs ... ok
test [ui] tests/ui/const-generics/overlapping_impls.rs ... ok
test [ui] tests/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs#full ... ok
---
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#fat3 ... ok
test [ui] tests/ui/extern/issue-80074.rs ... ok
test [ui] tests/ui/extern/issue-95829.rs ... ok
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#thin1 ... ok
test [ui] tests/ui/extern/lgamma-linkage.rs ... ok
test [ui] tests/ui/extern/not-in-block.rs ... ok
test [ui] tests/ui/extern/unsized-extern-derefmove.rs ... ok
test [ui] tests/ui/extern/no-mangle-associated-fn.rs ... ok
test [ui] tests/ui/feature-gates/allow-features-empty.rs ... ok
test [ui] tests/ui/extern/windows-tcb-trash-13259.rs ... ok
---
test [ui] tests/ui/feature-gates/feature-gate-loop-match.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-macro-derive.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-macro-attr.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-macro-metavar-expr-concat.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-mgca-type-const-syntax.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-marker_trait_attr.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-may-dangle.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-min-generic-const-args.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-movrs_target_feature.rs ... ignored, only executed when the architecture is x86_64
test [ui] tests/ui/feature-gates/feature-gate-min_const_fn.rs ... ok
---
test [ui] tests/ui/imports/ambiguous-8.rs ... ok
test [ui] tests/ui/imports/ambiguous-glob-vs-expanded-extern.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-glob-vs-multiouter.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-no-implicit-prelude.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-globvsglob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-non-prelude-std-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-non-prelude-core-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-pick-core.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-pick-std.rs ... ok
test [ui] tests/ui/imports/ambiguous-import-visibility-macro.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-rename-builtin.rs ... ok
---
------FileCheck stderr------------------------------
/checkout/tests/codegen-llvm/issues/issue-111603.rs:23:12: error: CHECK: expected string not found in input
 // CHECK: call alloc::sync::arcinner_layout_for_value_layout
           ^
/checkout/obj/build/aarch64-unknown-linux-gnu/test/codegen-llvm/issues/issue-111603/issue-111603.ll:50:47: note: scanning from here
define noalias noundef nonnull ptr @new_uninit(i64 noundef %x) unnamed_addr #0 personality ptr @rust_eh_personality {
                                              ^
/checkout/obj/build/aarch64-unknown-linux-gnu/test/codegen-llvm/issues/issue-111603/issue-111603.ll:61:3: note: possible intended match here
; call alloc::alloc::handle_alloc_error
  ^

Input file: /checkout/obj/build/aarch64-unknown-linux-gnu/test/codegen-llvm/issues/issue-111603/issue-111603.ll
Check file: /checkout/tests/codegen-llvm/issues/issue-111603.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ; ModuleID = 'issue_111603.8eafb1a0a540be9f-cgu.0' 
            2: source_filename = "issue_111603.8eafb1a0a540be9f-cgu.0" 
            3: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32" 
            4: target triple = "aarch64-unknown-linux-gnu" 
            5:  
            6: @alloc_ac1493a8bf84bc8bab0d3f1c9c85d5c4 = private unnamed_addr constant [45 x i8] c"/rustc/FAKE_PREFIX/library/alloc/src/sync.rs\00", align 1 
            7: @alloc_e4f66ebc6994e60894cebfdce794d51f = private unnamed_addr constant <{ [8 x i8], ptr, [8 x i8] }> <{ [8 x i8] c"m\08\00\00\09\00\00\00", ptr @alloc_ac1493a8bf84bc8bab0d3f1c9c85d5c4, [8 x i8] c",\00\00\00\00\00\00\00" }>, align 8 
            8:  
            9: ; Function Attrs: uwtable 
           10: define { ptr, i64 } @new_from_array(i64 noundef %x) unnamed_addr #0 personality ptr @rust_eh_personality { 
           11: start: 
           12:  %array = alloca [8000 x i8], align 8 
           13:  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %x, i64 0 
           14:  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer 
           15:  br label %vector.body 
           16:  
           17: vector.body: ; preds = %vector.body, %start 
           18:  %index = phi i64 [ 0, %start ], [ %index.next, %vector.body ] 
           19:  %0 = getelementptr inbounds nuw i64, ptr %array, i64 %index 
           20:  %1 = getelementptr inbounds nuw i8, ptr %0, i64 16 
           21:  store <2 x i64> %broadcast.splat, ptr %0, align 8 
           22:  store <2 x i64> %broadcast.splat, ptr %1, align 8 
           23:  %index.next = add nuw i64 %index, 4 
           24:  %2 = icmp eq i64 %index.next, 1000 
           25:  br i1 %2, label %repeat_loop_next, label %vector.body, !llvm.loop !2 
           26:  
           27: repeat_loop_next: ; preds = %vector.body 
           28: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 
           29:  tail call void @_RNvCs3LcVZ4W5lqF_7___rustc35___rust_no_alloc_shim_is_unstable_v2() #7, !noalias !5 
           30: ; call __rustc::__rust_alloc 
           31:  %3 = tail call noalias noundef align 8 dereferenceable_or_null(8016) ptr @_RNvCs3LcVZ4W5lqF_7___rustc12___rust_alloc(i64 noundef 8016, i64 noundef 8) #7, !noalias !5 
           32:  %4 = icmp eq ptr %3, null 
           33:  br i1 %4, label %bb3.i.i, label %_RNvMse_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcAyj3e8_E3newCscfvYVcvsPgx_12issue_111603.exit, !prof !8 
           34:  
           35: bb3.i.i: ; preds = %repeat_loop_next 
           36: ; call alloc::alloc::handle_alloc_error 
           37:  tail call void @_RNvNtCs3eZPr1ZwVuP_5alloc5alloc18handle_alloc_error(i64 noundef 8, i64 noundef 8016) #8, !noalias !5 
           38:  unreachable 
           39:  
           40: _RNvMse_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcAyj3e8_E3newCscfvYVcvsPgx_12issue_111603.exit: ; preds = %repeat_loop_next 
           41:  store <2 x i64> splat (i64 1), ptr %3, align 8, !alias.scope !9, !noalias !5 
           42:  %5 = getelementptr inbounds nuw i8, ptr %3, i64 16 
           43:  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(8000) %5, ptr noundef nonnull readonly align 8 dereferenceable(8000) %array, i64 8000, i1 false) 
           44:  %6 = insertvalue { ptr, i64 } poison, ptr %3, 0 
           45:  %7 = insertvalue { ptr, i64 } %6, i64 1000, 1 
           46:  ret { ptr, i64 } %7 
           47: } 
           48:  
           49: ; Function Attrs: uwtable 
           50: define noalias noundef nonnull ptr @new_uninit(i64 noundef %x) unnamed_addr #0 personality ptr @rust_eh_personality { 
check:23'0                                                   X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
           51: start: 
check:23'0     ~~~~~~~
           52:  %_3 = alloca [8000 x i8], align 8 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           53: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           54:  tail call void @_RNvCs3LcVZ4W5lqF_7___rustc35___rust_no_alloc_shim_is_unstable_v2() #7 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           55: ; call __rustc::__rust_alloc 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           56:  %0 = tail call noalias noundef align 8 dereferenceable_or_null(8016) ptr @_RNvCs3LcVZ4W5lqF_7___rustc12___rust_alloc(i64 noundef 8016, i64 noundef 8) #7 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           57:  %1 = icmp eq ptr %0, null 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
           58:  br i1 %1, label %bb3.i, label %_RNvMs_NtCs3eZPr1ZwVuP_5alloc5boxedINtB4_3BoxINtNtB6_4sync8ArcInnerAyj3e8_EE13new_uninit_inCscfvYVcvsPgx_12issue_111603.exit, !prof !8 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           59:  
check:23'0     ~
           60: bb3.i: ; preds = %start 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~
           61: ; call alloc::alloc::handle_alloc_error 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:23'1       ?                                      possible intended match
           62:  tail call void @_RNvNtCs3eZPr1ZwVuP_5alloc5alloc18handle_alloc_error(i64 noundef 8, i64 noundef 8016) #8 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           63:  unreachable 
check:23'0     ~~~~~~~~~~~~~
           64:  
check:23'0     ~
           65: _RNvMs_NtCs3eZPr1ZwVuP_5alloc5boxedINtB4_3BoxINtNtB6_4sync8ArcInnerAyj3e8_EE13new_uninit_inCscfvYVcvsPgx_12issue_111603.exit: ; preds = %start 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           66:  store <2 x i64> splat (i64 1), ptr %0, align 8, !alias.scope !12 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           67:  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %x, i64 0 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           68:  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           69:  br label %vector.body 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~
           70:  
check:23'0     ~
           71: vector.body: ; preds = %vector.body, %_RNvMs_NtCs3eZPr1ZwVuP_5alloc5boxedINtB4_3BoxINtNtB6_4sync8ArcInnerAyj3e8_EE13new_uninit_inCscfvYVcvsPgx_12issue_111603.exit 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           72:  %index = phi i64 [ 0, %_RNvMs_NtCs3eZPr1ZwVuP_5alloc5boxedINtB4_3BoxINtNtB6_4sync8ArcInnerAyj3e8_EE13new_uninit_inCscfvYVcvsPgx_12issue_111603.exit ], [ %index.next, %vector.body ] 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           73:  %2 = getelementptr inbounds nuw i64, ptr %_3, i64 %index 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           74:  %3 = getelementptr inbounds nuw i8, ptr %2, i64 16 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           75:  store <2 x i64> %broadcast.splat, ptr %2, align 8 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           76:  store <2 x i64> %broadcast.splat, ptr %3, align 8 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           77:  %index.next = add nuw i64 %index, 4 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           78:  %4 = icmp eq i64 %index.next, 1000 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           79:  br i1 %4, label %repeat_loop_next, label %vector.body, !llvm.loop !15 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           80:  
check:23'0     ~
           81: repeat_loop_next: ; preds = %vector.body 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           82:  %5 = getelementptr inbounds nuw i8, ptr %0, i64 16 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           83:  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(8000) %5, ptr noundef nonnull align 8 dereferenceable(8000) %_3, i64 8000, i1 false) 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           84:  ret ptr %0 
check:23'0     ~~~~~~~~~~~~
           85: } 
check:23'0     ~~
           86:  
check:23'0     ~
           87: ; Function Attrs: uwtable 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~
           88: define { ptr, i64 } @new_uninit_slice(i64 noundef %x) unnamed_addr #0 personality ptr @rust_eh_personality { 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           89: start: 
           90:  %_8.i.i.i = alloca [16 x i8], align 16 
           91:  %layout.i.i.i = alloca [16 x i8], align 8 
           92: ; call alloc::sync::arcinner_layout_for_value_layout 
           93:  %0 = tail call { i64, i64 } @_RNvNtCs3eZPr1ZwVuP_5alloc4sync32arcinner_layout_for_value_layout(i64 noundef 8, i64 noundef 8000) 
           94:  %layout.0.i.i = extractvalue { i64, i64 } %0, 0 
           95:  %layout.1.i.i = extractvalue { i64, i64 } %0, 1 
           96:  %1 = icmp eq i64 %layout.1.i.i, 0 
           97:  br i1 %1, label %bb2.i.i.i.i, label %bb4.i.i.i.i 
           98:  
           99: bb2.i.i.i.i: ; preds = %start 
          100:  %_15.i.i.i.i = inttoptr i64 %layout.0.i.i to ptr 
          101:  br label %_RNCNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB7_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_slice0CscfvYVcvsPgx_12issue_111603.exit.i.i 
          102:  
          103: bb4.i.i.i.i: ; preds = %start 
          104: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 
          105:  tail call void @_RNvCs3LcVZ4W5lqF_7___rustc35___rust_no_alloc_shim_is_unstable_v2() #7 
          106: ; call __rustc::__rust_alloc 
          107:  %2 = tail call noundef ptr @_RNvCs3LcVZ4W5lqF_7___rustc12___rust_alloc(i64 noundef %layout.1.i.i, i64 noundef range(i64 1, -9223372036854775807) %layout.0.i.i) #7 
          108:  br label %_RNCNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB7_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_slice0CscfvYVcvsPgx_12issue_111603.exit.i.i 
          109:  
          110: _RNCNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB7_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_slice0CscfvYVcvsPgx_12issue_111603.exit.i.i: ; preds = %bb4.i.i.i.i, %bb2.i.i.i.i 
          111:  %_0.sroa.0.0.i.i.i.i = phi ptr [ %_15.i.i.i.i, %bb2.i.i.i.i ], [ %2, %bb4.i.i.i.i ] 
          112:  %3 = icmp eq ptr %_0.sroa.0.0.i.i.i.i, null 
          113:  br i1 %3, label %bb10.i.i, label %bb11.i.i, !prof !8 
          114:  
          115: bb10.i.i: ; preds = %_RNCNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB7_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_slice0CscfvYVcvsPgx_12issue_111603.exit.i.i 
          116: ; call alloc::alloc::handle_alloc_error 
          117:  tail call void @_RNvNtCs3eZPr1ZwVuP_5alloc5alloc18handle_alloc_error(i64 noundef %layout.0.i.i, i64 noundef %layout.1.i.i) #8 
          118:  unreachable 
          119:  
          120: bb11.i.i: ; preds = %_RNCNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB7_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_slice0CscfvYVcvsPgx_12issue_111603.exit.i.i 
          121:  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %layout.i.i.i) 
          122:  store i64 %layout.0.i.i, ptr %layout.i.i.i, align 8 
          123:  %4 = getelementptr inbounds nuw i8, ptr %layout.i.i.i, i64 8 
          124:  store i64 %layout.1.i.i, ptr %4, align 8 
          125:  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %_8.i.i.i) 
          126:  store <2 x i64> <i64 8, i64 8016>, ptr %_8.i.i.i, align 16 
          127:  %_21.i.i.i = icmp eq i64 %layout.1.i.i, 8016 
          128:  %_11.i.i.i = icmp eq i64 %layout.0.i.i, 8 
          129:  %or.cond.i.i.i = and i1 %_11.i.i.i, %_21.i.i.i 
          130:  br i1 %or.cond.i.i.i, label %_RNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_sliceCscfvYVcvsPgx_12issue_111603.exit, label %bb3.i.i.i, !prof !16 
          131:  
          132: bb3.i.i.i: ; preds = %bb11.i.i 
          133: ; call core::panicking::assert_failed::<core::alloc::layout::Layout, core::alloc::layout::Layout> 
          134:  call void @_RINvNtCs2Lwqn61Hkzc_4core9panicking13assert_failedNtNtNtB4_5alloc6layout6LayoutBM_ECs3eZPr1ZwVuP_5alloc(i8 noundef 0, ptr noalias noundef nonnull readonly align 8 dereferenceable(16) %_8.i.i.i, ptr noalias noundef nonnull readonly align 8 dereferenceable(16) %layout.i.i.i, ptr noundef null, ptr undef, ptr noalias noundef nonnull readonly align 8 dereferenceable(24) @alloc_e4f66ebc6994e60894cebfdce794d51f) #9 
          135:  unreachable 
          136:  
          137: _RNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_sliceCscfvYVcvsPgx_12issue_111603.exit: ; preds = %bb11.i.i 
          138:  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %_8.i.i.i) 
          139:  store <2 x i64> splat (i64 1), ptr %_0.sroa.0.0.i.i.i.i, align 8 
          140:  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %layout.i.i.i) 
          141:  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %x, i64 0 
          142:  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer 
          143:  br label %vector.body 
          144:  
          145: vector.body: ; preds = %vector.body, %_RNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_sliceCscfvYVcvsPgx_12issue_111603.exit 
          146:  %index = phi i64 [ 0, %_RNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_sliceCscfvYVcvsPgx_12issue_111603.exit ], [ %index.next, %vector.body ] 
          147:  %5 = shl i64 %index, 3 
          148:  %offset.idx = or disjoint i64 %5, 16 
          149:  %6 = getelementptr inbounds nuw i8, ptr %_0.sroa.0.0.i.i.i.i, i64 %offset.idx 
          150:  %7 = getelementptr inbounds nuw i8, ptr %6, i64 16 
          151:  store <2 x i64> %broadcast.splat, ptr %6, align 8 
          152:  store <2 x i64> %broadcast.splat, ptr %7, align 8 
          153:  %index.next = add nuw i64 %index, 4 
          154:  %8 = icmp eq i64 %index.next, 1000 
          155:  br i1 %8, label %bb3, label %vector.body, !llvm.loop !17 
          156:  
          157: bb3: ; preds = %vector.body 
          158:  %9 = insertvalue { ptr, i64 } poison, ptr %_0.sroa.0.0.i.i.i.i, 0 
          159:  %10 = insertvalue { ptr, i64 } %9, i64 1000, 1 
          160:  ret { ptr, i64 } %10 
          161: } 
            .
            .
            .
>>>>>>

------------------------------------------

error: verification with 'FileCheck' failed
status: exit status: 1
command: "/usr/lib/llvm-20/bin/FileCheck" "--input-file" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/codegen-llvm/issues/issue-111603/issue-111603.ll" "/checkout/tests/codegen-llvm/issues/issue-111603.rs" "--check-prefix=CHECK" "--allow-unused-prefixes" "--dump-input-context" "100"
stdout: none
--- stderr -------------------------------
/checkout/tests/codegen-llvm/issues/issue-111603.rs:23:12: error: CHECK: expected string not found in input
 // CHECK: call alloc::sync::arcinner_layout_for_value_layout
           ^
/checkout/obj/build/aarch64-unknown-linux-gnu/test/codegen-llvm/issues/issue-111603/issue-111603.ll:50:47: note: scanning from here
define noalias noundef nonnull ptr @new_uninit(i64 noundef %x) unnamed_addr #0 personality ptr @rust_eh_personality {
                                              ^
/checkout/obj/build/aarch64-unknown-linux-gnu/test/codegen-llvm/issues/issue-111603/issue-111603.ll:61:3: note: possible intended match here
; call alloc::alloc::handle_alloc_error
  ^

Input file: /checkout/obj/build/aarch64-unknown-linux-gnu/test/codegen-llvm/issues/issue-111603/issue-111603.ll
Check file: /checkout/tests/codegen-llvm/issues/issue-111603.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ; ModuleID = 'issue_111603.8eafb1a0a540be9f-cgu.0' 
            2: source_filename = "issue_111603.8eafb1a0a540be9f-cgu.0" 
            3: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32" 
            4: target triple = "aarch64-unknown-linux-gnu" 
            5:  
            6: @alloc_ac1493a8bf84bc8bab0d3f1c9c85d5c4 = private unnamed_addr constant [45 x i8] c"/rustc/FAKE_PREFIX/library/alloc/src/sync.rs\00", align 1 
            7: @alloc_e4f66ebc6994e60894cebfdce794d51f = private unnamed_addr constant <{ [8 x i8], ptr, [8 x i8] }> <{ [8 x i8] c"m\08\00\00\09\00\00\00", ptr @alloc_ac1493a8bf84bc8bab0d3f1c9c85d5c4, [8 x i8] c",\00\00\00\00\00\00\00" }>, align 8 
            8:  
            9: ; Function Attrs: uwtable 
           10: define { ptr, i64 } @new_from_array(i64 noundef %x) unnamed_addr #0 personality ptr @rust_eh_personality { 
           11: start: 
           12:  %array = alloca [8000 x i8], align 8 
           13:  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %x, i64 0 
           14:  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer 
           15:  br label %vector.body 
           16:  
           17: vector.body: ; preds = %vector.body, %start 
           18:  %index = phi i64 [ 0, %start ], [ %index.next, %vector.body ] 
           19:  %0 = getelementptr inbounds nuw i64, ptr %array, i64 %index 
           20:  %1 = getelementptr inbounds nuw i8, ptr %0, i64 16 
           21:  store <2 x i64> %broadcast.splat, ptr %0, align 8 
           22:  store <2 x i64> %broadcast.splat, ptr %1, align 8 
           23:  %index.next = add nuw i64 %index, 4 
           24:  %2 = icmp eq i64 %index.next, 1000 
           25:  br i1 %2, label %repeat_loop_next, label %vector.body, !llvm.loop !2 
           26:  
           27: repeat_loop_next: ; preds = %vector.body 
           28: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 
           29:  tail call void @_RNvCs3LcVZ4W5lqF_7___rustc35___rust_no_alloc_shim_is_unstable_v2() #7, !noalias !5 
           30: ; call __rustc::__rust_alloc 
           31:  %3 = tail call noalias noundef align 8 dereferenceable_or_null(8016) ptr @_RNvCs3LcVZ4W5lqF_7___rustc12___rust_alloc(i64 noundef 8016, i64 noundef 8) #7, !noalias !5 
           32:  %4 = icmp eq ptr %3, null 
           33:  br i1 %4, label %bb3.i.i, label %_RNvMse_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcAyj3e8_E3newCscfvYVcvsPgx_12issue_111603.exit, !prof !8 
           34:  
           35: bb3.i.i: ; preds = %repeat_loop_next 
           36: ; call alloc::alloc::handle_alloc_error 
           37:  tail call void @_RNvNtCs3eZPr1ZwVuP_5alloc5alloc18handle_alloc_error(i64 noundef 8, i64 noundef 8016) #8, !noalias !5 
           38:  unreachable 
           39:  
           40: _RNvMse_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcAyj3e8_E3newCscfvYVcvsPgx_12issue_111603.exit: ; preds = %repeat_loop_next 
           41:  store <2 x i64> splat (i64 1), ptr %3, align 8, !alias.scope !9, !noalias !5 
           42:  %5 = getelementptr inbounds nuw i8, ptr %3, i64 16 
           43:  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(8000) %5, ptr noundef nonnull readonly align 8 dereferenceable(8000) %array, i64 8000, i1 false) 
           44:  %6 = insertvalue { ptr, i64 } poison, ptr %3, 0 
           45:  %7 = insertvalue { ptr, i64 } %6, i64 1000, 1 
           46:  ret { ptr, i64 } %7 
           47: } 
           48:  
           49: ; Function Attrs: uwtable 
           50: define noalias noundef nonnull ptr @new_uninit(i64 noundef %x) unnamed_addr #0 personality ptr @rust_eh_personality { 
check:23'0                                                   X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
           51: start: 
check:23'0     ~~~~~~~
           52:  %_3 = alloca [8000 x i8], align 8 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           53: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           54:  tail call void @_RNvCs3LcVZ4W5lqF_7___rustc35___rust_no_alloc_shim_is_unstable_v2() #7 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           55: ; call __rustc::__rust_alloc 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           56:  %0 = tail call noalias noundef align 8 dereferenceable_or_null(8016) ptr @_RNvCs3LcVZ4W5lqF_7___rustc12___rust_alloc(i64 noundef 8016, i64 noundef 8) #7 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           57:  %1 = icmp eq ptr %0, null 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
           58:  br i1 %1, label %bb3.i, label %_RNvMs_NtCs3eZPr1ZwVuP_5alloc5boxedINtB4_3BoxINtNtB6_4sync8ArcInnerAyj3e8_EE13new_uninit_inCscfvYVcvsPgx_12issue_111603.exit, !prof !8 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           59:  
check:23'0     ~
           60: bb3.i: ; preds = %start 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~
           61: ; call alloc::alloc::handle_alloc_error 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:23'1       ?                                      possible intended match
           62:  tail call void @_RNvNtCs3eZPr1ZwVuP_5alloc5alloc18handle_alloc_error(i64 noundef 8, i64 noundef 8016) #8 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           63:  unreachable 
check:23'0     ~~~~~~~~~~~~~
           64:  
check:23'0     ~
           65: _RNvMs_NtCs3eZPr1ZwVuP_5alloc5boxedINtB4_3BoxINtNtB6_4sync8ArcInnerAyj3e8_EE13new_uninit_inCscfvYVcvsPgx_12issue_111603.exit: ; preds = %start 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           66:  store <2 x i64> splat (i64 1), ptr %0, align 8, !alias.scope !12 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           67:  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %x, i64 0 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           68:  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           69:  br label %vector.body 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~
           70:  
check:23'0     ~
           71: vector.body: ; preds = %vector.body, %_RNvMs_NtCs3eZPr1ZwVuP_5alloc5boxedINtB4_3BoxINtNtB6_4sync8ArcInnerAyj3e8_EE13new_uninit_inCscfvYVcvsPgx_12issue_111603.exit 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           72:  %index = phi i64 [ 0, %_RNvMs_NtCs3eZPr1ZwVuP_5alloc5boxedINtB4_3BoxINtNtB6_4sync8ArcInnerAyj3e8_EE13new_uninit_inCscfvYVcvsPgx_12issue_111603.exit ], [ %index.next, %vector.body ] 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           73:  %2 = getelementptr inbounds nuw i64, ptr %_3, i64 %index 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           74:  %3 = getelementptr inbounds nuw i8, ptr %2, i64 16 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           75:  store <2 x i64> %broadcast.splat, ptr %2, align 8 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           76:  store <2 x i64> %broadcast.splat, ptr %3, align 8 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           77:  %index.next = add nuw i64 %index, 4 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           78:  %4 = icmp eq i64 %index.next, 1000 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           79:  br i1 %4, label %repeat_loop_next, label %vector.body, !llvm.loop !15 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           80:  
check:23'0     ~
           81: repeat_loop_next: ; preds = %vector.body 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           82:  %5 = getelementptr inbounds nuw i8, ptr %0, i64 16 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           83:  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(8000) %5, ptr noundef nonnull align 8 dereferenceable(8000) %_3, i64 8000, i1 false) 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           84:  ret ptr %0 
check:23'0     ~~~~~~~~~~~~
           85: } 
check:23'0     ~~
           86:  
check:23'0     ~
           87: ; Function Attrs: uwtable 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~
           88: define { ptr, i64 } @new_uninit_slice(i64 noundef %x) unnamed_addr #0 personality ptr @rust_eh_personality { 
check:23'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           89: start: 
           90:  %_8.i.i.i = alloca [16 x i8], align 16 
           91:  %layout.i.i.i = alloca [16 x i8], align 8 
           92: ; call alloc::sync::arcinner_layout_for_value_layout 
           93:  %0 = tail call { i64, i64 } @_RNvNtCs3eZPr1ZwVuP_5alloc4sync32arcinner_layout_for_value_layout(i64 noundef 8, i64 noundef 8000) 
           94:  %layout.0.i.i = extractvalue { i64, i64 } %0, 0 
           95:  %layout.1.i.i = extractvalue { i64, i64 } %0, 1 
           96:  %1 = icmp eq i64 %layout.1.i.i, 0 
           97:  br i1 %1, label %bb2.i.i.i.i, label %bb4.i.i.i.i 
           98:  
           99: bb2.i.i.i.i: ; preds = %start 
          100:  %_15.i.i.i.i = inttoptr i64 %layout.0.i.i to ptr 
          101:  br label %_RNCNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB7_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_slice0CscfvYVcvsPgx_12issue_111603.exit.i.i 
          102:  
          103: bb4.i.i.i.i: ; preds = %start 
          104: ; call __rustc::__rust_no_alloc_shim_is_unstable_v2 
          105:  tail call void @_RNvCs3LcVZ4W5lqF_7___rustc35___rust_no_alloc_shim_is_unstable_v2() #7 
          106: ; call __rustc::__rust_alloc 
          107:  %2 = tail call noundef ptr @_RNvCs3LcVZ4W5lqF_7___rustc12___rust_alloc(i64 noundef %layout.1.i.i, i64 noundef range(i64 1, -9223372036854775807) %layout.0.i.i) #7 
          108:  br label %_RNCNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB7_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_slice0CscfvYVcvsPgx_12issue_111603.exit.i.i 
          109:  
          110: _RNCNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB7_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_slice0CscfvYVcvsPgx_12issue_111603.exit.i.i: ; preds = %bb4.i.i.i.i, %bb2.i.i.i.i 
          111:  %_0.sroa.0.0.i.i.i.i = phi ptr [ %_15.i.i.i.i, %bb2.i.i.i.i ], [ %2, %bb4.i.i.i.i ] 
          112:  %3 = icmp eq ptr %_0.sroa.0.0.i.i.i.i, null 
          113:  br i1 %3, label %bb10.i.i, label %bb11.i.i, !prof !8 
          114:  
          115: bb10.i.i: ; preds = %_RNCNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB7_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_slice0CscfvYVcvsPgx_12issue_111603.exit.i.i 
          116: ; call alloc::alloc::handle_alloc_error 
          117:  tail call void @_RNvNtCs3eZPr1ZwVuP_5alloc5alloc18handle_alloc_error(i64 noundef %layout.0.i.i, i64 noundef %layout.1.i.i) #8 
          118:  unreachable 
          119:  
          120: bb11.i.i: ; preds = %_RNCNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB7_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_slice0CscfvYVcvsPgx_12issue_111603.exit.i.i 
          121:  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %layout.i.i.i) 
          122:  store i64 %layout.0.i.i, ptr %layout.i.i.i, align 8 
          123:  %4 = getelementptr inbounds nuw i8, ptr %layout.i.i.i, i64 8 
          124:  store i64 %layout.1.i.i, ptr %4, align 8 
          125:  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %_8.i.i.i) 
          126:  store <2 x i64> <i64 8, i64 8016>, ptr %_8.i.i.i, align 16 
          127:  %_21.i.i.i = icmp eq i64 %layout.1.i.i, 8016 
          128:  %_11.i.i.i = icmp eq i64 %layout.0.i.i, 8 
          129:  %or.cond.i.i.i = and i1 %_11.i.i.i, %_21.i.i.i 
          130:  br i1 %or.cond.i.i.i, label %_RNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_sliceCscfvYVcvsPgx_12issue_111603.exit, label %bb3.i.i.i, !prof !16 
          131:  
          132: bb3.i.i.i: ; preds = %bb11.i.i 
          133: ; call core::panicking::assert_failed::<core::alloc::layout::Layout, core::alloc::layout::Layout> 
          134:  call void @_RINvNtCs2Lwqn61Hkzc_4core9panicking13assert_failedNtNtNtB4_5alloc6layout6LayoutBM_ECs3eZPr1ZwVuP_5alloc(i8 noundef 0, ptr noalias noundef nonnull readonly align 8 dereferenceable(16) %_8.i.i.i, ptr noalias noundef nonnull readonly align 8 dereferenceable(16) %layout.i.i.i, ptr noundef null, ptr undef, ptr noalias noundef nonnull readonly align 8 dereferenceable(24) @alloc_e4f66ebc6994e60894cebfdce794d51f) #9 
          135:  unreachable 
          136:  
          137: _RNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_sliceCscfvYVcvsPgx_12issue_111603.exit: ; preds = %bb11.i.i 
          138:  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %_8.i.i.i) 
          139:  store <2 x i64> splat (i64 1), ptr %_0.sroa.0.0.i.i.i.i, align 8 
          140:  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %layout.i.i.i) 
          141:  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %x, i64 0 
          142:  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer 
          143:  br label %vector.body 
          144:  
          145: vector.body: ; preds = %vector.body, %_RNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_sliceCscfvYVcvsPgx_12issue_111603.exit 
          146:  %index = phi i64 [ 0, %_RNvMsq_NtCs3eZPr1ZwVuP_5alloc4syncINtB5_3ArcSINtNtNtCs2Lwqn61Hkzc_4core3mem12maybe_uninit11MaybeUninityEE18allocate_for_sliceCscfvYVcvsPgx_12issue_111603.exit ], [ %index.next, %vector.body ] 
          147:  %5 = shl i64 %index, 3 
          148:  %offset.idx = or disjoint i64 %5, 16 
          149:  %6 = getelementptr inbounds nuw i8, ptr %_0.sroa.0.0.i.i.i.i, i64 %offset.idx 
          150:  %7 = getelementptr inbounds nuw i8, ptr %6, i64 16 
          151:  store <2 x i64> %broadcast.splat, ptr %6, align 8 
          152:  store <2 x i64> %broadcast.splat, ptr %7, align 8 
          153:  %index.next = add nuw i64 %index, 4 
          154:  %8 = icmp eq i64 %index.next, 1000 
          155:  br i1 %8, label %bb3, label %vector.body, !llvm.loop !17 
          156:  
          157: bb3: ; preds = %vector.body 
          158:  %9 = insertvalue { ptr, i64 } poison, ptr %_0.sroa.0.0.i.i.i.i, 0 
          159:  %10 = insertvalue { ptr, i64 } %9, i64 1000, 1 
          160:  ret { ptr, i64 } %10 
          161: } 
            .
            .
            .
>>>>>>
------------------------------------------

@scottmcm
Copy link
Member

This would require making the {Rc,Arc}Inner types public

Note that this is an opposite direction from #132553 where those types disappear in favour of using a layout that's not expressible in a rust type today so that the counts are always at a consistent offset from the data so that type erasure can work better.

@alexcrichton
Copy link
Member Author

Thanks for linking that! I wasn't previously aware of that, and yeah that would pretty much sink this endeavor. My understanding from reading through the various threads there is that there's no opposition beyond review bandwidth and scale of change there, in the sense that it's likely to happen. If that's true it's probably not worth landing this in the meantime as it would cause unnecessary churn.

Assuming others agree I'd still like to land the refactor of new-style constructors where they allocate a MaybeUninit first, then initialize, then assume_init. That would help decouple the allocation there and provide one less place to update in the future with various allocation changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants