Skip to content

Commit

Permalink
cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Dec 25, 2021
1 parent 8bb874f commit 813163f
Showing 1 changed file with 24 additions and 34 deletions.
58 changes: 24 additions & 34 deletions src/EscapeAnalysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,8 @@ const _TOP_MOD = ccall(:jl_base_relative_to, Any, (Any,), EscapeAnalysis)::Modul
import ._TOP_MOD: ==
# usings
import Core:
MethodInstance,
Const,
Argument,
SSAValue,
PiNode,
PhiNode,
UpsilonNode,
PhiCNode,
ReturnNode,
GotoNode,
GotoIfNot,
SimpleVector
MethodInstance, Const, Argument, SSAValue, PiNode, PhiNode, UpsilonNode, PhiCNode,
ReturnNode, GotoNode, GotoIfNot, SimpleVector
import ._TOP_MOD: # Base definitions
@eval, @assert, @nospecialize, @__MODULE__, Vector, BitSet, IdDict,
!, !==, , +, -, , &, |, include, error, missing, println,
Expand Down Expand Up @@ -364,28 +354,6 @@ function escape_val!(ir::IRCode, pc::Int, x, state::EscapeState, changes::Change
end
end

function escape_call!(ir::IRCode, pc::Int, args::Vector{Any},
state::EscapeState, changes::Changes)
ft = argextype(first(args), ir, ir.sptypes, ir.argtypes)
f = singleton_type(ft)
if isa(f, Core.IntrinsicFunction)
return false # COMBAK we may break soundness here, e.g. `pointerref`
end
result = escape_builtin!(f, ir, pc, args, state, changes)
if result === false
return false # nothing to propagate
elseif result === missing
# if this call hasn't been handled by any of pre-defined handlers,
# we escape this call conservatively
for i in 2:length(args)
add_change!(args[i], ir, AllEscape(), changes)
end
return true
else
return true
end
end

function escape_invoke!(ir::IRCode, pc::Int, args::Vector{Any},
state::EscapeState, changes::Changes)
linfo = first(args)::MethodInstance
Expand Down Expand Up @@ -472,6 +440,28 @@ end
# TODO implement more builtins, make them more accurate
# TODO use `T_IFUNC`-like logic and don't not abuse dispatch ?

function escape_call!(ir::IRCode, pc::Int, args::Vector{Any},
state::EscapeState, changes::Changes)
ft = argextype(first(args), ir, ir.sptypes, ir.argtypes)
f = singleton_type(ft)
if isa(f, Core.IntrinsicFunction)
return false # COMBAK we may break soundness here, e.g. `pointerref`
end
result = escape_builtin!(f, ir, pc, args, state, changes)
if result === false
return false # nothing to propagate
elseif result === missing
# if this call hasn't been handled by any of pre-defined handlers,
# we escape this call conservatively
for i in 2:length(args)
add_change!(args[i], ir, AllEscape(), changes)
end
return true
else
return true
end
end

escape_builtin!(@nospecialize(f), _...) = return missing

# safe builtins
Expand Down

0 comments on commit 813163f

Please sign in to comment.