-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Add tests for slice bounds check optimization #139129
Add tests for slice bounds check optimization #139129
Conversation
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
This comment has been minimized.
This comment has been minimized.
f8d5a87
to
599a94d
Compare
This comment has been minimized.
This comment has been minimized.
599a94d
to
f98f095
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this file is needed because it doesn't test anything new. Could you remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I removed it.
// In a suboptimal implementation this would contain a call to | ||
// slice_start_index_len_fail that is unreachable. | ||
|
||
// The fix exists in LLVM 20: We use this implementation with | ||
// bounds check outside of slice operation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// In a suboptimal implementation this would contain a call to | |
// slice_start_index_len_fail that is unreachable. | |
// The fix exists in LLVM 20: We use this implementation with | |
// bounds check outside of slice operation. | |
// Previously this would generate a branch to slice_start_index_len_fail | |
// that is unreachable. The LLVM 20 fix should eliminate this branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly, I think it is okay to only keep the codegen test. assembly is one step further than we need since we just have to check if the LLVM IR contains the call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to this -- assembly is annoyingly platform specific in a bunch of ways, so we should test it as little as possible in rustc. Specific assembly is almost always LLVM's problem, not our problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense — I’ve already removed the assembly test accordingly.
Only the codegen test remains now.
// This implementation avoids the issue by moving the slice operation | ||
// inside the conditional. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// This implementation avoids the issue by moving the slice operation | |
// inside the conditional. | |
// This version was already correctly optimized before the fix in LLVM 20. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion — I’ve applied it.
f98f095
to
dea9472
Compare
@rustbot ready |
@bors r+ rollup |
…-check-optimization, r=fee1-dead Add tests for slice bounds check optimization Closes rust-lang#134466
…-check-optimization, r=fee1-dead Add tests for slice bounds check optimization Closes rust-lang#134466
Rollup of 12 pull requests Successful merges: - rust-lang#110406 (rustdoc-json: Add test for #[automatically_derived] attribute) - rust-lang#137738 (Make slice iterator constructors unstably const) - rust-lang#138492 (remove `feature(inline_const_pat)`) - rust-lang#138928 (Fix UWP reparse point check) - rust-lang#138950 (replace extra_filename with strict version hash in metrics file names) - rust-lang#139002 (Add release notes for 1.86.0) - rust-lang#139022 (increment depth of nested obligations) - rust-lang#139060 (replace commit placeholder in vendor status with actual commit) - rust-lang#139102 (coverage: Avoid splitting spans during span extraction/refinement) - rust-lang#139129 (Add tests for slice bounds check optimization) - rust-lang#139188 (PassWrapper: adapt for llvm/llvm-project@94122d58fc77079a291a3d008914…) - rust-lang#139193 (Feed HIR for by-move coroutine body def, since the inliner tries to read its attrs) r? `@ghost` `@rustbot` modify labels: rollup
…-check-optimization, r=fee1-dead Add tests for slice bounds check optimization Closes rust-lang#134466
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#110406 (rustdoc-json: Add test for #[automatically_derived] attribute) - rust-lang#138790 (Note potential but private items in show_candidates) - rust-lang#138950 (replace extra_filename with strict version hash in metrics file names) - rust-lang#139002 (Add release notes for 1.86.0) - rust-lang#139022 (increment depth of nested obligations) - rust-lang#139129 (Add tests for slice bounds check optimization) - rust-lang#139188 (PassWrapper: adapt for llvm/llvm-project@94122d58fc77079a291a3d008914…) - rust-lang#139193 (Feed HIR for by-move coroutine body def, since the inliner tries to read its attrs) - rust-lang#139202 (Improve docs of ValTreeKind) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#110406 (rustdoc-json: Add test for #[automatically_derived] attribute) - rust-lang#138790 (Note potential but private items in show_candidates) - rust-lang#139002 (Add release notes for 1.86.0) - rust-lang#139022 (increment depth of nested obligations) - rust-lang#139129 (Add tests for slice bounds check optimization) - rust-lang#139188 (PassWrapper: adapt for llvm/llvm-project@94122d58fc77079a291a3d008914…) - rust-lang#139193 (Feed HIR for by-move coroutine body def, since the inliner tries to read its attrs) - rust-lang#139202 (Improve docs of ValTreeKind) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#139129 - reez12g:add-tests-for-slice-bounds-check-optimization, r=fee1-dead Add tests for slice bounds check optimization Closes rust-lang#134466
Closes #134466