Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nightmarish hacks within] Lower UB checks as a new kind of intrinsic, not calls #121767

Closed
wants to merge 2 commits into from

Conversation

saethlin
Copy link
Member

I think one reason the UB checks have the compile time overhead that they do is that they impede MIR optimizations by being calls, which are penalized heavily in MIR inlining, and also simply complicate the MIR we generate.

So this is my (ongoing) effort to fix that. Currently the code is strewn with terrible hacks that I'll figure out how to do better later. Right now I just want to establish if this is a path to reducing their compile-time overhead.

r? @ghost

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 28, 2024
@saethlin saethlin changed the title [nightmarish hacks within] Lower library UB checks as a new kind of intrinsic, not calls [nightmarish hacks within] Lower UB checks as a new kind of intrinsic, not calls Feb 28, 2024
@saethlin saethlin removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 28, 2024
@saethlin
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 28, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 28, 2024
[nightmarish hacks within] Lower UB checks as a new kind of intrinsic, not calls

I _think_ one reason the UB checks have the compile time overhead that they do is that they impede MIR optimizations by being calls, which are penalized heavily in MIR inlining, and also simply complicate the MIR we generate.

So this is my (ongoing) effort to fix that. Currently the code is strewn with terrible hacks that I'll figure out how to do better later. Right now I just want to establish if this is a path to reducing their compile-time overhead.

r? `@ghost`
@bors
Copy link
Contributor

bors commented Feb 28, 2024

⌛ Trying commit 9ae476b with merge 9f42d34...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-16 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#12 writing image sha256:f3a4bf98c643c322f96ea804399308dc5f7dc405a396b41360f7f1a6ca313b94 done
#12 naming to docker.io/library/rust-ci done
#12 DONE 10.1s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-16]
##[group]Clock drift check
  local time: Wed Feb 28 22:36:05 UTC 2024
  network time: Wed, 28 Feb 2024 22:36:05 GMT
  network time: Wed, 28 Feb 2024 22:36:05 GMT
##[endgroup]
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-16', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'build.optimized-compiler-builtins', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-16/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.thin-lto-import-instr-limit := 10
configure: change-id            := 99999999
---
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: rustc_codegen_cranelift::base::codegen_fn_body
   4: rustc_codegen_cranelift::base::codegen_fn
   5: rustc_codegen_cranelift::driver::aot::module_codegen
   6: <core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::slice::iter::Iter<rustc_middle::mir::mono::CodegenUnit>>, rustc_codegen_cranelift::driver::aot::run_aot::{closure#2}::{closure#0}> as core::iter::traits::iterator::Iterator>::fold::<(), core::iter::traits::iterator::Iterator::for_each::call<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen, <alloc::vec::Vec<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen>>::extend_trusted<core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::slice::iter::Iter<rustc_middle::mir::mono::CodegenUnit>>, rustc_codegen_cranelift::driver::aot::run_aot::{closure#2}::{closure#0}>>::{closure#0}>::{closure#0}>
   7: <alloc::vec::Vec<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen> as alloc::vec::spec_from_iter::SpecFromIter<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen, core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::slice::iter::Iter<rustc_middle::mir::mono::CodegenUnit>>, rustc_codegen_cranelift::driver::aot::run_aot::{closure#2}::{closure#0}>>>::from_iter
   8: <rustc_session::session::Session>::time::<alloc::vec::Vec<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen>, rustc_codegen_cranelift::driver::aot::run_aot::{closure#2}>
   9: rustc_codegen_cranelift::driver::aot::run_aot
  10: <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  11: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  13: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::codegen_and_build_linker::{closure#0}, core::result::Result<rustc_interface::queries::Linker, rustc_span::ErrorGuaranteed>>
  14: <rustc_interface::queries::Queries>::codegen_and_build_linker
  15: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  16: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}::{closure#0}>
  16: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

warning: the ICE couldn't be written to `/checkout/compiler/rustc_codegen_cranelift/rustc-ice-2024-02-28T22_50_50-149912.txt`: Read-only file system (os error 30)
note: rustc 1.78.0-nightly (4aaaaf20f 2024-02-28) running on x86_64-unknown-linux-gnu


note: compiler flags: -C panic=abort -Z panic-abort-tests -Z codegen-backend=cranelift -C symbol-mangling-version=v0 -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C llvm-args=-import-instr-limit=10 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -C debuginfo=2 -C panic=abort -Z unstable-options -Z force-unstable-if-unmarked
query stack during panic:
end of query stack
end of query stack
stmt UbCheck(LanguageUb): NonNull::<T>::new_unchecked::precondition_check(move _26)
fn std::alloc::Global::alloc_impl(_1: &std::alloc::Global, _2: std::alloc::Layout, _3: bool) -> std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError> {
    debug self => _1;
    debug layout => _2;
    debug zeroed => _3;
    let mut _0: std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>;
    let mut _4: usize;
    let mut _5: &std::alloc::Layout;
    let mut _6: std::ptr::NonNull<[u8]>;
    let mut _7: std::ptr::NonNull<u8>;
    let mut _8: &std::alloc::Layout;
    let mut _10: std::alloc::Layout;
    let mut _11: std::alloc::Layout;
    let mut _12: std::ops::ControlFlow<std::result::Result<std::convert::Infallible, std::alloc::AllocError>, std::ptr::NonNull<u8>>;
    let mut _13: std::result::Result<std::ptr::NonNull<u8>, std::alloc::AllocError>;
    let mut _14: std::option::Option<std::ptr::NonNull<u8>>;
    let mut _15: *mut u8;
    let mut _17: std::ptr::NonNull<[u8]>;
    scope 1 {
        debug size => _4;
        scope 2 {
            let _9: *mut u8;
            scope 3 {
                debug raw_ptr => _9;
                let _16: std::ptr::NonNull<u8>;
                scope 4 {
                    debug ptr => _16;
                    scope 55 (inlined std::ptr::NonNull::<[u8]>::slice_from_raw_parts) {
                        debug data => _16;
                        debug len => _4;
                        let mut _68: *mut [u8];
                        let mut _69: *mut u8;
                        scope 56 {
                            scope 57 (inlined std::ptr::NonNull::<u8>::as_ptr) {
                                debug self => _16;
                                let mut _70: *const u8;
                            }
                            scope 58 (inlined std::ptr::slice_from_raw_parts_mut::<u8>) {
                                debug data => _69;
                                debug len => _4;
                                let mut _71: *mut ();
                                scope 59 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
                                    debug self => _69;
                                }
                                scope 60 (inlined std::ptr::from_raw_parts_mut::<[u8]>) {
                                    debug data_pointer => _71;
                                    debug metadata => _4;
                                    let mut _72: std::ptr::metadata::PtrRepr<[u8]>;
                                    let mut _73: std::ptr::metadata::PtrComponents<[u8]>;
                                    let mut _74: *const ();
                                    scope 61 {
                                }
                            }
                            }
                            scope 62 (inlined std::ptr::NonNull::<[u8]>::new_unchecked) {
                                debug ptr => _68;
                                let mut _75: (*mut (),);
                                let mut _76: *mut ();
                                let mut _77: *const [u8];
                                scope 63 {
                            }
                        }
                    }
                }
                }
                scope 5 {
                    debug residual => const std::result::Result::<std::convert::Infallible, std::alloc::AllocError>::Err(std::alloc::AllocError);
                    scope 6 {
                        scope 64 (inlined #[track_caller] <std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError> as std::ops::FromResidual<std::result::Result<std::convert::Infallible, std::alloc::AllocError>>>::from_residual) {
                            debug residual => const std::result::Result::<std::convert::Infallible, std::alloc::AllocError>::Err(std::alloc::AllocError);
                            scope 65 {
                                debug e => const std::alloc::AllocError;
                                scope 66 (inlined <std::alloc::AllocError as std::convert::From<std::alloc::AllocError>>::from) {
                                    debug t => const std::alloc::AllocError;
                            }
                        }
                    }
                }
                }
                scope 7 {
                    debug val => _16;
                    scope 8 {
                    }
                }
                scope 40 (inlined std::ptr::NonNull::<u8>::new) {
                    debug ptr => _15;
                    let mut _61: std::ptr::NonNull<u8>;
                    scope 41 {
                        scope 48 (inlined std::ptr::NonNull::<u8>::new_unchecked) {
                            debug ptr => _15;
                            let mut _64: (*mut (),);
                            let mut _65: *const u8;
                            scope 49 {
                        }
                    }
                    }
                    scope 42 (inlined std::ptr::mut_ptr::<impl *mut u8>::is_null) {
                        debug self => _15;
                        scope 43 {
                            scope 44 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) {
                                debug ptr => _15;
                                let mut _62: usize;
                                scope 45 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) {
                                    debug self => _15;
                                    let mut _63: *mut ();
                                    scope 46 {
                                        scope 47 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
                                            debug self => _15;
                                    }
                                }
                            }
                        }
                        }
                    }
                }
                scope 50 (inlined std::option::Option::<std::ptr::NonNull<u8>>::ok_or::<std::alloc::AllocError>) {
                    debug self => _14;
                    debug err => const std::alloc::AllocError;
                    let _66: std::ptr::NonNull<u8>;
                    scope 51 {
                        debug v => _66;
                }
                }
                scope 52 (inlined <std::result::Result<std::ptr::NonNull<u8>, std::alloc::AllocError> as std::ops::Try>::branch) {
                    debug self => _13;
                    let _67: std::ptr::NonNull<u8>;
                    scope 53 {
                        debug v => _67;
                    scope 54 {
                    scope 54 {
                        debug e => const std::alloc::AllocError;
                }
            }
            }
            scope 27 (inlined std::alloc::alloc_zeroed) {
                debug layout => _10;
                let mut _36: usize;
                let mut _37: &std::alloc::Layout;
                let mut _38: usize;
                let mut _39: &std::alloc::Layout;
                scope 28 {
                    scope 29 (inlined std::alloc::Layout::size) {
                        debug self => _37;
                    }
                    scope 30 (inlined std::alloc::Layout::align) {
                        debug self => _39;
                        let mut _40: std::ptr::Alignment;
                        scope 31 (inlined std::ptr::Alignment::as_usize) {
                            debug self => _40;
                            let _41: std::ptr::alignment::AlignmentEnum64;
                            let mut _42: u64;
                            let mut _43: bool;
                            let mut _44: bool;
                            let mut _45: bool;
                    }
                }
            }
            }
            scope 32 (inlined std::alloc::alloc) {
                debug layout => _11;
                let _46: u8;
                let mut _47: *const u8;
                let _48: *const u8;
                let mut _49: usize;
                let mut _50: &std::alloc::Layout;
                let mut _51: usize;
                let mut _52: &std::alloc::Layout;
                scope 33 {
                    scope 34 (inlined std::ptr::read_volatile::<u8>) {
                        debug src => const {alloc10: *const u8};
                        let mut _53: (*const (), usize);
                        let mut _54: *const ();
                        scope 35 {
                            scope 36 (inlined std::mem::align_of::<u8>) {
                        }
                    }
                    }
                    scope 37 (inlined std::alloc::Layout::size) {
                        debug self => _50;
                    }
                    scope 38 (inlined std::alloc::Layout::align) {
                        debug self => _52;
                        let mut _55: std::ptr::Alignment;
                        scope 39 (inlined std::ptr::Alignment::as_usize) {
                            debug self => _55;
                            let _56: std::ptr::alignment::AlignmentEnum64;
                            let mut _57: u64;
                            let mut _58: bool;
                            let mut _59: bool;
                            let mut _60: bool;
                    }
                }
            }
        }
        }
    }
    scope 9 (inlined std::alloc::Layout::size) {
        debug self => _5;
    }
    scope 10 (inlined std::alloc::Layout::dangling) {
        debug self => _8;
        let mut _18: *mut u8;
        let mut _19: usize;
        scope 11 {
            scope 12 (inlined std::alloc::Layout::align) {
                debug self => _8;
                let mut _20: std::ptr::Alignment;
                scope 13 (inlined std::ptr::Alignment::as_usize) {
                    debug self => _20;
                    let _21: std::ptr::alignment::AlignmentEnum64;
                    let mut _22: u64;
                    let mut _23: bool;
                    let mut _24: bool;
                    let mut _25: bool;
            }
            }
            scope 14 (inlined std::ptr::without_provenance_mut::<u8>) {
                debug addr => _19;
                scope 15 {
            }
            }
            scope 16 (inlined std::ptr::NonNull::<u8>::new_unchecked) {
                debug ptr => _18;
                let mut _26: (*mut (),);
                let mut _27: *mut ();
                let mut _28: *const u8;
                scope 17 {
            }
        }
    }
    }
    scope 18 (inlined std::ptr::NonNull::<[u8]>::slice_from_raw_parts) {
        debug data => _7;
        debug len => const 0_usize;
        let mut _29: *mut [u8];
        scope 19 {
            scope 20 (inlined std::ptr::NonNull::<u8>::as_ptr) {
                debug self => _7;
            }
            scope 21 (inlined std::ptr::slice_from_raw_parts_mut::<u8>) {
                debug data => _18;
                debug len => const 0_usize;
                scope 22 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) {
                    debug self => _18;
                }
                scope 23 (inlined std::ptr::from_raw_parts_mut::<[u8]>) {
                    debug data_pointer => _27;
                    debug metadata => const 0_usize;
                    let mut _30: std::ptr::metadata::PtrRepr<[u8]>;
                    let mut _31: std::ptr::metadata::PtrComponents<[u8]>;
                    let mut _32: *const ();
                    scope 24 {
                }
            }
            }
            scope 25 (inlined std::ptr::NonNull::<[u8]>::new_unchecked) {
                debug ptr => _29;
                let mut _33: (*mut (),);
                let mut _34: *mut ();
                let mut _35: *const [u8];
                scope 26 {
            }
        }
    }


    bb0: {
        StorageLive(_5);
        _5 = &_2;
        _4 = (_2.0: usize);
        StorageDead(_5);
        switchInt(_4) -> [0: bb2, otherwise: bb1];

    bb1: {
        StorageLive(_9);
        StorageLive(_9);
        switchInt(_3) -> [0: bb4, otherwise: bb3];

    bb2: {
        StorageLive(_6);
        StorageLive(_7);
        StorageLive(_7);
        StorageLive(_8);
        _8 = &_2;
        StorageLive(_19);
        StorageLive(_20);
        _20 = (_2.1: std::ptr::Alignment);
        StorageLive(_22);
        StorageLive(_23);
        StorageLive(_24);
        StorageLive(_25);
        StorageLive(_21);
        _21 = (_20.0: std::ptr::alignment::AlignmentEnum64);
        _22 = discriminant(_21);
        _23 = Ge(_22, const 1_u64);
        _24 = Le(_22, const 9223372036854775808_u64);
        _25 = BitAnd(move _23, move _24);
        assume(move _25);
        _19 = _22 as usize (IntToInt);
        StorageDead(_21);
        StorageDead(_25);
        StorageDead(_24);
        StorageDead(_23);
        StorageDead(_22);
        StorageDead(_20);
        _18 = _19 as *mut u8 (Transmute);
        StorageDead(_19);
        StorageLive(_26);
        _27 = _18 as *mut () (PtrToPtr);
        _26 = (_27,);
        UbCheck(LanguageUb): std::ptr::NonNull::<T>::new_unchecked::precondition_check(move _26);
        StorageDead(_26);
        _28 = _18 as *const u8 (PointerCoercion(MutToConstPointer));
        _7 = std::ptr::NonNull::<u8> { pointer: _28 };
        StorageDead(_8);
        StorageLive(_29);
        StorageLive(_30);
        StorageLive(_31);
        StorageLive(_32);
        _32 = _18 as *const () (PtrToPtr);
        _31 = std::ptr::metadata::PtrComponents::<[u8]> { data_pointer: move _32, metadata: const 0_usize };
        StorageDead(_32);
        _30 = std::ptr::metadata::PtrRepr::<[u8]> { const_ptr: move _31 };
        StorageDead(_31);
        _29 = (_30.1: *mut [u8]);
        StorageDead(_30);
        StorageLive(_35);
        StorageLive(_33);
        StorageLive(_34);
        _34 = _29 as *mut () (PtrToPtr);
        _33 = (move _34,);
        StorageDead(_34);
        UbCheck(LanguageUb): std::ptr::NonNull::<T>::new_unchecked::precondition_check(move _33);
        StorageDead(_33);
        _35 = _29 as *const [u8] (PointerCoercion(MutToConstPointer));
        _6 = std::ptr::NonNull::<[u8]> { pointer: _35 };
        StorageDead(_35);
        StorageDead(_29);
        StorageDead(_7);
        _0 = std::result::Result::<std::ptr::NonNull<[u8]>, std::alloc::AllocError>::Ok(move _6);
        StorageDead(_6);
        goto -> bb6;

    bb3: {
        StorageLive(_10);
        _10 = _2;
        _10 = _2;
        StorageLive(_36);
        StorageLive(_37);
        _37 = &_10;
        _36 = (_10.0: usize);
        StorageDead(_37);
        StorageLive(_38);
        StorageLive(_39);
        _39 = &_10;
        StorageLive(_40);
        _40 = (_10.1: std::ptr::Alignment);
        StorageLive(_42);
        StorageLive(_43);
        StorageLive(_44);
        StorageLive(_45);
        StorageLive(_41);
        _41 = (_40.0: std::ptr::alignment::AlignmentEnum64);
        _42 = discriminant(_41);
        _43 = Ge(_42, const 1_u64);
        _44 = Le(_42, const 9223372036854775808_u64);
        _45 = BitAnd(move _43, move _44);
        assume(move _45);
        _38 = _42 as usize (IntToInt);
        StorageDead(_41);
        StorageDead(_45);
        StorageDead(_44);
        StorageDead(_43);
        StorageDead(_42);
        StorageDead(_40);
        StorageDead(_39);
        _9 = alloc::alloc::__rust_alloc_zeroed(move _36, move _38) -> [return: bb7, unwind unreachable];

    bb4: {
        StorageLive(_11);
        _11 = _2;
        _11 = _2;
        StorageLive(_48);
        StorageLive(_46);
        StorageLive(_47);
        _48 = const {alloc10: *const u8};
        _47 = &raw const (*_48);
        StorageLive(_53);
        StorageLive(_54);
        _54 = _47 as *const () (PtrToPtr);
        _53 = (move _54, const 1_usize);
        StorageDead(_54);
        UbCheck(LanguageUb): std::ptr::read_volatile::precondition_check(move _53);
        StorageDead(_53);
        _46 = std::intrinsics::volatile_load::<u8>(move _47) -> [return: bb9, unwind unreachable];

    bb5: {
        StorageLive(_12);
        StorageLive(_13);
        StorageLive(_13);
        StorageLive(_14);
        _15 = _9;
        StorageLive(_63);
        StorageLive(_62);
        _63 = _15 as *mut () (PtrToPtr);
        _62 = _63 as usize (Transmute);
        switchInt(move _62) -> [0: bb10, otherwise: bb11];

    bb6: {
        return;
    }
---
        StorageDead(_11);
        goto -> bb5;
    }

    bb9: {
        StorageDead(_47);
        StorageDead(_46);
        StorageLive(_49);
        StorageLive(_50);
        _50 = &_11;
        _49 = (_11.0: usize);
        StorageDead(_50);
        StorageLive(_51);
        StorageLive(_52);
        _52 = &_11;
        StorageLive(_55);
        _55 = (_11.1: std::ptr::Alignment);
        StorageLive(_57);
        StorageLive(_58);
        StorageLive(_59);
        StorageLive(_60);
        StorageLive(_56);
        _56 = (_55.0: std::ptr::alignment::AlignmentEnum64);
        _57 = discriminant(_56);
        _58 = Ge(_57, const 1_u64);
        _59 = Le(_57, const 9223372036854775808_u64);
        _60 = BitAnd(move _58, move _59);
        assume(move _60);
        _51 = _57 as usize (IntToInt);
        StorageDead(_56);
        StorageDead(_60);
        StorageDead(_59);
        StorageDead(_58);
        StorageDead(_57);
        StorageDead(_55);
        StorageDead(_52);
        _9 = alloc::alloc::__rust_alloc(move _49, move _51) -> [return: bb8, unwind unreachable];

    bb10: {
        StorageDead(_62);
        StorageDead(_62);
        _14 = const std::option::Option::<std::ptr::NonNull<u8>>::None;
        StorageDead(_63);
        StorageLive(_66);
        _13 = const std::result::Result::<std::ptr::NonNull<u8>, std::alloc::AllocError>::Err(std::alloc::AllocError);
        StorageDead(_66);
        StorageDead(_14);
        StorageLive(_67);
        StorageDead(_67);
        StorageDead(_13);
        _0 = const std::result::Result::<std::ptr::NonNull<[u8]>, std::alloc::AllocError>::Err(std::alloc::AllocError);
        StorageDead(_12);
        StorageDead(_9);
        goto -> bb6;

    bb11: {
        StorageDead(_62);
        StorageLive(_61);
        StorageLive(_61);
        StorageLive(_65);
        StorageLive(_64);
        _64 = (_63,);
        UbCheck(LanguageUb): std::ptr::NonNull::<T>::new_unchecked::precondition_check(move _64);
        StorageDead(_64);
        _65 = _15 as *const u8 (PointerCoercion(MutToConstPointer));
        _61 = std::ptr::NonNull::<u8> { pointer: _65 };
        StorageDead(_65);
        _14 = std::option::Option::<std::ptr::NonNull<u8>>::Some(move _61);
        StorageDead(_61);
        StorageDead(_63);
        StorageLive(_66);
        _66 = move ((_14 as Some).0: std::ptr::NonNull<u8>);
        _13 = std::result::Result::<std::ptr::NonNull<u8>, std::alloc::AllocError>::Ok(_66);
        StorageDead(_66);
        StorageDead(_14);
        StorageLive(_67);
        _67 = move ((_13 as Ok).0: std::ptr::NonNull<u8>);
        _12 = std::ops::ControlFlow::<std::result::Result<std::convert::Infallible, std::alloc::AllocError>, std::ptr::NonNull<u8>>::Continue(_67);
        StorageDead(_67);
        StorageDead(_13);
        _16 = ((_12 as Continue).0: std::ptr::NonNull<u8>);
        StorageDead(_12);
        StorageLive(_17);
        StorageLive(_70);
        StorageLive(_68);
        StorageLive(_69);
        _70 = (_16.0: *const u8);
        _69 = _70 as *mut u8 (PtrToPtr);
        StorageLive(_71);
        _71 = _70 as *mut () (PtrToPtr);
        StorageLive(_72);
        StorageLive(_73);
        StorageLive(_74);
        _74 = _70 as *const () (PtrToPtr);
        _73 = std::ptr::metadata::PtrComponents::<[u8]> { data_pointer: move _74, metadata: _4 };
        StorageDead(_74);
        _72 = std::ptr::metadata::PtrRepr::<[u8]> { const_ptr: move _73 };
        StorageDead(_73);
        _68 = (_72.1: *mut [u8]);
        StorageDead(_72);
        StorageDead(_71);
        StorageDead(_69);
        StorageLive(_77);
        StorageLive(_75);
        StorageLive(_76);
        _76 = _68 as *mut () (PtrToPtr);
        _75 = (move _76,);
        StorageDead(_76);
        UbCheck(LanguageUb): std::ptr::NonNull::<T>::new_unchecked::precondition_check(move _75);
        StorageDead(_75);
        _77 = _68 as *const [u8] (PointerCoercion(MutToConstPointer));
        _17 = std::ptr::NonNull::<[u8]> { pointer: _77 };
        StorageDead(_77);
        StorageDead(_68);
        StorageDead(_70);
        _0 = std::result::Result::<std::ptr::NonNull<[u8]>, std::alloc::AllocError>::Ok(move _17);
        StorageDead(_17);
        StorageDead(_9);
        goto -> bb6;
}


alloc11 (size: 16, align: 8) {
    00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░


alloc10 (extern static: alloc::alloc::__rust_no_alloc_shim_is_unstable)

"/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_clif/dist/rustc-clif" "--cap-lints=allow" "-Csymbol-mangling-version=v0" "-Zunstable-options" "--check-cfg=cfg(bootstrap)" "--check-cfg=cfg(parallel_compiler)" "-Zmacro-backtrace" "-Csplit-debuginfo=off" "-Cllvm-args=-import-instr-limit=10" "-Clink-args=-Wl,-z,origin" "-Clink-args=-Wl,-rpath,$ORIGIN/../lib" "--cfg=parallel_compiler" "-L" "crate=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_clif/build/example" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_clif/build/example" "-Cdebuginfo=2" "--target" "x86_64-unknown-linux-gnu" "-Cpanic=abort" "-Zunstable-options" "--check-cfg=cfg(no_unstable_features)" "--check-cfg=cfg(jit)" "example/arbitrary_self_types_pointers_and_wrappers.rs" "--cfg" "no_unstable_features" exited with status ExitStatus(unix_wait_status(25856))



command did not execute successfully: cd "/checkout/compiler/rustc_codegen_cranelift" && env -u MAKEFLAGS -u MFLAGS AR_x86_64_unknown_linux_gnu="ar" CARGO_BUILD_INCREMENTAL="false" CARGO_INCREMENTAL="0" CARGO_PROFILE_RELEASE_DEBUG="0" CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS="true" CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS="true" CARGO_PROFILE_RELEASE_STRIP="false" CARGO_TARGET_DIR="/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-codegen" CC_x86_64_unknown_linux_gnu="sccache cc" CFG_COMPILER_BUILD_TRIPLE="x86_64-unknown-linux-gnu" CFG_COMPILER_HOST_TRIPLE="x86_64-unknown-linux-gnu" CFG_DEFAULT_CODEGEN_BACKEND="llvm" CFG_LIBDIR_RELATIVE="lib" CFG_RELEASE="1.78.0-nightly" CFG_RELEASE_CHANNEL="nightly" CFG_VERSION="1.78.0-nightly (4aaaaf20f 2024-02-28)" CFG_VER_DATE="2024-02-28" CFG_VER_HASH="4aaaaf20f2298b869cd422f9ebcef634a8840072" CFLAGS_x86_64_unknown_linux_gnu="-ffunction-sections -fdata-sections -fPIC -m64" CXXFLAGS_x86_64_unknown_linux_gnu="-ffunction-sections -fdata-sections -fPIC -m64" CXX_x86_64_unknown_linux_gnu="sccache c++" LIBC_CHECK_CFG="1" LIBRARY_PATH="/usr/lib/llvm-16/lib" LLVM_CONFIG="/usr/lib/llvm-16/bin/llvm-config" LLVM_LINK_SHARED="1" LLVM_NDEBUG="1" LLVM_STATIC_STDCPP="/usr/lib/gcc/x86_64-linux-gnu/12/libstdc++.a" RANLIB_x86_64_unknown_linux_gnu="ar s" REAL_LIBRARY_PATH_VAR="LD_LIBRARY_PATH" RUSTBUILD_NATIVE_DIR="/checkout/obj/build/x86_64-unknown-linux-gnu/native" RUSTC="/checkout/obj/build/bootstrap/debug/rustc" RUSTC_BOOTSTRAP="1" RUSTC_BREAK_ON_ICE="1" RUSTC_ERROR_METADATA_DST="/checkout/obj/build/tmp/extended-error-metadata" RUSTC_FORCE_UNSTABLE="1" RUSTC_HOST_FLAGS="-Zunstable-options --check-cfg=cfg(bootstrap)" RUSTC_INSTALL_BINDIR="bin" RUSTC_LIBDIR="/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib" RUSTC_LINT_FLAGS="-Wrust_2018_idioms -Wunused_lifetimes -Dwarnings" RUSTC_REAL="/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" RUSTC_SNAPSHOT="/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" RUSTC_SNAPSHOT_LIBDIR="/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib" RUSTC_STAGE="1" RUSTC_SYSROOT="/checkout/obj/build/x86_64-unknown-linux-gnu/stage1" RUSTC_VERBOSE="0" RUSTC_VERIFY_LLVM_IR="1" RUSTC_WRAPPER="/checkout/obj/build/bootstrap/debug/rustc" RUSTDOC="/checkout/obj/build/bootstrap/debug/rustdoc" RUSTDOCFLAGS="-Csymbol-mangling-version=v0 -Zunstable-options --check-cfg=cfg(bootstrap) --check-cfg=cfg(parallel_compiler) -Dwarnings -Wrustdoc::invalid_codeblock_attributes --crate-version 1.78.0-nightly\t(4aaaaf20f\t2024-02-28) --cfg=parallel_compiler" RUSTDOC_LIBDIR="/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/lib" RUSTDOC_REAL="/path/to/nowhere/rustdoc/not/required" RUSTFLAGS="-Csymbol-mangling-version=v0 -Zunstable-options --check-cfg=cfg(bootstrap) --check-cfg=cfg(parallel_compiler) -Zmacro-backtrace -Csplit-debuginfo=off -Cllvm-args=-import-instr-limit=10 -Clink-args=-Wl,-z,origin -Clink-args=-Wl,-rpath,$ORIGIN/../lib --cfg=parallel_compiler" RUST_TEST_THREADS="16" TERM="xterm" WINAPI_NO_BUNDLED_LIBRARIES="1" __CARGO_DEFAULT_LIB_METADATA="nightlycodegen" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "run" "--target" "x86_64-unknown-linux-gnu" "--release" "-Zcheck-cfg" "-Zbinary-dep-depinfo" "-j" "16" "--locked" "--color" "always" "--manifest-path" "/checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml" "--" "test" "--download-dir" "/checkout/obj/build/cg_clif_download" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_clif" "--no-unstable-features" "--use-backend" "cranelift" "--sysroot" "llvm" "--skip-test" "testsuite.extended_sysroot"

stdout ----

stderr ----

@bors
Copy link
Contributor

bors commented Feb 29, 2024

☀️ Try build successful - checks-actions
Build commit: 9f42d34 (9f42d3498ce5ab5b6c7debfbd4e93e38935012cf)

1 similar comment
@bors
Copy link
Contributor

bors commented Feb 29, 2024

☀️ Try build successful - checks-actions
Build commit: 9f42d34 (9f42d3498ce5ab5b6c7debfbd4e93e38935012cf)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9f42d34): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.5% [0.1%, 1.2%] 21
Regressions ❌
(secondary)
1.3% [1.2%, 1.5%] 6
Improvements ✅
(primary)
-0.8% [-1.7%, -0.2%] 12
Improvements ✅
(secondary)
-0.5% [-1.1%, -0.2%] 19
All ❌✅ (primary) 0.0% [-1.7%, 1.2%] 33

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
8.2% [0.3%, 15.5%] 4
Regressions ❌
(secondary)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
-4.7% [-6.9%, -2.5%] 3
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) 2.7% [-6.9%, 15.5%] 7

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.4% [1.4%, 1.5%] 2
Regressions ❌
(secondary)
1.7% [0.9%, 2.9%] 3
Improvements ✅
(primary)
-1.1% [-1.3%, -0.8%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [-1.3%, 1.5%] 4

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.5% [0.0%, 1.6%] 52
Regressions ❌
(secondary)
0.2% [0.0%, 0.8%] 15
Improvements ✅
(primary)
-0.2% [-0.4%, -0.0%] 40
Improvements ✅
(secondary)
-0.3% [-0.5%, -0.1%] 11
All ❌✅ (primary) 0.2% [-0.4%, 1.6%] 92

Bootstrap: 651.872s -> 651.607s (-0.04%)
Artifact size: 311.14 MiB -> 311.31 MiB (0.05%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 29, 2024
@saethlin
Copy link
Member Author

I think the numerous other codegen changes that we've made should have obviated the entire approach here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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.

None yet

5 participants