diff options
author | John Högberg <[email protected]> | 2019-07-08 14:37:50 +0200 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-07-09 09:35:13 +0200 |
commit | e20015186fa2372793650a98005faf88e6f6e0fa (patch) | |
tree | 0672c9687fa1d3ec7894b415365bb7afda560e72 /lib/compiler/test/beam_ssa_SUITE.erl | |
parent | 7999631c63998cffc07bbcc91dd86cbe709dde5f (diff) | |
download | otp-e20015186fa2372793650a98005faf88e6f6e0fa.tar.gz otp-e20015186fa2372793650a98005faf88e6f6e0fa.tar.bz2 otp-e20015186fa2372793650a98005faf88e6f6e0fa.zip |
compiler: Fix broken 'receive' in try/catch blocks
This fix is rather ugly and tacked-on, but I'm not comfortable
refactoring the pass in an emergency patch.
Diffstat (limited to 'lib/compiler/test/beam_ssa_SUITE.erl')
-rw-r--r-- | lib/compiler/test/beam_ssa_SUITE.erl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/compiler/test/beam_ssa_SUITE.erl b/lib/compiler/test/beam_ssa_SUITE.erl index a741ebbdf9..256bb95559 100644 --- a/lib/compiler/test/beam_ssa_SUITE.erl +++ b/lib/compiler/test/beam_ssa_SUITE.erl @@ -190,6 +190,12 @@ recv(_Config) -> self() ! {[self(),r1],{2,99,<<"data">>}}, {Parent,r1,<<1:32,2:8,99:8,"data">>} = tricky_recv_4(), + %% Test tricky_recv_5/0. + self() ! 1, + a = tricky_recv_5(), + self() ! 2, + b = tricky_recv_5(), + ok. sync_wait_mon({Pid, Ref}, Timeout) -> @@ -295,6 +301,26 @@ tricky_recv_4() -> end, id({Pid,R,Request}). +%% beam_ssa_pre_codegen would accidentally create phi nodes on critical edges +%% when fixing up receives; the call to id/2 can either succeed or land in the +%% catch block, and we added a phi node to its immediate successor. +tricky_recv_5() -> + try + receive + X=1 -> + id(42), + a; + X=2 -> + b + end, + case X of + 1 -> a; + 2 -> b + end + catch + _:_ -> c + end. + maps(_Config) -> {'EXIT',{{badmatch,#{}},_}} = (catch maps_1(any)), ok. |