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

[What If] NonNull could just offset directly? #133096

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scottmcm
Copy link
Member

Probably not worth it, but I'm curious.

r? ghost

Probably not worth it, but I'm curious.
@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 Nov 16, 2024
@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
#17 exporting to docker image format
#17 sending tarball 27.8s done
#17 DONE 35.4s
##[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-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
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-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--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', 'rust.lld=false', '--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-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
internal error: entered unreachable code: Offset(std::ptr::NonNull<std::string::String>, usize)
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: rustc_codegen_cranelift::num::codegen_binop
   3: rustc_codegen_cranelift::base::codegen_fn_body
   4: rustc_codegen_cranelift::base::codegen_fn
   5: rustc_codegen_cranelift::driver::aot::module_codegen
   6: rustc_codegen_cranelift::driver::aot::run_aot::{closure#3}::{closure#0}
   7: <&mut rustc_data_structures::sync::parallel::par_map<(usize, &rustc_middle::mir::mono::CodegenUnit), alloc::vec::Vec<(usize, &rustc_middle::mir::mono::CodegenUnit)>, rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen, alloc::vec::Vec<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen>, rustc_codegen_cranelift::driver::aot::run_aot::{closure#3}::{closure#0}>::{closure#0}::{closure#1} as core::ops::function::FnMut<((usize, &rustc_middle::mir::mono::CodegenUnit),)>>::call_mut
   8: <alloc::vec::into_iter::IntoIter<(usize, &rustc_middle::mir::mono::CodegenUnit)> as core::iter::traits::iterator::Iterator>::try_fold::<(), core::iter::traits::iterator::Iterator::find_map::check<(usize, &rustc_middle::mir::mono::CodegenUnit), rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen, &mut rustc_data_structures::sync::parallel::par_map<(usize, &rustc_middle::mir::mono::CodegenUnit), alloc::vec::Vec<(usize, &rustc_middle::mir::mono::CodegenUnit)>, rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen, alloc::vec::Vec<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen>, rustc_codegen_cranelift::driver::aot::run_aot::{closure#3}::{closure#0}>::{closure#0}::{closure#1}>::{closure#0}, core::ops::control_flow::ControlFlow<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen>>
   9: <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::filter_map::FilterMap<alloc::vec::into_iter::IntoIter<(usize, &rustc_middle::mir::mono::CodegenUnit)>, rustc_data_structures::sync::parallel::par_map<(usize, &rustc_middle::mir::mono::CodegenUnit), alloc::vec::Vec<(usize, &rustc_middle::mir::mono::CodegenUnit)>, rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen, alloc::vec::Vec<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen>, rustc_codegen_cranelift::driver::aot::run_aot::{closure#3}::{closure#0}>::{closure#0}::{closure#1}>>>::from_iter
  10: <rustc_session::session::Session>::time::<alloc::vec::Vec<rustc_codegen_cranelift::driver::aot::OngoingModuleCodegen>, rustc_codegen_cranelift::driver::aot::run_aot::{closure#3}>
  11: <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  13: rustc_interface::passes::start_codegen
  14: <rustc_interface::queries::Linker>::codegen_and_build_linker
  15: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#6}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  16: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#6}>
---
note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly

note: please attach the file at `/checkout/compiler/rustc_codegen_cranelift/rustc-ice-2024-11-16T09_01_21-192563.txt` to your bug report

note: compiler flags: -C panic=abort -Z panic-abort-tests -Z codegen-backend=cranelift -C symbol-mangling-version=v0 -Z randomize-layout -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 force-unstable-if-unmarked
query stack during panic:
end of query stack
end of query stack
stmt _22 = Offset(copy _23, const 1_usize)
fn <std::slice::Iter<'a, T> as std::iter::Iterator>::next(_1: &mut std::slice::Iter<'_, T>) -> std::option::Option<&T> {
    debug self => _1;
    let mut _0: std::option::Option<&T>;
    let mut _2: bool;
    let mut _4: *const T;
    let mut _6: *const std::ptr::NonNull<T>;
    let mut _7: *const *const T;
    let mut _8: &std::ptr::NonNull<T>;
    let mut _9: &std::ptr::NonNull<T>;
    let _10: &T;
    scope 1 {
        let _3: usize;
        let _5: std::ptr::NonNull<T>;
        scope 2 {
            debug len => _3;
        scope 3 {
            debug end => _5;
            debug end => _5;
            scope 7 (inlined <std::ptr::NonNull<T> as std::cmp::PartialEq>::eq) {
                debug self => _8;
                debug other => _9;
                let mut _11: std::ptr::NonNull<T>;
                scope 8 (inlined std::ptr::NonNull::<T>::as_ptr) {
                    debug self => _11;
                    let mut _12: *const T;
                }
                scope 9 (inlined std::ptr::NonNull::<T>::as_ptr) {
                    debug self => _5;
                    let mut _13: *const T;
            }
        }
        }
        scope 4 (inlined std::ptr::const_ptr::<impl *const T>::addr) {
            debug self => _4;
            scope 5 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) {
                debug self => _4;
        }
        }
        scope 6 (inlined std::ptr::const_ptr::<impl *const *const T>::cast::<std::ptr::NonNull<T>>) {
            debug self => _7;
    }
    }
    scope 10 (inlined <std::slice::Iter<'_, T> as std::iter::traits::unchecked_iterator::UncheckedIterator>::next_unchecked) {
        debug self => _1;
        let mut _14: &std::ptr::NonNull<T>;
        let _15: std::ptr::NonNull<T>;
        scope 11 (inlined std::slice::Iter::<'_, T>::post_inc_start) {
            debug self => _1;
            debug offset => const 1_usize;
            let mut _16: *mut usize;
            let mut _17: *mut *const T;
            let mut _18: usize;
            let mut _19: usize;
            let mut _20: *mut std::ptr::NonNull<T>;
            let mut _21: *mut *const T;
            let mut _22: std::ptr::NonNull<T>;
            let mut _23: std::ptr::NonNull<T>;
            scope 12 {
                debug old => _15;
                scope 13 {
                    scope 14 {
                        debug len => _16;
                    scope 15 {
                        debug _end => _20;
                        debug _end => _20;
                        scope 18 (inlined std::ptr::NonNull::<T>::add) {
                            debug self => _23;
                            debug count => const 1_usize;
                    }
                    }
                    scope 16 (inlined std::ptr::mut_ptr::<impl *mut *const T>::cast::<usize>) {
                        debug self => _17;
                    }
                    scope 17 (inlined std::ptr::mut_ptr::<impl *mut *const T>::cast::<std::ptr::NonNull<T>>) {
                        debug self => _21;
                }
            }
        }
        }
        scope 19 (inlined std::ptr::NonNull::<T>::as_ref::<'_>) {
            debug self => _14;
            let mut _24: *mut T;
            scope 20 (inlined std::ptr::NonNull::<T>::as_ptr) {
                debug self => _15;
                let mut _25: *const T;
            }
            scope 21 (inlined std::ptr::mut_ptr::<impl *mut T>::cast_const) {
                debug self => _24;
        }
    }

    bb0: {
    bb0: {
        StorageLive(_2);
        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb2, otherwise: bb1];

    bb1: {
        _4 = copy ((*_1).1: *const T);
        _3 = copy _4 as usize (Transmute);
        _3 = copy _4 as usize (Transmute);
        _2 = Eq(copy _3, const 0_usize);
        goto -> bb3;

    bb2: {
        StorageLive(_6);
        StorageLive(_7);
        StorageLive(_7);
        _7 = &raw const ((*_1).1: *const T);
        _6 = copy _7 as *const std::ptr::NonNull<T> (PtrToPtr);
        _5 = copy (*_6);
        StorageDead(_6);
        StorageLive(_8);
        StorageLive(_8);
        _8 = &((*_1).0: std::ptr::NonNull<T>);
        _9 = &_5;
        StorageLive(_12);
        StorageLive(_13);
        StorageLive(_11);
        StorageLive(_11);
        _11 = copy ((*_1).0: std::ptr::NonNull<T>);
        _12 = copy (_11.0: *const T);
        StorageDead(_11);
        _13 = copy (_5.0: *const T);
        _2 = Eq(copy _12, copy _13);
        StorageDead(_12);
        StorageDead(_9);
        StorageDead(_8);
        goto -> bb3;
        goto -> bb3;
    }

    bb3: {
        switchInt(move _2) -> [0: bb5, otherwise: bb4];

    bb4: {
    bb4: {
        _0 = const {transmute(0x0000000000000000): std::option::Option<&T>};
        goto -> bb6;

    bb5: {
        StorageLive(_15);
        StorageLive(_14);
        StorageLive(_14);
        StorageLive(_16);
        _15 = copy ((*_1).0: std::ptr::NonNull<T>);
        switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb9, otherwise: bb8];

    bb6: {
        StorageDead(_2);
        return;
        return;
    }

    bb7: {
        StorageDead(_16);
        _14 = &_15;
        StorageLive(_25);
        StorageLive(_24);
        _25 = copy (_15.0: *const T);
        _24 = copy _25 as *mut T (PtrToPtr);
        _10 = &(*_25);
        StorageDead(_25);
        StorageDead(_14);
        StorageDead(_15);
        StorageDead(_15);
        _0 = std::option::Option::<&T>::Some(copy _10);
        goto -> bb6;
    }

    bb8: {
        StorageLive(_17);
        _17 = &raw mut ((*_1).1: *const T);
        _16 = copy _17 as *mut usize (PtrToPtr);
        StorageLive(_18);
        StorageLive(_19);
        _19 = copy (*_16);
        _19 = copy (*_16);
        _18 = SubUnchecked(move _19, const 1_usize);
        StorageDead(_19);
        (*_16) = move _18;
        goto -> bb7;
    }

    bb9: {
    bb9: {
        StorageLive(_20);
        StorageLive(_21);
        _21 = &raw mut ((*_1).1: *const T);
        _20 = copy _21 as *mut std::ptr::NonNull<T> (PtrToPtr);
        StorageLive(_22);
        StorageLive(_23);
        StorageLive(_23);
        _23 = copy ((*_1).0: std::ptr::NonNull<T>);
        _22 = Offset(copy _23, const 1_usize);
        StorageDead(_23);
        ((*_1).0: std::ptr::NonNull<T>) = move _22;
        StorageDead(_20);
        goto -> bb7;
    }
}
}

"/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_clif/dist/rustc-clif" "-Csymbol-mangling-version=v0" "-Zrandomize-layout" "-Zunstable-options" "--check-cfg=cfg(bootstrap)" "--check-cfg=cfg(llvm_enzyme)" "-Zmacro-backtrace" "-Csplit-debuginfo=off" "-Cllvm-args=-import-instr-limit=10" "-Clink-args=-Wl,-z,origin" "-Clink-args=-Wl,-rpath,$ORIGIN/../lib" "-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" "--check-cfg=cfg(jit)" "example/std_example.rs" exited with status ExitStatus(unix_wait_status(25856))
Command has failed. Rerun with -v to see more details.
  local time: Sat Nov 16 09:01:21 UTC 2024
  network time: Sat, 16 Nov 2024 09:01:21 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@scottmcm
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 16, 2024
@bors
Copy link
Contributor

bors commented Nov 16, 2024

⌛ Trying commit c9bd538 with merge 27363a4ea44373c4a9ec90863a3a76efbfcd1adf...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 16, 2024
…<try>

[What If] NonNull could just offset directly?

Probably not worth it, but I'm curious.

r? ghost
@bors
Copy link
Contributor

bors commented Nov 16, 2024

☀️ Try build successful - checks-actions
Build commit: 27363a4 (27363a4ea44373c4a9ec90863a3a76efbfcd1adf)

@rust-timer
Copy link
Collaborator

Queued 27363a4 with parent 46e8d20, future comparison URL.
There is currently 1 preceding artifact in the queue.
It will probably take at least ~1.8 hours until the benchmark run finishes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-perf Status: Waiting on a perf run to be completed. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants