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

allow destructive inlining only when the source is volatile #52062

Merged
merged 1 commit into from
Nov 8, 2023
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
2 changes: 1 addition & 1 deletion base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ function resolve_todo(mi::MethodInstance, result::Union{Nothing,InferenceResult,
elseif isa(result, VolatileInferenceResult)
inferred_result = get_local_result(result.inf_result)
# volatile inference result can be inlined destructively
preserve_local_sources = OptimizationParams(state.interp).preserve_local_sources
preserve_local_sources = !result.inf_result.is_src_volatile | OptimizationParams(state.interp).preserve_local_sources
else
inferred_result = get_cached_result(state, mi)
end
Expand Down
2 changes: 2 additions & 0 deletions base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ function transform_result_for_cache(interp::AbstractInterpreter,
linfo::MethodInstance, valid_worlds::WorldRange, result::InferenceResult)
inferred_result = result.src
if inferred_result isa CodeInfo
uncompressed = inferred_result
inferred_result = maybe_compress_codeinfo(interp, linfo, inferred_result)
result.is_src_volatile |= uncompressed !== inferred_result
end
# The global cache can only handle objects that codegen understands
if !isa(inferred_result, MaybeCompressed)
Expand Down
3 changes: 2 additions & 1 deletion base/compiler/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ mutable struct InferenceResult
ipo_effects::Effects # if inference is finished
effects::Effects # if optimization is finished
argescapes # ::ArgEscapeCache if optimized, nothing otherwise
is_src_volatile::Bool # `src` has been cached globally as the compressed format already, allowing `src` to be used destructively
function InferenceResult(linfo::MethodInstance, cache_argtypes::Vector{Any}, overridden_by_const::BitVector)
# def = linfo.def
# nargs = def isa Method ? Int(def.nargs) : 0
# @assert length(cache_argtypes) == nargs
return new(linfo, cache_argtypes, overridden_by_const, nothing, nothing,
WorldRange(), Effects(), Effects(), nothing)
WorldRange(), Effects(), Effects(), nothing, false)
end
end
InferenceResult(linfo::MethodInstance, 𝕃::AbstractLattice=fallback_lattice) =
Expand Down