From 203fdc9d70d41efd3e16ea4e0bacedb647d70ac9 Mon Sep 17 00:00:00 2001 From: Frej Drejhammar Date: Tue, 23 Jul 2024 14:11:12 +0200 Subject: [PATCH] compiler alias analysis: Alternate function traversal order Sharing state information flows from callers to callees for function arguments, and from callees to callers for results. Previously callers were always analyzed before callees, but it turns out that the alias analysis converges faster if the traversal order is alternated between caller-callee and callee-caller. --- lib/compiler/src/beam_ssa_alias.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/compiler/src/beam_ssa_alias.erl b/lib/compiler/src/beam_ssa_alias.erl index aab967b76897..0f9e407949d7 100644 --- a/lib/compiler/src/beam_ssa_alias.erl +++ b/lib/compiler/src/beam_ssa_alias.erl @@ -354,7 +354,7 @@ aa_fixpoint(Funs, AAS=#aas{func_db=FuncDb}) -> Order = aa_order(Funs, FuncDb), ?DP("Traversal order:~n ~s~n", [string:join([fn(F) || F <- Order], ",\n ")]), - aa_fixpoint(Order, Order, AAS, 1). + aa_fixpoint(Order, reverse(Order), AAS, 1). aa_fixpoint([F|Fs], Order, AAS0=#aas{func_db=FuncDb,st_map=StMap, @@ -388,7 +388,7 @@ aa_fixpoint([], Order, #aas{func_db=FuncDb,repeats=Repeats}=AAS, NoofIters) -> {StMap, FuncDb}; NewOrder -> ?DP("**** Starting traversal ~p ****~n", [NoofIters + 1]), - aa_fixpoint(NewOrder, Order, + aa_fixpoint(NewOrder, reverse(Order), AAS#aas{repeats=sets:new()}, NoofIters + 1) end.