forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Improve migration lint #58
Draft
roxelo
wants to merge
33
commits into
rfc2229-migration-capture-kind
Choose a base branch
from
rfc2229-improve-lint
base: rfc2229-migration-capture-kind
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
One key observation while going over the closure size profile of rustc was that we are disjointly capturing one or more fields starting at an immutable reference. Disjoint capture over immutable reference doesn't add too much value because the fields can either be borrowed immutably or copied. One possible edge case of the optimization is when a fields of a struct have a longer lifetime than the structure, therefore we can't completely get rid of all the accesses on top of sharef refs, only the rightmost one. Here is a possible example: ```rust struct MyStruct<'a> { a: &'static A, b: B, c: C<'a>, } fn foo<'a, 'b>(m: &'a MyStruct<'b>) -> impl FnMut() + 'static { let c = || drop(&*m.a.field_of_a); // Here we really do want to capture `*m.a` because that outlives `'static` // If we capture `m`, then the closure no longer outlives `'static' // it is constrained to `'a` } ```
9ef334f
to
dc20230
Compare
special case for integer log10 Now that rust-lang#80918 has been merged, this PR provides a faster version of `log10`. The PR also adds some tests for values close to all powers of 10.
94530e3
to
7c15fc1
Compare
dc20230
to
64383fa
Compare
- Add `:Sized` assertion in interpreter impl - Use `Scalar::from_bool` instead of `ScalarInt: From<bool>` - Remove unneeded comparison in intrinsic typeck - Make this UB to call with undef, not just return undef in that case
Showing that this avoids an alloca and private constant.
9b0e94d
to
10088df
Compare
10088df
to
a298535
Compare
2229: Reduce the size of closures with `capture_disjoint_fields` One key observation while going over the closure size profile of rustc was that we are disjointly capturing one or more fields starting at an immutable reference. Disjoint capture over immutable reference doesn't add too much value because the fields can either be borrowed immutably or copied. One possible edge case of the optimization is when a fields of a struct have a longer lifetime than the structure, therefore we can't completely get rid of all the accesses on top of sharef refs, only the rightmost one. Here is a possible example: ```rust struct MyStruct<'a> { a: &'static A, b: B, c: C<'a>, } fn foo<'a, 'b>(m: &'a MyStruct<'b>) -> impl FnMut() + 'static { let c = || drop(&*m.a.field_of_a); // Here we really do want to capture `*m.a` because that outlives `'static` // If we capture `m`, then the closure no longer outlives `'static' // it is constrained to `'a` } ``` r? `@nikomatsakis`
…-kind, r=nikomatsakis Account for capture kind in auto traits migration Modifies the current auto traits migration for RFC2229 so it takes into account capture kind Closes rust-lang/project-rfc-2229#51 r? `@nikomatsakis`
…, r=nikomatsakis Check FromIterator trait impl in prelude collision check. Fixes rust-lang#86902.
Stop generating `alloca`s & `memcmp` for simple short array equality Example: ```rust pub fn demo(x: [u16; 6], y: [u16; 6]) -> bool { x == y } ``` Before: ```llvm define zeroext i1 `@_ZN10playground4demo17h48537f7eac23948fE(i96` %0, i96 %1) unnamed_addr #0 { start: %y = alloca [6 x i16], align 8 %x = alloca [6 x i16], align 8 %.0..sroa_cast = bitcast [6 x i16]* %x to i96* store i96 %0, i96* %.0..sroa_cast, align 8 %.0..sroa_cast3 = bitcast [6 x i16]* %y to i96* store i96 %1, i96* %.0..sroa_cast3, align 8 %_11.i.i.i = bitcast [6 x i16]* %x to i8* %_14.i.i.i = bitcast [6 x i16]* %y to i8* %bcmp.i.i.i = call i32 `@bcmp(i8*` nonnull dereferenceable(12) %_11.i.i.i, i8* nonnull dereferenceable(12) %_14.i.i.i, i64 12) #2, !alias.scope !2 %2 = icmp eq i32 %bcmp.i.i.i, 0 ret i1 %2 } ``` ```x86 playground::demo: # `@playground::demo` sub rsp, 32 mov qword ptr [rsp], rdi mov dword ptr [rsp + 8], esi mov qword ptr [rsp + 16], rdx mov dword ptr [rsp + 24], ecx xor rdi, rdx xor esi, ecx or rsi, rdi sete al add rsp, 32 ret ``` After: ```llvm define zeroext i1 `@_ZN4mini4demo17h7a8994aaa314c981E(i96` %0, i96 %1) unnamed_addr #0 { start: %2 = icmp eq i96 %0, %1 ret i1 %2 } ``` ```x86 _ZN4mini4demo17h7a8994aaa314c981E: xor rcx, r8 xor edx, r9d or rdx, rcx sete al ret ```
a298535
to
8cbeaf7
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current state of the migration lint improvement.
Example of drop migration lint:
Example of trait migration lint: