From 2b03fbacf1ac0c06a84439baac90d418916a1778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 26 Nov 2010 11:47:50 +0100 Subject: beam_utils: Fix check_liveness/3 for receive loops Sometimes the beam_bool pass wants to know whether an y register will be killed by the code that follows and will do (effectively): beam_utils:is_killed({y,Y}, Code, L) When asked to calculate the liveness for an y register, beam_utils:is_killed/3 will loop forever if the code includes a receive loop. Since this rarely occurs, fix the problem in the simplest and most conservative way. Reported-by: Christopher Williams --- lib/compiler/src/beam_utils.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/compiler/src') diff --git a/lib/compiler/src/beam_utils.erl b/lib/compiler/src/beam_utils.erl index dc8079d0b7..45cdf8a659 100644 --- a/lib/compiler/src/beam_utils.erl +++ b/lib/compiler/src/beam_utils.erl @@ -489,10 +489,13 @@ check_liveness(R, [{bs_context_to_binary,S}|Is], St) -> S -> {used,St}; _ -> check_liveness(R, Is, St) end; -check_liveness(R, [{loop_rec,{f,_},{x,0}}|Is], St) -> +check_liveness(R, [{loop_rec,{f,_},{x,0}}|_], St) -> case R of - {x,_} -> {killed,St}; - _ -> check_liveness(R, Is, St) + {x,_} -> + {killed,St}; + _ -> + %% y register. Rarely happens. Be very conversative. + {unknown,St} end; check_liveness(R, [{loop_rec_end,{f,Fail}}|_], St) -> check_liveness_at(R, Fail, St); -- cgit v1.2.3