From c084718de1d198eefc908db2febcc36f4c1b1790 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com> Date: Wed, 20 Sep 2023 00:46:37 +0900 Subject: [PATCH] EA: remove no longer used `is_ipo_profitable` (#51391) --- .../ssair/EscapeAnalysis/EscapeAnalysis.jl | 23 ------------------- doc/src/devdocs/EscapeAnalysis.md | 4 ---- test/compiler/EscapeAnalysis/EAUtils.jl | 2 +- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl b/base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl index a62d2637b54044..ba7d068ae70eee 100644 --- a/base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl +++ b/base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl @@ -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 diff --git a/doc/src/devdocs/EscapeAnalysis.md b/doc/src/devdocs/EscapeAnalysis.md index fd4373410dbe37..ed91ee64e8bdcc 100644 --- a/doc/src/devdocs/EscapeAnalysis.md +++ b/doc/src/devdocs/EscapeAnalysis.md @@ -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 ``` -------------------------------------------------------------------------------------------- diff --git a/test/compiler/EscapeAnalysis/EAUtils.jl b/test/compiler/EscapeAnalysis/EAUtils.jl index 3bcace92a78526..e043d035c97dd0 100644 --- a/test/compiler/EscapeAnalysis/EAUtils.jl +++ b/test/compiler/EscapeAnalysis/EAUtils.jl @@ -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}