diff options
author | Björn Gustavsson <[email protected]> | 2019-01-17 10:42:41 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-01-17 16:42:16 +0100 |
commit | f9ea85611faca82c7494449ddb8bcb1ef1d194cb (patch) | |
tree | 0b619a3d19dca91f13adb599cb27470d54870424 /lib/compiler/test | |
parent | 401bd13ffd39052d4125fbc6fc8360dc08121883 (diff) | |
download | otp-f9ea85611faca82c7494449ddb8bcb1ef1d194cb.tar.gz otp-f9ea85611faca82c7494449ddb8bcb1ef1d194cb.tar.bz2 otp-f9ea85611faca82c7494449ddb8bcb1ef1d194cb.zip |
Make the beam_validator smarter (again)
Needed because of the optimizations in 48f20bd589fa69.
https://bugs.erlang.org/browse/ERL-832
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/beam_validator_SUITE.erl | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/compiler/test/beam_validator_SUITE.erl b/lib/compiler/test/beam_validator_SUITE.erl index 661b48a080..c9df066958 100644 --- a/lib/compiler/test/beam_validator_SUITE.erl +++ b/lib/compiler/test/beam_validator_SUITE.erl @@ -579,14 +579,23 @@ receive_stacked(Config) -> ok. +aliased_types(Config) -> + Seq = lists:seq(1, 5), + 1 = aliased_types_1(Seq, Config), + + {1,1} = aliased_types_2(Seq), + {42,none} = aliased_types_2([]), + + ok. + %% ERL-735: validator failed to track types on aliased registers, rejecting %% legitimate optimizations. %% %% move x0 y0 %% bif hd L1 x0 %% get_hd y0 %% The validator failed to see that y0 was a list -aliased_types(Config) when is_list(Config) -> - Bug = lists:seq(1, 5), +%% +aliased_types_1(Bug, Config) -> if Config =/= [gurka, gaffel] -> %% Pointless branch. _ = hd(Bug), @@ -594,6 +603,17 @@ aliased_types(Config) when is_list(Config) -> hd(Bug) end. +%% ERL-832: validator failed to realize that a Y register was a cons. +aliased_types_2(Bug) -> + Res = case Bug of + [] -> id(42); + _ -> hd(Bug) + end, + {Res,case Bug of + [] -> none; + _ -> hd(Bug) + end}. + %%%------------------------------------------------------------------------- transform_remove(Remove, Module) -> @@ -652,3 +672,6 @@ night(Turned) -> ok. participating(_, _, _, _) -> ok. + +id(I) -> + I. |