diff options
author | Björn Gustavsson <[email protected]> | 2018-09-10 15:01:05 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2018-09-12 14:19:05 +0200 |
commit | 5ebd2c4e0a12af57287b0bba390fb226c7209fb1 (patch) | |
tree | 221442944e0b37c6f73c29a156b44d31eb887d02 /lib/compiler/src/beam_ssa.erl | |
parent | b21098e88551580d8ab3a1e7502506e91a950ec4 (diff) | |
download | otp-5ebd2c4e0a12af57287b0bba390fb226c7209fb1.tar.gz otp-5ebd2c4e0a12af57287b0bba390fb226c7209fb1.tar.bz2 otp-5ebd2c4e0a12af57287b0bba390fb226c7209fb1.zip |
beam_ssa: Add trim_unreachable/1
Add trim_unreachable/1 to remove unreachable blocks
and adjust phi nodes.
Diffstat (limited to 'lib/compiler/src/beam_ssa.erl')
-rw-r--r-- | lib/compiler/src/beam_ssa.erl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_ssa.erl b/lib/compiler/src/beam_ssa.erl index 75d567ff87..b0818b1092 100644 --- a/lib/compiler/src/beam_ssa.erl +++ b/lib/compiler/src/beam_ssa.erl @@ -33,6 +33,7 @@ rpo/1,rpo/2, split_blocks/3, successors/1,successors/2, + trim_unreachable/1, update_phi_labels/4,used/1]). -export_type([b_module/0,b_function/0,b_blk/0,b_set/0, @@ -448,6 +449,19 @@ split_blocks(P, Blocks, Count) -> Ls = beam_ssa:rpo(Blocks), split_blocks_1(Ls, P, Blocks, Count). +-spec trim_unreachable(Blocks0) -> Blocks when + Blocks0 :: block_map(), + Blocks :: block_map(). + +%% trim_unreachable(Blocks0) -> Blocks. +%% Remove all unreachable blocks. Adjust all phi nodes so +%% they don't refer to blocks that has been removed or no +%% no longer branch to the phi node in question. + +trim_unreachable(Blocks) -> + %% Could perhaps be optimized if there is any need. + maps:from_list(linearize(Blocks)). + %% update_phi_labels([BlockLabel], Old, New, Blocks0) -> Blocks. %% In the given blocks, replace label Old in with New in all %% phi nodes. This is useful after merging or splitting |