-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Draft] JIT: Testing field-wise analysis #105162
Conversation
These flags are strictly optimizations. Having them required to be set for certain indirs based on context of the operand introduces IR invariants that are annoying to work with since it suddenly becomes necessary for all transformations to consider "did we just introduce this IR shape?". Instead, handle these patterns during morph as the optimization it is and remove the strict flags checking from `fgDebugCheckFlags`.
9a3a510
to
9f40866
Compare
The current field-wise analysis is too conservative and is making a lot of false negatives where it stack-allocates less than before the field-wise analysis was added. The analysis needs more work to unblock more cases. |
Added back the array for testing as it needs |
Closing as the analysis still need more work. |
Can you summarize what you tried and what roadblocks you ran into? |
The analysis in my prototype tried to recognize the following cases: Case 1:
Then it extracts the
Case 2:
In this case, it extracts the
What's more, now a local may escape through However, actually this cannot handle the address correctly, as we may dup a local to another local directly lie:
Consider this code: var foo = new Foo(new Bar());
return foo.B;
class Foo
{
public Bar B { get; set; }
public Foo(Bar? b)
{
B = b ?? new Bar();
}
}
class Bar { } which produces the following GenTree:
We added an edge from In the end the To address this, I conservatively add a bidirectional edge from both source to target and target to source when we see
While the current analysis still has correctness issue. Actually, the analysis needs to follow the Anderson's algorithm, and we need to track it following the below 4 rules: Here introducing a
So apparently the prototype I built is both too conservative and incomplete (we need to treat Finally, I decide to stop the current prototype and move to Steensgaard's algorithm, which is fast as it's an algorithm in linear time. I'm running out of bandwidth so I'm closing this PR. I may revisit it to try the new algorithm if I have more time in the future. Also, spilling all fields to their own temps may simplify the analysis in my opinion, though I'm not confident about this. |
Thanks for the detailed notes. Not too surprising that this sort of analysis requires careful thinking. If we end up needing to implement union-find as part of a revised approach, it would be good to think about how to make it into something generally useful. |
Built on-top-of the array analysis. I have been trying to make the analysis conservative, still open a PR to check if anything is broken. I expect many AVs can happen in the current stage.
/cc: @AndyAyersMS