diff options
author | Björn Gustavsson <[email protected]> | 2019-05-27 14:16:00 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-05-27 14:16:00 +0200 |
commit | 435a3d3c0495c33df512b3dec87f01e3d721f77f (patch) | |
tree | 440e3a1e120bbe51b7a05bcba07a6b2522b2df48 /lib/compiler/test | |
parent | 4b972d6934a2362e228e1458b0a6b2ca5d6aa6c8 (diff) | |
parent | bfeef8e0c1639ac7d6a35122b8b62a3c2f3575bf (diff) | |
download | otp-435a3d3c0495c33df512b3dec87f01e3d721f77f.tar.gz otp-435a3d3c0495c33df512b3dec87f01e3d721f77f.tar.bz2 otp-435a3d3c0495c33df512b3dec87f01e3d721f77f.zip |
Merge branch 'bjorn/compiler/fix-beam_ssa_dead-patch/OTP-15845' into maint
* bjorn/compiler/fix-beam_ssa_dead-patch/OTP-15845:
Fix unsafe optimizations where guard tests could be removed
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/guard_SUITE.erl | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/compiler/test/guard_SUITE.erl b/lib/compiler/test/guard_SUITE.erl index ed0a56f064..cea7a374cd 100644 --- a/lib/compiler/test/guard_SUITE.erl +++ b/lib/compiler/test/guard_SUITE.erl @@ -35,7 +35,8 @@ basic_andalso_orelse/1,traverse_dcd/1, check_qlc_hrl/1,andalso_semi/1,t_tuple_size/1,binary_part/1, bad_constants/1,bad_guards/1, - guard_in_catch/1,beam_bool_SUITE/1]). + guard_in_catch/1,beam_bool_SUITE/1, + repeated_type_tests/1]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -53,7 +54,8 @@ groups() -> rel_ops,rel_op_combinations, literal_type_tests,basic_andalso_orelse,traverse_dcd, check_qlc_hrl,andalso_semi,t_tuple_size,binary_part, - bad_constants,bad_guards,guard_in_catch,beam_bool_SUITE]}]. + bad_constants,bad_guards,guard_in_catch,beam_bool_SUITE, + repeated_type_tests]}]. init_per_suite(Config) -> test_lib:recompile(?MODULE), @@ -2261,6 +2263,25 @@ maps() -> evidence(#{0 := Charge}) when 0; #{[] => Charge} == #{[] => 42} -> ok. +repeated_type_tests(_Config) -> + binary = repeated_type_test(<<42>>), + bitstring = repeated_type_test(<<1:1>>), + other = repeated_type_test(atom), + ok. + +repeated_type_test(T) -> + %% Test for a bug in beam_ssa_dead. + if is_bitstring(T) -> + if is_binary(T) -> %This test would be optimized away. + binary; + true -> + bitstring + end; + true -> + other + end. + + %% Call this function to turn off constant propagation. id(I) -> I. |