From 992a1f18934f071858b5e87f32bda5b49bed637d Mon Sep 17 00:00:00 2001 From: Kostis Sagonas Date: Mon, 11 Jun 2018 17:47:37 +0200 Subject: Fix a crash ih HoPE's lazy code motion pass Some change in the BEAM compiler resulted in the creation of basic blocks that differed from those previously created by the compiler. As a result, the lazy code motion pass of RTL crashed when compiling some of the new code. Crashes were privately reported by @richcarl. --- lib/hipe/rtl/hipe_rtl_lcm.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/hipe/rtl/hipe_rtl_lcm.erl') diff --git a/lib/hipe/rtl/hipe_rtl_lcm.erl b/lib/hipe/rtl/hipe_rtl_lcm.erl index af39c9a0a4..2c8cc80e56 100644 --- a/lib/hipe/rtl/hipe_rtl_lcm.erl +++ b/lib/hipe/rtl/hipe_rtl_lcm.erl @@ -267,14 +267,17 @@ try_insert_expr_last(CFG0, Label, Instr) -> %% with the new code inserted second to last (assuming the last expression %% is a branch operation). insert_expr_last_work(_Instr, [#call{}]) -> - %% Call instructions clobber all expressions; we musn't insert the expression - %% before it + %% Call instructions clobber all expressions; we must not insert the + %% expression before it not_safe; insert_expr_last_work(Instr, [Code1]) -> %% We insert the code next to last. [Instr, Code1]; insert_expr_last_work(Instr, [Code|Codes]) -> - [Code|insert_expr_last_work(Instr, Codes)]. + case insert_expr_last_work(Instr, Codes) of + not_safe -> not_safe; + NewCodes -> [Code|NewCodes] + end. %%============================================================================= %% Inserts expression first in the block for the given label. -- cgit v1.2.3