aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-08-09 11:16:09 +0200
committerBjörn Gustavsson <[email protected]>2012-10-09 09:38:19 +0200
commitcda99c83652fca9473eadba2608c14e5feffa0a0 (patch)
tree4227a822e55c264f38a887ecdfc8b191b154b445
parentc3b60f86c622ba6978564aa059d4d881b9549936 (diff)
downloadotp-cda99c83652fca9473eadba2608c14e5feffa0a0.tar.gz
otp-cda99c83652fca9473eadba2608c14e5feffa0a0.tar.bz2
otp-cda99c83652fca9473eadba2608c14e5feffa0a0.zip
beam_utils:live_opt/1: Correct liveness calculation for 'try'
The liveness at the failure label should be ignored, because if there is an exception, all x registers will be killed.
-rw-r--r--lib/compiler/src/beam_utils.erl6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_utils.erl b/lib/compiler/src/beam_utils.erl
index b9c0cd7304..3b24cbfaba 100644
--- a/lib/compiler/src/beam_utils.erl
+++ b/lib/compiler/src/beam_utils.erl
@@ -810,8 +810,10 @@ live_opt([{select_tuple_arity,Src,Fail,{list,List}}=I|Is], Regs0, D, Acc) ->
Regs1 = x_live([Src], Regs0),
Regs = live_join_labels([Fail|List], D, Regs1),
live_opt(Is, Regs, D, [I|Acc]);
-live_opt([{'try',_,Fail}=I|Is], Regs0, D, Acc) ->
- Regs = live_join_label(Fail, D, Regs0),
+live_opt([{'try',_,_}=I|Is], Regs, D, Acc) ->
+ %% If an exeption happens, all x registers will be killed.
+ %% Therefore, we should only base liveness of the code inside
+ %% the try.
live_opt(Is, Regs, D, [I|Acc]);
live_opt([{try_case,_}=I|Is], _, D, Acc) ->
live_opt(Is, live_call(1), D, [I|Acc]);