diff options
author | Björn Gustavsson <[email protected]> | 2016-05-24 09:28:32 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-05-25 16:41:26 +0200 |
commit | ca368c8503712dce0044201bf25323ace3372a62 (patch) | |
tree | 98b8ce9fb96a1ede798df2022f58157409f789f1 /lib/compiler/src | |
parent | bb468eab3064d1e8bec5d6c6f53c60ccce2c9dc2 (diff) | |
download | otp-ca368c8503712dce0044201bf25323ace3372a62.tar.gz otp-ca368c8503712dce0044201bf25323ace3372a62.tar.bz2 otp-ca368c8503712dce0044201bf25323ace3372a62.zip |
v3_codegen: Correct code generation for an error/1 call in a guard
Sometimes v3_codegen would generate unsafe code when there was
a call to error/1 in a guard.
Diffstat (limited to 'lib/compiler/src')
-rw-r--r-- | lib/compiler/src/v3_codegen.erl | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/compiler/src/v3_codegen.erl b/lib/compiler/src/v3_codegen.erl index f531056591..45403338b4 100644 --- a/lib/compiler/src/v3_codegen.erl +++ b/lib/compiler/src/v3_codegen.erl @@ -1155,19 +1155,15 @@ call_cg(Func, As, Rs, Le, Vdb, Bef, St0) -> %% Inside a guard. The only allowed function call is to %% erlang:error/1,2. We will generate the following code: %% - %% jump FailureLabel %% move {atom,ok} DestReg - %% - %% The 'move' instruction will never be executed, but we - %% generate it anyway in case the beam_validator is run - %% on unoptimized code. + %% jump FailureLabel {remote,{atom,erlang},{atom,error}} = Func, %Assertion. [{var,DestVar}] = Rs, Int0 = clear_dead(Bef, Le#l.i, Vdb), Reg = put_reg(DestVar, Int0#sr.reg), Int = Int0#sr{reg=Reg}, Dst = fetch_reg(DestVar, Reg), - {[{jump,{f,Fail}},{move,{atom,ok},Dst}], + {[{move,{atom,ok},Dst},{jump,{f,Fail}}], clear_dead(Int, Le#l.i, Vdb),St0}; #cg{} -> %% Ordinary function call in a function body. |