diff options
author | Sverker Eriksson <[email protected]> | 2017-03-28 15:01:09 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2017-03-28 15:01:09 +0200 |
commit | 1ec9366f468026a216c1c8cd78c7f512bae37ae5 (patch) | |
tree | 0803f40e7f6ddb5b98fc368f92650277cd924dc7 /lib/hipe/test/basic_SUITE_data/basic_bugs_hipe.erl | |
parent | deaa890b3da0be617c9f62c968ba829c146fb2d6 (diff) | |
parent | af3f9ca6fa5b207e7619590723f80002d82a013a (diff) | |
download | otp-1ec9366f468026a216c1c8cd78c7f512bae37ae5.tar.gz otp-1ec9366f468026a216c1c8cd78c7f512bae37ae5.tar.bz2 otp-1ec9366f468026a216c1c8cd78c7f512bae37ae5.zip |
Merge PR-1392 from margnus1/hipe-range-fixpoint-bug OTP-14306
HiPE: Fix ERL-278: Fix range analysis miscompilation bug
Diffstat (limited to 'lib/hipe/test/basic_SUITE_data/basic_bugs_hipe.erl')
-rw-r--r-- | lib/hipe/test/basic_SUITE_data/basic_bugs_hipe.erl | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/hipe/test/basic_SUITE_data/basic_bugs_hipe.erl b/lib/hipe/test/basic_SUITE_data/basic_bugs_hipe.erl index caa0e71d0b..430e097b91 100644 --- a/lib/hipe/test/basic_SUITE_data/basic_bugs_hipe.erl +++ b/lib/hipe/test/basic_SUITE_data/basic_bugs_hipe.erl @@ -18,6 +18,7 @@ test() -> ok = test_R12B5_seg_fault(), ok = test_switch_neg_int(), ok = test_icode_range_anal(), + ok = test_icode_range_call(), ok. %%----------------------------------------------------------------------- @@ -461,3 +462,44 @@ g(X, Z) -> test -> non_zero_test; other -> other end. + +%%----------------------------------------------------------------------- +%% From: Rich Neswold +%% Date: Oct 5, 2016 +%% +%% The following was a bug in the HiPE compiler's range analysis. The +%% function range_client/2 below would would not stop when N reached 0, +%% but keep recursing into the second clause forever. +%% +%% The problem turned out to be in hipe_icode_range:analyse_call/2, +%% which would note update the argument ranges of the callee if the +%% result of the call was ignored. +%% ----------------------------------------------------------------------- +-define(TIMEOUT, 42). + +test_icode_range_call() -> + Self = self(), + Client = spawn_link(fun() -> range_client(Self, 4) end), + range_server(4, Client). + +range_server(0, _Client) -> + receive + stopping -> ok; + {called_with, 0} -> error(failure) + after ?TIMEOUT -> error(timeout) + end; +range_server(N, Client) -> + receive + {called_with, N} -> + Client ! proceed + after ?TIMEOUT -> error(timeout) + end, + range_server(N-1, Client). % tailcall (so the bug does not affect it) + +range_client(Server, 0) -> + Server ! stopping; +range_client(Server, N) -> + Server ! {called_with, N}, + receive proceed -> ok end, + range_client(Server, N - 1), % non-tailrecursive call with ignored result + ok. |