aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_ssa_pre_codegen.erl
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-01-24 08:52:21 +0100
committerGitHub <[email protected]>2019-01-24 08:52:21 +0100
commita0104bc16c8c6f57c2725d07b811bf3bcb0a2455 (patch)
tree02ea5e7585b66c04c3d775b42f8ccfa9a68a6d8b /lib/compiler/src/beam_ssa_pre_codegen.erl
parent5a9adb7b9b600fc2a406e677a673047045a494d8 (diff)
parent294d66a295f6c2101fe3c2da630979ad4e736c08 (diff)
downloadotp-a0104bc16c8c6f57c2725d07b811bf3bcb0a2455.tar.gz
otp-a0104bc16c8c6f57c2725d07b811bf3bcb0a2455.tar.bz2
otp-a0104bc16c8c6f57c2725d07b811bf3bcb0a2455.zip
Merge pull request #2100 from jhogberg/john/compiler/module-type-optimization
Apply type optimizations across local function calls
Diffstat (limited to 'lib/compiler/src/beam_ssa_pre_codegen.erl')
-rw-r--r--lib/compiler/src/beam_ssa_pre_codegen.erl8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_ssa_pre_codegen.erl b/lib/compiler/src/beam_ssa_pre_codegen.erl
index 39b778f174..9b2bb65911 100644
--- a/lib/compiler/src/beam_ssa_pre_codegen.erl
+++ b/lib/compiler/src/beam_ssa_pre_codegen.erl
@@ -1031,7 +1031,7 @@ need_frame_1([#b_set{op=call,args=[Func|_]}|Is], Context) ->
case Func of
#b_remote{mod=#b_literal{val=Mod},
name=#b_literal{val=Name},
- arity=Arity} ->
+ arity=Arity} when is_atom(Mod), is_atom(Name) ->
case erl_bifs:is_exit_bif(Mod, Name, Arity) of
true ->
false;
@@ -1993,6 +1993,12 @@ reserve_zregs(Blocks, Intervals, Res) ->
end,
beam_ssa:fold_rpo(F, [0], Res, Blocks).
+reserve_zreg([#b_set{op=call,dst=Dst}],
+ #b_br{bool=Dst}, _ShortLived, A) ->
+ %% If type optimization has determined that the result of a call can be
+ %% used directly in a branch, we must avoid reserving a z register or code
+ %% generation will fail.
+ A;
reserve_zreg([#b_set{op={bif,tuple_size},dst=Dst},
#b_set{op={bif,'=:='},args=[Dst,Val]}], Last, ShortLived, A0) ->
case {Val,Last} of