aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-11-29 07:41:23 +0100
committerBjörn Gustavsson <[email protected]>2017-11-30 11:40:26 +0100
commit93fde6744a0c94c2d31f99cb1f9019ff6e98f83d (patch)
tree8bd2dd31bfe96fc7eb108893973027fda80235a4
parentfadc3d671d2edcf15b87719f350451c32c1f4bbb (diff)
downloadotp-93fde6744a0c94c2d31f99cb1f9019ff6e98f83d.tar.gz
otp-93fde6744a0c94c2d31f99cb1f9019ff6e98f83d.tar.bz2
otp-93fde6744a0c94c2d31f99cb1f9019ff6e98f83d.zip
Clean up collection of basic blocks
-rw-r--r--lib/compiler/src/v3_codegen.erl24
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/compiler/src/v3_codegen.erl b/lib/compiler/src/v3_codegen.erl
index 535c0679d8..2f81910e59 100644
--- a/lib/compiler/src/v3_codegen.erl
+++ b/lib/compiler/src/v3_codegen.erl
@@ -679,28 +679,26 @@ basic_block([Ke|Kes], Acc) ->
no_block -> {reverse(Acc, [Ke]),Kes}
end.
-%% #k_put{} instructions that may garbage collect are not allowed in basic blocks.
-
-collect_block(#k_put{arg=#k_binary{}}) ->
- no_block;
-collect_block(#k_put{arg=#k_map{}}) ->
- no_block;
-collect_block(#k_put{}) ->
- include;
-collect_block(#k_call{op=#k_var{}=Var,args=As}) ->
- {block_end,As++[Var]};
+collect_block(#k_put{arg=Arg}) ->
+ %% #k_put{} instructions that may garbage collect are not allowed
+ %% in basic blocks.
+ case Arg of
+ #k_binary{} -> no_block;
+ #k_map{} -> no_block;
+ _ -> include
+ end;
collect_block(#k_call{op=Func,args=As}) ->
{block_end,As++func_vars(Func)};
-collect_block(#k_enter{op=#k_var{}=Var,args=As}) ->
- {block_end,As++[Var]};
collect_block(#k_enter{op=Func,args=As}) ->
{block_end,As++func_vars(Func)};
collect_block(#k_return{args=Rs}) ->
{block_end,Rs};
collect_block(#k_break{args=Bs}) ->
{block_end,Bs};
-collect_block(_) -> no_block.
+collect_block(_) -> no_block.
+func_vars(#k_var{}=Var) ->
+ [Var];
func_vars(#k_remote{mod=M,name=F})
when is_record(M, k_var); is_record(F, k_var) ->
[M,F];