Skip to content

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

Merged
merged 1 commit into from
Jun 22, 2022
Merged

Hook up IR_FLAG_NOTHROW #45752

merged 1 commit into from
Jun 22, 2022

Conversation

Keno
Copy link
Member

@Keno Keno commented Jun 19, 2022

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.

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

This change seems unnecessary?

Copy link
Member Author

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)
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return (nothrow, nothrow)
return (nothrow && isconst(stmt.mod, stmt.name), nothrow)

Copy link
Member Author

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)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return (true, true)
return (!ismutabletype(typ), true)

Comment on lines 193 to 195
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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.
@vtjnash
Copy link
Member

vtjnash commented Jun 22, 2022

sgtm

@Keno Keno merged commit a2cc0f4 into master Jun 22, 2022
@Keno Keno deleted the kf/newssa branch June 22, 2022 20:08
pcjentsch pushed a commit to pcjentsch/julia that referenced this pull request Aug 18, 2022
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.
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.

3 participants