Skip to content

Try to improve into_slice_range inlining#157947

Draft
saethlin wants to merge 1 commit into
rust-lang:mainfrom
saethlin:into_slice_range
Draft

Try to improve into_slice_range inlining#157947
saethlin wants to merge 1 commit into
rust-lang:mainfrom
saethlin:into_slice_range

Conversation

@saethlin

Copy link
Copy Markdown
Member

This is a possible solution to #157909. I think the root problem is that LLVM sees the many non-inlinable calls to slice_index_fail and decides that the function must be a bad inlining candidate.

The other strategy I was thinking of was to call try_into_slice_range. I think deduplicating the checking logic in the source between these two functions might just be a good cleanup. But first I'm going to check if this has unexpected perf impact, because I saw mentions of RangeBounds in the compiler source.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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 Jun 16, 2026
@saethlin

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

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

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 16, 2026
rust-bors Bot pushed a commit that referenced this pull request Jun 16, 2026
Try to improve into_slice_range inlining
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[TIMING:end] tool::ToolBuild { build_compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu, tool: "tidy", path: "src/tools/tidy", mode: ToolBootstrap, source_type: InTree, extra_features: [], allow_features: "", cargo_args: [], artifact_kind: Binary } -- 13.085
[TIMING:end] tool::Tidy { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu } -- 0.000
fmt check
Diff in /checkout/tests/codegen-llvm/bounds-checking/bound-tuple.rs:1:
 //@ compile-flags: -O -Zmerge-functions=disabled
 #![crate_type = "lib"]
-    
+
 use std::collections::Bound;
 use std::ops::RangeBounds;
 
Diff in /checkout/tests/codegen-llvm/bounds-checking/bound-tuple.rs:18:
     // CHECK-NOT: slice_index_fail
     // CHECK-NOT: br
     // CHECK: ret
-    if buf.len() < 4 {
-        None
-    } else {
-        Some(&buf[(Bound::Included(4), Bound::Unbounded)])
-    }
+    if buf.len() < 4 { None } else { Some(&buf[(Bound::Included(4), Bound::Unbounded)]) }
 }
 
 #[no_mangle]
fmt: checked 6912 files
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`

@rust-bors

rust-bors Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 6a83d7f (6a83d7f17c32155a5e582df6cf5dfcfa8f6d1b67, parent: 01dfd79246f1b2d5f146616deff08223a840a9ae)

@rust-timer

Copy link
Copy Markdown
Collaborator

Queued 6a83d7f with parent 01dfd79, future comparison URL.
There are currently 0 preceding artifacts in the queue.
It will probably take at least ~1.0 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-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-perf Status: Waiting on a perf run to be completed. 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