Skip to content

Commit

Permalink
EA: remove no longer used is_ipo_profitable (JuliaLang#51391)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored and pull[bot] committed Feb 7, 2024
1 parent 9ed82a2 commit c084718
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 28 deletions.
23 changes: 0 additions & 23 deletions base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -583,29 +583,6 @@ function ArgEscapeCache(estate::EscapeState)
return ArgEscapeCache(argescapes, argaliases)
end

"""
is_ipo_profitable(ir::IRCode, nargs::Int) -> Bool
Heuristically checks if there is any profitability to run the escape analysis on `ir`
and generate IPO escape information cache. Specifically, this function examines
if any call argument is "interesting" in terms of their escapability.
"""
function is_ipo_profitable(ir::IRCode, nargs::Int)
for i = 1:nargs
t = unwrap_unionall(widenconst(ir.argtypes[i]))
t <: IO && return false # bail out IO-related functions
is_ipo_profitable_type(t) && return true
end
return false
end
function is_ipo_profitable_type(@nospecialize t)
if isa(t, Union)
return is_ipo_profitable_type(t.a) && is_ipo_profitable_type(t.b)
end
(t === String || t === Symbol || t === Module || t === SimpleVector) && return false
return ismutabletype(t)
end

abstract type Change end
struct EscapeChange <: Change
xidx::Int
Expand Down
4 changes: 0 additions & 4 deletions doc/src/devdocs/EscapeAnalysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,10 @@ non-inlined callees that has been derived by previous `IPO EA`.
More interestingly, it is also valid to use `IPO EA` escape information for type inference,
e.g., inference accuracy can be improved by forming `Const`/`PartialStruct`/`MustAlias` of mutable object.

Since the computational cost of `analyze_escapes` is not that cheap,
both `IPO EA` and `Local EA` are better to run only when there is any profitability.
Currently `EscapeAnalysis` provides the `is_ipo_profitable` heuristic to check a profitability of `IPO EA`.
```@docs
Core.Compiler.EscapeAnalysis.analyze_escapes
Core.Compiler.EscapeAnalysis.EscapeState
Core.Compiler.EscapeAnalysis.EscapeInfo
Core.Compiler.EscapeAnalysis.is_ipo_profitable
```

--------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion test/compiler/EscapeAnalysis/EAUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ using .CC:
InferenceResult, OptimizationState, IRCode, copy as cccopy,
@timeit, convert_to_ircode, slot2reg, compact!, ssa_inlining_pass!, sroa_pass!,
adce_pass!, JLOptions, verify_ir, verify_linetable
using .EA: analyze_escapes, ArgEscapeCache, EscapeInfo, EscapeState, is_ipo_profitable
using .EA: analyze_escapes, ArgEscapeCache, EscapeInfo, EscapeState

struct CodeCache
cache::IdDict{MethodInstance,CodeInstance}
Expand Down

0 comments on commit c084718

Please sign in to comment.