Skip to content
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

Refine effects for getfield corner cases #48203

Merged
merged 3 commits into from
Jan 10, 2023
Merged

Refine effects for getfield corner cases #48203

merged 3 commits into from
Jan 10, 2023

Conversation

Keno
Copy link
Member

@Keno Keno commented Jan 9, 2023

See individual commits.

@Keno Keno requested a review from aviatesk January 9, 2023 22:18
test/compiler/effects.jl Outdated Show resolved Hide resolved
@Keno Keno changed the title Refine effects for T.instance Refine effects for getfield corner cases Jan 9, 2023
@Keno
Copy link
Member Author

Keno commented Jan 9, 2023

I've pushed some tiny related commits to this PR, since otherwise, this'll just end up conflicting with each other. Should all be straightforward.

base/compiler/tfuncs.jl Outdated Show resolved Hide resolved
@aviatesk
Copy link
Sponsor Member

I will push some changes to fix test failures.

@Keno
Copy link
Member Author

Keno commented Jan 10, 2023

thanks

@Keno
Copy link
Member Author

Keno commented Jan 10, 2023

I'm concerned about that GC root issue in llvmpasses. I also saw something similar locally on a branch that included these changes. Is that currently a known issue on master or is that new on this branch? In either case, we should try to capture it in rr and see what the missing root is.

@aviatesk
Copy link
Sponsor Member

Maybe it's the issue that Jameson pointed out about #47994 (esp. #47994 (comment))?

@Keno
Copy link
Member Author

Keno commented Jan 10, 2023

Assertions are enabled, so if that were the issue, i think we'd have seen the assertion in #48089.

@aviatesk
Copy link
Sponsor Member

(unrelated to the GC issue) So it seems like the remaining test failures (in compiler/inline and compiler/inference) are because this PR allows irinterp on more frames that are now proved as :foldable thanks to the :consistent-cy improvement of getfield.

@Keno
Copy link
Member Author

Keno commented Jan 10, 2023

The test in compiler/inline is fine, it's just getting some extra junk basic blocks:

CodeInfo(
1 ──       goto #3
2 ──       nothing::Nothing
3 ┄─ %3  = Base.getfield(x, 1)::Int64
└───       goto #4
4 ──       goto #5
5 ──       goto #7
6 ──       nothing::Nothing
7 ┄─ %8  = Base.getfield(x, 2)::Int64
└───       goto #8
8 ──       nothing::Nothing
└───       goto #10
9 ──       nothing::Nothing
10 ┄ %13 = Core.tuple(%3, %8)::Tuple{Int64, Int64}
└───       return %13
)

The test should be updated to test what it actually wants to know (two getfield calls, one tuple call, no other calls).

We were already able to essentially fold this away, but we were
incorrectly tainting :consistency.
@aviatesk
Copy link
Sponsor Member

The test in compiler/inline is fine, it's just getting some extra junk basic blocks:

Okay, just confirmed that LLVM optimizes those junks away.

The remaining ones are related to MustAlias lattice extension. I added it for JET's use case and it's not enabled in base yet. Since JET's analyzer doesn't enable irinterp, I'm fine with marking the failing cases as broken.

When all fields are known initialized syntactically, we do not
need to test whether accessing the fields will give an UndefRef.
We only need to check for the fields that are not syntactically
known to be initialized.

As a result, this commit improves `:consistent`-cy of `getfield` call,
which is better in general but leads to inference/inlining accuracy
regression in some edge cases because now irinterp is enabled on more
frames. There are two regressions, but we are fine with them so we
modify the test cases:
- inlining regression: irinterp ends up some extra junk basic blocks,
  that LLVM can optimize away down the road.
- inference regressions: these regressions are all related to the
  `MustAlias` lattice extension, which was added for JET's use case
  especially and not enabled in base yet. Since JET doesn't enable
  irinterp, this commit marks the regressed cases as broken.
Like other mutable allocation consistency here is flow-dependent.
@aviatesk
Copy link
Sponsor Member

Okay, fixed up all the failed cases. Should be good to go.

@aviatesk aviatesk merged commit 9a2f016 into master Jan 10, 2023
@aviatesk aviatesk deleted the kf/instanceffects branch January 10, 2023 09:21
aviatesk added a commit that referenced this pull request Jan 10, 2023
Follow up #48203.
See the added test cases for the purpose of this commit.
aviatesk added a commit that referenced this pull request Jan 10, 2023
Follow up #48203.
See the added test cases for the purpose of this commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants