-
Notifications
You must be signed in to change notification settings - Fork 831
[CompilerPerf] Fix 5136: LAddrOf is a constant and {x with ...} respects byrefness of x #5148
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
Conversation
{x with ...} respects byrefness of x{x with ...} respects byrefness of x
{x with ...} respects byrefness of x
member x.Next = let (SingleUnion i) = x in SingleUnion (i+1)or member x.Next =
match x with
| SingleUnion i -> SingleUnion (i+1)Code size 24 down to 16 with the extractive copy removed: AFTER: BEFORE: |
|
@dotnet-bot test this please |
1 similar comment
|
@dotnet-bot test this please |
|
NOTE: CI is still not running for some reason, and needs to be re-run on this PR when it starts working again |
|
@dotnet-bot test this please |
|
@dotnet-bot test this please |
|
It seems a test is failing for "StructUnion01.il.bsl" since the IL has actually changed. |
|
👍 this time it should pass. |
|
And the fix is actually really small |
|
I tried to compile this code: [<Struct>]
type Context = { Img: int; Pos: nativeint}
module Context =
let inline move n ctx = { ctx with Pos = ctx.Pos + n } but get the following error: Which translates to "Unable to curently use 'ctx' variable's address" |
|
Actually it not due to It seems that has this point the type |
|
Something to do with #5146 probably... |
|
@dsyme ---> When do you think this will be ready? Master is cleared for Dev16.0 now. |
|
Ugh, now getting a CI failure on Linux - feels like a compiler bug though I don't know why this would only affect Mono (it could be we're hitting some size limitation or bug caused by very large binaries and that is triggered on Mono first due to somhow extra code being added there) I've just pushed some extra diagnostics to try to diagnose this a little. |
|
I added diagnostics, and the build completed ok... Trying again with the original commit 771ef66 |
|
@KevinRansom It is ready. Odd CI error before but now it is gone |
1,
{ x with ... }respecting byrefs2. In optimization,
&x(i.e. LAddrOf) is a constant value even ifxis mutable and so can be propagated (so forlet y = &x in ... y ...the occurrences of y get replaced by&xandygets removed)See #5136, also related to #2688.
For (1), basically
should respect the byrefness of
xin the case thatxis a byref pointer to a struct which is being implicitly dereferenced. At the moment this elaborates to:It should elaborate to:
which removes a struct copy. #2688 covers a similar case for struct unions.