aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2010-03-17 16:09:48 +0100
committerBjörn Gustavsson <[email protected]>2010-03-26 08:03:43 +0100
commit57cb16f84fd21443d3ad9951473f1e0960c6a26e (patch)
tree801e776035fb15ef2d53b6f242d1a6a5e3174129 /lib
parente2074da57e6dd9b68a39ae71771b28c8f704196f (diff)
downloadotp-57cb16f84fd21443d3ad9951473f1e0960c6a26e.tar.gz
otp-57cb16f84fd21443d3ad9951473f1e0960c6a26e.tar.bz2
otp-57cb16f84fd21443d3ad9951473f1e0960c6a26e.zip
compiler: Suppress bs_context_to_binary/1 for a literal operand
The inliner can cause illegal uses of the bs_context_to_binary/1 instruction, such as: bs_context_to_binary {literal,"string"} or bs_context_to_binary {integer,1} Remove the bs_context_to_binary/1 instruction if the operand is not a register (it is clearly not needed).
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/src/v3_codegen.erl11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/compiler/src/v3_codegen.erl b/lib/compiler/src/v3_codegen.erl
index 1f05b4f6b4..948937c438 100644
--- a/lib/compiler/src/v3_codegen.erl
+++ b/lib/compiler/src/v3_codegen.erl
@@ -1190,7 +1190,12 @@ trap_bif(_, _, _) -> false.
bif_cg(bs_context_to_binary=Instr, [Src0], [], Le, Vdb, Bef, St0) ->
[Src] = cg_reg_args([Src0], Bef),
- {[{Instr,Src}],clear_dead(Bef, Le#l.i, Vdb), St0};
+ case is_register(Src) of
+ false ->
+ {[],clear_dead(Bef, Le#l.i, Vdb), St0};
+ true ->
+ {[{Instr,Src}],clear_dead(Bef, Le#l.i, Vdb), St0}
+ end;
bif_cg(dsetelement, [Index0,Tuple0,New0], _Rs, Le, Vdb, Bef, St0) ->
[New,Tuple,{integer,Index1}] = cg_reg_args([New0,Tuple0,Index0], Bef),
Index = Index1-1,
@@ -2019,6 +2024,10 @@ fetch_stack(V, [_|Stk], I) -> fetch_stack(V, Stk, I+1).
on_stack(V, Stk) -> keymember(V, 1, Stk).
+is_register({x,_}) -> true;
+is_register({yy,_}) -> true;
+is_register(_) -> false.
+
%% put_catch(CatchTag, Stack) -> Stack'
%% drop_catch(CatchTag, Stack) -> Stack'
%% Special interface for putting and removing catch tags, to ensure that