-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Mutation of Ref
embedded in Expr treated as effect-free
#52843
Comments
It's quite likely we are missing a julia> @code_lowered bar()
CodeInfo(
1 ─ Base.setindex!(Base.RefValue{Int64}(0), 1)
│ Main.nothing
└── return Main.nothing
) |
QuoteNode is not expected in IR for self-quoting values |
Then this is purely an effects bug. I, and I think @vchuravy talked a bit about this in #52536. But basically it doesn't make sense for a caller to inherit Specifically I think julia/base/compiler/typeinfer.jl Lines 471 to 475 in 0c46852
What I noticed is that we never refine INACCESSIBLEMEM_OR_ARGMEMONLY to ALWAYS_FALSE , the caller then inherits it (which is weird) and if the caller has no mutable arguments we refine to ALWAYS_TRUE , which then allows CONSISTENT_IF_INACCESSIBLEMEMONLY to be refined. This makes a function that calls something that is ?c,?m to be c,m
|
While talking with @topolarity we were thinking that our current memory effects are a bit weird, which makes analyzing them even weirder. I think they were initially sort of inspired by LLVMs semantics, and maybe we should take that inspiration again. Currentyl we have
|
We have more precise memory information in the escape analysis cache. The effects are just an over approximation of this information that people added because it was quick to check. |
This diff fixes the issue, but the resulting precision loss breaks a lot of tests. We'll probably have to do a compensating dataflow analysis to recover the flag in the common cases.
|
The way that Would it not work to walk the IR stmts and taint |
@topolarity Right. This is another instance of #52531, and the easiest fix would be: diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl
index 3701fa8cf9..c5cb4698ca 100644
--- a/base/compiler/abstractinterpretation.jl
+++ b/base/compiler/abstractinterpretation.jl
@@ -2335,8 +2335,8 @@ function abstract_eval_special_value(interp::AbstractInterpreter, @nospecialize(
elseif isa(e, GlobalRef)
return abstract_eval_globalref(interp, e, sv)
end
-
- return RTEffects(Const(e), Union{}, EFFECTS_TOTAL)
+ return RTEffects(Const(e), Union{}, Effects(EFFECTS_TOTAL;
+ inaccessiblememonly = is_mutation_free_argtype(typeof(e)) ? ALWAYS_TRUE : ALWAYS_FALSE))
end
function abstract_eval_value_expr(interp::AbstractInterpreter, e::Expr, sv::AbsIntState) |
The deviation from LLVM's |
Yeah, I agree. Will make a PR. |
All values are self-quoting except for |
Does that mean we can update these functions to match? julia/base/compiler/utilities.jl Lines 69 to 76 in 9c78420
|
…edded to IR Fixes another variant of JuliaLang#52531.
MWE in 1.10:
Correct output in 1.9:
Appears to be another variant of #52531
The text was updated successfully, but these errors were encountered: