-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Hook up IR_FLAG_NOTHROW #45752
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
Hook up IR_FLAG_NOTHROW #45752
Conversation
@@ -250,7 +250,7 @@ function setindex!(is::InstructionStream, newval::Instruction, idx::Int) | |||
is.flag[idx] = newval[:flag] | |||
return is | |||
end | |||
function setindex!(is::InstructionStream, newval::AnySSAValue, idx::Int) | |||
function setindex!(is::InstructionStream, newval::Union{AnySSAValue, Nothing}, idx::Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regressed at some point. It's the idiom for deleting and instruction so should work, but yes, it's mostly unrelated to this PR.
@@ -343,7 +343,7 @@ function getindex(x::IRCode, s::SSAValue) | |||
end | |||
end | |||
|
|||
function setindex!(x::IRCode, repl::Union{Instruction, AnySSAValue}, s::SSAValue) | |||
function setindex!(x::IRCode, repl::Union{Instruction, Nothing, AnySSAValue}, s::SSAValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
isa(stmt, Slot) && return (false, false) # Slots shouldn't occur in the IR at this point, but let's be defensive here | ||
if isa(stmt, GlobalRef) | ||
nothrow = isdefined(stmt.mod, stmt.name) | ||
return (nothrow, nothrow) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (nothrow, nothrow) | |
return (nothrow && isconst(stmt.mod, stmt.name), nothrow) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should keep doing what it did before, but probably the total
in the comment is from and it should actually be effect_free. This code predates the clarification of those terms.
end | ||
return true | ||
return (true, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (true, true) | |
return (!ismutabletype(typ), true) |
base/compiler/optimize.jl
Outdated
Returns a tuple of (total, nothrow) for a given statement. | ||
|
||
Determine whether a `stmt` is "side-effect-free", i.e. may be removed if it has no uses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns a tuple of (total, nothrow) for a given statement. | |
Determine whether a `stmt` is "side-effect-free", i.e. may be removed if it has no uses. | |
Returns a tuple of (total, nothrow) for a given statement. |
I added the flag in #45272, but didn't hook it up to the nothrow model. In the fullness of time, these should forwarded from inference and only recomputed if necessary, but for the moment, just make it work.
sgtm |
I added the flag in JuliaLang#45272, but didn't hook it up to the nothrow model. In the fullness of time, these should forwarded from inference and only recomputed if necessary, but for the moment, just make it work.
I added the flag in #45272, but didn't hook it up to the nothrow
model. In the fullness of time, these should forwarded from
inference and only recomputed if necessary, but for the moment,
just make it work.