summaryrefslogtreecommitdiff
path: root/lib/compiler/src/beam_ssa_opt.hrl
diff options
context:
space:
mode:
authorJohn Högberg <john@erlang.org>2019-01-21 07:25:47 +0100
committerJohn Högberg <john@erlang.org>2019-01-24 08:37:37 +0100
commit294d66a295f6c2101fe3c2da630979ad4e736c08 (patch)
tree7a74227c185c69a976bd90b521eddd47d01db5d3 /lib/compiler/src/beam_ssa_opt.hrl
parent1c73a313e72909d054f55e321c1929d2be55ff11 (diff)
downloaderlang-294d66a295f6c2101fe3c2da630979ad4e736c08.tar.gz
compiler: Introduce module-level type optimization
This commit lets the type optimization pass work across functions, tracking return and argument types to eliminate redundant tests.
Diffstat (limited to 'lib/compiler/src/beam_ssa_opt.hrl')
-rw-r--r--lib/compiler/src/beam_ssa_opt.hrl20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_ssa_opt.hrl b/lib/compiler/src/beam_ssa_opt.hrl
index 21a45f562a..37711a6f48 100644
--- a/lib/compiler/src/beam_ssa_opt.hrl
+++ b/lib/compiler/src/beam_ssa_opt.hrl
@@ -27,11 +27,27 @@
%% Whether the function is exported or not; some optimizations may
%% need to be suppressed if it is.
- exported = true :: boolean()}).
+ exported = true :: boolean(),
+
+ %% The inferred types of each argument (as opposed to parameter),
+ %% indexed by call site.
+ %%
+ %% This is more effective than the naive approach of joining into a
+ %% "parameter_type" as we go as it lets us narrow parameter types
+ %% without having to visit all callers on each pass, which helps a lot
+ %% when dealing with co-recursive functions.
+ arg_types = [] :: list(arg_type_map()),
+
+ %% The inferred return type of this function, this is either [type()]
+ %% or [] to note absence.
+ ret_type = [] :: list()}).
+
+-type arg_key() :: {CallerId :: func_id(),
+ CallDst :: beam_ssa:b_var()}.
+-type arg_type_map() :: #{ arg_key() => term() }.
%% Per-function metadata used by various optimization passes to perform
%% module-level optimization. If a function is absent it means that
%% module-level optimization has been turned off for said function.
-
-type func_id() :: beam_ssa:b_local().
-type func_info_db() :: #{ func_id() => #func_info{} }.