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

Speed up alias analysis #8695

Merged
merged 25 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5c9a929
compiler: Extend sharing status db to handle a sequence of extracts
frej May 2, 2024
08bd121
compiler SSA-checker: Handle succeeded instructions
frej Aug 5, 2024
2680c84
compiler destructive update: Simplify logic in patch_is/5
frej May 29, 2024
31d4302
compiler beam_digraph: Implement del_vertex/2
frej Jun 11, 2024
9c52efd
beam_digraph: Add beam_digraph:vertex/3 analogous to maps:get/3
frej Jun 27, 2024
3ce859c
compiler beam_digraph: Add edges/1
frej Jun 17, 2024
d6d613f
compiler beam_ssa_ss: Improve debug dumps
frej Jun 17, 2024
b332468
compiler beam_ssa_ss: Remove TODO after investigating performance
frej Jul 31, 2024
368a79d
compiler alias analysis: Unify support for debugging dumps
frej Jul 18, 2024
82f52a1
compiler alias analysis: Use beam_ssa_ss:dump/1 for debug printouts
frej Jul 22, 2024
03ea590
compiler alias analysis: Unify printing of function names
frej Jul 22, 2024
105abbd
compiler alias analysis: Speed up beam_ssa_ss:prune()
frej Jun 24, 2024
9c02c78
compiler alias analysis: Avoid variable creation for plain values
frej Jun 28, 2024
6510323
compiler alias analysis: Avoid redundant database changes
frej Jul 1, 2024
b046f24
compiler alias analysis: See through embed-extract chains
frej Jul 23, 2024
e775560
compiler alias analysis: Introduce explicit no_info alias status
frej Jul 23, 2024
b2d8654
compiler alias analysis: Improve fixpoint iteration strategy
frej Jul 22, 2024
4a58947
compiler alias analysis: Analyze zero-arity functions first
frej Jul 23, 2024
a6868d6
compiler alias analysis: Always record call argument status
frej Jul 23, 2024
f4310bc
compiler alias analysis: Status of not analyzed callee is `no_info`
frej Jul 12, 2024
b4f7a6c
compiler alias analysis: Improve handling of Phi-instructions
frej Jul 15, 2024
d0b64a2
compiler alias analysis: Change work limiting strategy
frej Jul 23, 2024
e66fa4d
compiler alias analysis: Alternate function traversal order
frej Jul 23, 2024
ccf5a66
compiler alias analysis: Speed up state pruning
frej Jul 25, 2024
b83561a
compiler: Avoid reuse hint for update_record with > 1 update
frej Jul 24, 2024
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
6 changes: 4 additions & 2 deletions lib/compiler/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ BEAM_H = $(wildcard ../priv/beam_h/*.h)
HRL_FILES= \
beam_asm.hrl \
beam_disasm.hrl \
beam_ssa_alias_debug.hrl \
beam_ssa_opt.hrl \
beam_ssa.hrl \
beam_types.hrl \
Expand Down Expand Up @@ -216,7 +217,8 @@ $(EBIN)/beam_jump.beam: beam_asm.hrl
$(EBIN)/beam_listing.beam: core_parse.hrl beam_ssa.hrl \
beam_asm.hrl beam_types.hrl
$(EBIN)/beam_ssa.beam: beam_ssa.hrl
$(EBIN)/beam_ssa_alias.beam: beam_ssa_opt.hrl beam_types.hrl
$(EBIN)/beam_ssa_alias.beam: beam_ssa_opt.hrl beam_ssa_alias_debug.hrl \
beam_types.hrl
$(EBIN)/beam_ssa_bsm.beam: beam_ssa.hrl
$(EBIN)/beam_ssa_bool.beam: beam_ssa.hrl
$(EBIN)/beam_ssa_check.beam: beam_ssa.hrl beam_types.hrl
Expand All @@ -229,7 +231,7 @@ $(EBIN)/beam_ssa_pp.beam: beam_ssa.hrl beam_types.hrl
$(EBIN)/beam_ssa_pre_codegen.beam: beam_ssa.hrl beam_asm.hrl
$(EBIN)/beam_ssa_recv.beam: beam_ssa.hrl
$(EBIN)/beam_ssa_share.beam: beam_ssa.hrl
$(EBIN)/beam_ssa_ss.beam: beam_ssa.hrl beam_types.hrl
$(EBIN)/beam_ssa_ss.beam: beam_ssa.hrl beam_ssa_alias_debug.hrl beam_types.hrl
$(EBIN)/beam_ssa_throw.beam: beam_ssa.hrl beam_types.hrl
$(EBIN)/beam_ssa_type.beam: beam_ssa.hrl beam_types.hrl
$(EBIN)/beam_trim.beam: beam_asm.hrl
Expand Down
28 changes: 27 additions & 1 deletion lib/compiler/src/beam_digraph.erl
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
-export([new/0,
add_vertex/2, add_vertex/3, add_edge/3, add_edge/4,
del_edge/2, del_edges/2,
del_vertex/2,
edges/1,
foldv/3,
has_vertex/2,
is_path/3,
in_degree/2, in_edges/2, in_neighbours/2,
no_vertices/1,
out_degree/2, out_edges/2, out_neighbours/2,
vertex/2, vertices/1,
vertex/2, vertex/3, vertices/1,
reverse_postorder/2,
roots/1,
topsort/1,
Expand Down Expand Up @@ -76,6 +78,18 @@ add_vertex(Dg, V, Label) ->
Vs = Vs0#{V=>Label},
Dg#dg{vs=Vs}.

-spec del_vertex(graph(), vertex()) -> graph().
del_vertex(Dg, V) ->
#dg{vs=Vs0,in_es=InEsMap0,out_es=OutEsMap0} = Dg,
InEs = maps:get(V, InEsMap0, []),
OutEsMap = foldl(fun({From,_,_}=E, A) -> edge_map_del(From, E, A) end,
maps:remove(V, OutEsMap0), InEs),
OutEs = maps:get(V, OutEsMap0, []),
InEsMap = foldl(fun({_,To,_}=E, A) -> edge_map_del(To, E, A) end,
maps:remove(V, InEsMap0), OutEs),
Vs = maps:remove(V, Vs0),
Dg#dg{vs=Vs,in_es=InEsMap,out_es=OutEsMap}.

-spec add_edge(graph(), vertex(), vertex()) -> graph().
add_edge(Dg, From, To) ->
add_edge(Dg, From, To, edge).
Expand Down Expand Up @@ -176,6 +190,12 @@ no_vertices(#dg{vs=Vs}) ->
vertex(#dg{vs=Vs}, V) ->
map_get(V, Vs).

%% As vertex/2 but if the vertex does not exist a default value is
%% returned.
-spec vertex(graph(), vertex(), label()) -> label().
vertex(#dg{vs=Vs}, V, Default) ->
maps:get(V, Vs, Default).

-spec vertices(graph()) -> [{vertex(), label()}].
vertices(#dg{vs=Vs}) ->
maps:to_list(Vs).
Expand Down Expand Up @@ -217,6 +237,12 @@ topsort(G) ->
Seen = roots(G),
reverse_postorder(G, Seen).

-spec edges(graph()) -> [edge()].
edges(#dg{out_es=OutEsMap}) ->
maps:fold(fun(_, Es, Acc) ->
Es ++ Acc
end, [], OutEsMap).

%%
%% Kosaraju's algorithm
%%
Expand Down
Loading
Loading