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

effects: add :inaccessiblememonly effect #46198

Merged
merged 2 commits into from
Aug 3, 2022
Merged

effects: add :inaccessiblememonly effect #46198

merged 2 commits into from
Aug 3, 2022

Conversation

aviatesk
Copy link
Sponsor Member

@aviatesk aviatesk commented Jul 27, 2022

This is a preparatory PR for future improvements on the effects analysis.
This commit adds the :inaccessiblememonly helper effect, that tracks
if a method involves any access or modification on any mutable state.
This effect property is basically same as LLVM's inaccessiblememonly
function attribute, except that it only reasons about mutable memory.
This effect property can be considered as a very limited and coarse
version of escape analysis and allow us prove :consistent-cy or
:effect_free-ness even in a presence of accesses or modifications
on local mutable allocations in cases when we can prove they are local
and don't escape. Separate PRs that actually improve the effect analysis
accuracy will follow.

@aviatesk
Copy link
Sponsor Member Author

Separate PRs that actually improve the effect analysis
accuracy will follow.

#46199 and #46200 .

base/expr.jl Outdated
@@ -570,6 +571,19 @@ moved between tasks without observable results.
code that is not `:notaskstate`, but is `:effect_free` and `:consistent`
may still be dead-code-eliminated and thus promoted to `:total`.

---
## `:noglobal`
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the same as inaccessiblemem_or_argmemonly in llvm? Asking because at some point it would be useful to start transferring our annotations into LLVM too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's quite the same, since this excludes the case where you're passing in a global as an argument. I think :noglobal probably implies it though?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently :noglobal === true means inaccessiblemem_or_argmemonly and it includes cases we access to (potentially) global memory passed as an argument. And we additionally check that arguments are never be mutable global memory (by a simple type analysis) when trying to refine :consistent or :effect_free information later.

Now I wonder if we should make :noglobal === ALWAYS_TRUE mean inaccessiblemem and :noglobal === INACCESSIBLEMEM_OR_ARGMEMONLY mean that so.

And I guess one more difference is that :noglobal doesn't really reason about immutable global memory, as it doesn't taint :consistent-cy/:effect_free-ness anyway.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking about this for a bit, now I think it's a bit confusing that currently :noglobal === ALWAYS_TRUE doesn't exclude access to arguments memory, and we may want to make :noglobal === ALWAYS_TRUE mean inaccessiblemem and :noglobal === ARGMEM mean inaccessiblemem_or_argmemonly and also rename :noglobal to :inaccessiblemem.

This property may not necessarily 1-to-1 correspond to LLVM's function attributes since our :inaccessiblemem only reasons about mutable memory.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

llvm also only reasons about mutable memory

@aviatesk aviatesk force-pushed the avi/redesign-effectsbits branch 3 times, most recently from d64d832 to b1f1f49 Compare July 29, 2022 22:30
Base automatically changed from avi/redesign-effectsbits to master July 30, 2022 04:30
@aviatesk aviatesk changed the title effects: add :noglobal effect effects: add :inaccessiblememonly effect Jul 30, 2022
This is a preparatory PR for future improvements on the effects analysis.
This commit adds the `:inaccessiblememonly` helper effect, that tracks
if a method involves any access or modification on any mutable state.
This effect property is basically same as LLVM's `inaccessiblememonly`
function attribute, except that it only reasons about mutable memory.
This effect property can be considered as a very limited and coarse
version of escape analysis and allow us prove `:consistent`-cy or
`:effect_free`-ness even in a presence of accesses or modifications
on local mutable allocations in cases when we can prove they are local
and don't escape. Separate PRs that actually improve the effect analysis
accuracy will follow.
@aviatesk aviatesk added the compiler:inference Type inference label Aug 1, 2022
@aviatesk aviatesk merged commit c094a89 into master Aug 3, 2022
@aviatesk aviatesk deleted the avi/noglobal branch August 3, 2022 05:33
ffucci pushed a commit to ffucci/julia that referenced this pull request Aug 11, 2022
This is a preparatory PR for future improvements on the effects analysis.
This commit adds the `:inaccessiblememonly` helper effect, that tracks
if a method involves any access or modification on any mutable state.
This effect property is basically same as LLVM's `inaccessiblememonly`
function attribute, except that it only reasons about mutable memory.
This effect property can be considered as a very limited and coarse
version of escape analysis and allow us prove `:consistent`-cy or
`:effect_free`-ness even in a presence of accesses or modifications
on local mutable allocations in cases when we can prove they are local
and don't escape. Separate PRs that actually improve the effect analysis
accuracy will follow.
pcjentsch pushed a commit to pcjentsch/julia that referenced this pull request Aug 18, 2022
This is a preparatory PR for future improvements on the effects analysis.
This commit adds the `:inaccessiblememonly` helper effect, that tracks
if a method involves any access or modification on any mutable state.
This effect property is basically same as LLVM's `inaccessiblememonly`
function attribute, except that it only reasons about mutable memory.
This effect property can be considered as a very limited and coarse
version of escape analysis and allow us prove `:consistent`-cy or
`:effect_free`-ness even in a presence of accesses or modifications
on local mutable allocations in cases when we can prove they are local
and don't escape. Separate PRs that actually improve the effect analysis
accuracy will follow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants