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

optimizer: minor refactor try_compute_fieldidx_expr #42025

Merged
merged 1 commit into from
Aug 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions base/compiler/ssair/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ struct SSADefUse
end
SSADefUse() = SSADefUse(Int[], Int[], Int[])

function try_compute_fieldidx_expr(@nospecialize(typ), @nospecialize(use_expr))
field = use_expr.args[3]
try_compute_fieldidx_expr(typ::DataType, expr::Expr) = try_compute_fieldidx_args(typ, expr.args)
function try_compute_fieldidx_args(typ::DataType, args::Vector{Any})
field = args[3]
isa(field, QuoteNode) && (field = field.value)
isa(field, Union{Int, Symbol}) || return nothing
return try_compute_fieldidx(typ, field)
Expand Down Expand Up @@ -792,6 +793,7 @@ function getfield_elim_pass!(ir::IRCode)
# Could still end up here if we tried to setfield! and immutable, which would
# error at runtime, but is not illegal to have in the IR.
ismutabletype(typ) || continue
typ = typ::DataType
# Partition defuses by field
fielddefuse = SSADefUse[SSADefUse() for _ = 1:fieldcount(typ)]
ok = true
Expand Down
1 change: 0 additions & 1 deletion base/compiler/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ mutable struct InferenceResult
end
end


"""
OptimizationParams

Expand Down