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

Update a bunch of library types for MCP807 #135236

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

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Jan 8, 2025

This greatly reduces the number of places that actually use the rustc_layout_scalar_valid_range_* attributes down to just 3:

library/core\src\ptr\non_null.rs
68:#[rustc_layout_scalar_valid_range_start(1)]

library/core\src\num\niche_types.rs
19:        #[rustc_layout_scalar_valid_range_start($low)]
20:        #[rustc_layout_scalar_valid_range_end($high)]

Everything else -- PAL Nanoseconds, alloc's Cap, niched FDs, etc -- all just wrap those niche_types types.

r? ghost

@rustbot rustbot added O-solid Operating System: SOLID O-unix Operating system: Unix-like O-windows Operating system: Windows 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 Jan 8, 2025
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the more-mcp807-library-updates branch from 9afba99 to 32606ca Compare January 8, 2025 08:17
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the more-mcp807-library-updates branch from 32606ca to 91c7fde Compare January 8, 2025 08:28
@rust-log-analyzer

This comment has been minimized.

This greatly reduces the number of places that actually use the `rustc_layout_scalar_valid_range_*` attributes down to just 3:
```
library/core\src\ptr\non_null.rs
68:#[rustc_layout_scalar_valid_range_start(1)]

library/core\src\num\niche_types.rs
19:        #[rustc_layout_scalar_valid_range_start($low)]
20:        #[rustc_layout_scalar_valid_range_end($high)]
```

Everything else -- PAL Nanoseconds, alloc's `Cap`, niched FDs, etc -- all just wrap those `niche_types` types.
@scottmcm scottmcm force-pushed the more-mcp807-library-updates branch from 91c7fde to 1df19d1 Compare January 9, 2025 02:33
@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)
#22 exporting to docker image format
#22 sending tarball 27.5s done
#22 DONE 33.5s
##[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
---
failures:

---- [codegen] tests/codegen/vec_pop_push_noop.rs#llvm-pre-19 stdout ----

error in revision `llvm-pre-19`: verification with 'FileCheck' failed
status: exit status: 1
command: "/usr/lib/llvm-18/bin/FileCheck" "--input-file" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/vec_pop_push_noop.llvm-pre-19/vec_pop_push_noop.ll" "/checkout/tests/codegen/vec_pop_push_noop.rs" "--check-prefix=CHECK" "--check-prefix" "llvm-pre-19" "--allow-unused-prefixes" "--dump-input-context" "100"
--- stderr -------------------------------
--- stderr -------------------------------
/checkout/tests/codegen/vec_pop_push_noop.rs:15:18: error: llvm-pre-19: expected string not found in input
 // llvm-pre-19: call
                 ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/vec_pop_push_noop.llvm-pre-19/vec_pop_push_noop.ll:21:29: note: scanning from here
 tail call void @llvm.assume(i1 %cond.i)
                            ^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/vec_pop_push_noop.llvm-pre-19/vec_pop_push_noop.ll:24:29: note: possible intended match here
bb3: ; preds = %start, %"_ZN5alloc3vec16Vec$LT$T$C$A$GT$4push17hd4a1e7a19fc33e46E.exit"


Input file: /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/vec_pop_push_noop.llvm-pre-19/vec_pop_push_noop.ll


-dump-input=help explains the following input dump.
Input was:
<<<<<<
<<<<<<
            1: ; ModuleID = 'vec_pop_push_noop.2c8a275f269cfdaf-cgu.0' 
            2: source_filename = "vec_pop_push_noop.2c8a275f269cfdaf-cgu.0" 
            3: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" 
            5:  
            5:  
            6: @alloc_51474328339f2c7d77915d02854b2ab1 = private unnamed_addr constant <{ [44 x i8] }> <{ [44 x i8] c"/checkout/tests/codegen/vec_pop_push_noop.rs" }>, align 1 
            7: @alloc_91001570030a99b163732ef67ee4451b = private unnamed_addr constant <{ ptr, [16 x i8] }> <{ ptr @alloc_51474328339f2c7d77915d02854b2ab1, [16 x i8] c",\00\00\00\00\00\00\00\07\00\00\00\1D\00\00\00" }>, align 8 
            8:  
            9: ; Function Attrs: mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(argmem: read, inaccessiblemem: write) uwtable 
           10: define void @noop(ptr noalias nocapture noundef readonly align 8 dereferenceable(24) %v) unnamed_addr #0 personality ptr @rust_eh_personality { 
           11: start: 
           12:  %0 = getelementptr inbounds i8, ptr %v, i64 16 
           13:  %_2.i = load i64, ptr %0, align 8, !alias.scope !3, !noundef !6 
           14:  %.not = icmp eq i64 %_2.i, 0 
           15:  br i1 %.not, label %bb3, label %"_ZN5alloc3vec16Vec$LT$T$C$A$GT$4push17hd4a1e7a19fc33e46E.exit" 
           16:  
           17: "_ZN5alloc3vec16Vec$LT$T$C$A$GT$4push17hd4a1e7a19fc33e46E.exit": ; preds = %start 
           18:  %_3.0.i = add i64 %_2.i, -1 
           19:  %_15.i = load i64, ptr %v, align 8, !range !7, !noundef !6 
           20:  %cond.i = icmp ult i64 %_3.0.i, %_15.i 
           21:  tail call void @llvm.assume(i1 %cond.i) 
check:15'0                                 X~~~~~~~~~~~~ error: no match found
           22:  br label %bb3 
check:15'0     ~~~~~~~~~~~~~~~
check:15'0     ~
check:15'0     ~
           24: bb3: ; preds = %start, %"_ZN5alloc3vec16Vec$LT$T$C$A$GT$4push17hd4a1e7a19fc33e46E.exit" 
check:15'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:15'1                                 ?                                                            possible intended match
           25:  ret void 
check:15'0     ~~~~~~~~~~
           26: } 
check:15'0     ~~
check:15'0     ~
check:15'0     ~
           28: ; Function Attrs: nonlazybind uwtable 
check:15'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           29: define void @push_byte(ptr noalias noundef align 8 dereferenceable(24) %v) unnamed_addr #1 personality ptr @rust_eh_personality { 
check:15'0     ~~~~~~~~~~~~~~~~~~~~~~~
           30: start: 
           31:  %0 = getelementptr inbounds i8, ptr %v, i64 16 
           32:  %len.i = load i64, ptr %0, align 8, !alias.scope !8, !noalias !11, !noundef !6 
           33:  %_18.i = load i64, ptr %v, align 8, !range !7, !alias.scope !8, !noalias !11, !noundef !6 
           34:  %_4.i = icmp eq i64 %len.i, %_18.i 
           35:  br i1 %_4.i, label %bb1.i, label %"_ZN5alloc3vec16Vec$LT$T$C$A$GT$4push17hd4a1e7a19fc33e46E.exit" 
           36:  
           37: bb1.i: ; preds = %start 
           38: ; call <alloc::raw_vec::RawVec<u8>>::grow_one 
           39:  tail call void @_RNvMs1_NtCscL3QlWgWVOV_5alloc7raw_vecINtB5_6RawVechE8grow_oneB7_(ptr noalias noundef nonnull align 8 dereferenceable(16) %v, ptr noalias noundef nonnull readonly align 8 dereferenceable(24) @alloc_91001570030a99b163732ef67ee4451b) 
           40:  br label %"_ZN5alloc3vec16Vec$LT$T$C$A$GT$4push17hd4a1e7a19fc33e46E.exit" 
           41:  
           42: "_ZN5alloc3vec16Vec$LT$T$C$A$GT$4push17hd4a1e7a19fc33e46E.exit": ; preds = %start, %bb1.i 
           43:  %1 = getelementptr inbounds i8, ptr %v, i64 8 
           44:  %_22.i = load ptr, ptr %1, align 8, !alias.scope !8, !noalias !11, !nonnull !6, !noundef !6 
           45:  %2 = getelementptr inbounds i8, ptr %_22.i, i64 %len.i 
           46:  store i8 3, ptr %2, align 1 
           47:  %_13.0.i = add i64 %len.i, 1 
           48:  store i64 %_13.0.i, ptr %0, align 8, !alias.scope !8, !noalias !11 
           49:  ret void 
           50: } 
           51:  
           52: ; Function Attrs: nounwind nonlazybind uwtable 
           53: declare noundef i32 @rust_eh_personality(i32 noundef, i32 noundef, i64 noundef, ptr noundef, ptr noundef) unnamed_addr #2 
           54:  
           55: ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) 
           56: declare void @llvm.assume(i1 noundef) #3 
           57:  
           58: ; <alloc::raw_vec::RawVec<u8>>::grow_one 
           59: ; Function Attrs: noinline nonlazybind uwtable 
           60: declare void @_RNvMs1_NtCscL3QlWgWVOV_5alloc7raw_vecINtB5_6RawVechE8grow_oneB7_(ptr noalias noundef align 8 dereferenceable(16), ptr noalias noundef readonly align 8 dereferenceable(24)) unnamed_addr #4 
           61:  
           62: attributes #0 = { mustprogress nofree norecurse nosync nounwind nonlazybind willreturn memory(argmem: read, inaccessiblemem: write) uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" "target-features"="+x87,+sse2" } 
           63: attributes #1 = { nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" "target-features"="+x87,+sse2" } 
           64: attributes #2 = { nounwind nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" "target-features"="+x87,+sse2" } 
           65: attributes #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) } 
           66: attributes #4 = { noinline nonlazybind uwtable "probe-stack"="inline-asm" "target-cpu"="x86-64" "target-features"="+x87,+sse2" } 
           67:  
           68: !llvm.module.flags = !{!0, !1} 
           69: !llvm.ident = !{!2} 
           70:  
           71: !0 = !{i32 8, !"PIC Level", i32 2} 
           72: !1 = !{i32 2, !"RtLibUseGOT", i32 1} 
           73: !2 = !{!"rustc version 1.86.0-nightly (dcfecdb44 2025-01-09)"} 
           74: !3 = !{!4} 
           75: !4 = distinct !{!4, !5, !"_ZN5alloc3vec16Vec$LT$T$C$A$GT$3pop17hdd79b07f109109eeE: %self"} 
           76: !5 = distinct !{!5, !"_ZN5alloc3vec16Vec$LT$T$C$A$GT$3pop17hdd79b07f109109eeE"} 
           77: !6 = !{} 
           78: !7 = !{i64 0, i64 -9223372036854775808} 
           79: !8 = !{!9} 
           80: !9 = distinct !{!9, !10, !"_ZN5alloc3vec16Vec$LT$T$C$A$GT$4push17hd4a1e7a19fc33e46E: %self"} 
           81: !10 = distinct !{!10, !"_ZN5alloc3vec16Vec$LT$T$C$A$GT$4push17hd4a1e7a19fc33e46E"} 
           82: !11 = !{!12} 
           83: !12 = distinct !{!12, !10, !"_ZN5alloc3vec16Vec$LT$T$C$A$GT$4push17hd4a1e7a19fc33e46E: argument 1"} 
------------------------------------------



#[derive(Clone, Copy)]
#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)]
#[rustc_nonnull_optimization_guaranteed]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see this attribute in the new code for the non zero integers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-solid Operating System: SOLID O-unix Operating system: Unix-like O-windows Operating system: Windows 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.

4 participants