diff options
author | Björn Gustavsson <[email protected]> | 2018-12-18 12:59:38 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2019-01-07 12:55:26 +0100 |
commit | 7a01269e62f21ac3ba9858dd358716081549bea3 (patch) | |
tree | fb11fe61a52e2f1b3dd1801491646d773c90b42a /lib/compiler/test | |
parent | f0ea49125815ec9197ffb6c74e20ebb5f10732d4 (diff) | |
download | otp-7a01269e62f21ac3ba9858dd358716081549bea3.tar.gz otp-7a01269e62f21ac3ba9858dd358716081549bea3.tar.bz2 otp-7a01269e62f21ac3ba9858dd358716081549bea3.zip |
Remove unsafe optimization for delaying creation of stackframe
b89044a800c4 introduced an optimization that tries to delay creation
of stack frames. It turns out that this optimization is not always
safe. (See the new test case for an example.)
Since the code generator is completely rewritten in the `master`
branch for the upcoming OTP 22 release, it does not make sense trying
to mend this optimization. It is better to remove it. Out of a sample
of about 1000 modules in OTP, about 50 of them are changed as a result
of removing this optimization.
The compiler in OTP 22 will do the same optimization in a cleaner,
safer, and more effective way.
https://bugs.erlang.org/browse/ERL-807
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/match_SUITE.erl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/compiler/test/match_SUITE.erl b/lib/compiler/test/match_SUITE.erl index e3f842b668..72e5356a8d 100644 --- a/lib/compiler/test/match_SUITE.erl +++ b/lib/compiler/test/match_SUITE.erl @@ -378,6 +378,13 @@ untuplify(Config) when is_list(Config) -> %% We do this to cover sys_core_fold:unalias_pat/1. {1,2,3,4,alias,{[1,2],{3,4},alias}} = untuplify_1([1,2], {3,4}, alias), error = untuplify_1([1,2], {3,4}, 42), + + %% Test that a previous bug in v3_codegen is gone. (The sinking of + %% stack frames into only the case arms that needed them was not always + %% safe.) + [33, -1, -33, 1] = untuplify_2(32, 65), + {33, 1, -33, -1} = untuplify_2(65, 32), + ok. untuplify_1(A, B, C) -> @@ -390,6 +397,21 @@ untuplify_1(A, B, C) -> error end. +untuplify_2(V1, V2) -> + {D1,D2,D3,D4} = + if V1 > V2 -> + %% The 1 value was overwritten by the value of V2-V1. + {V1-V2, 1, V2-V1, -1}; + true -> + {V2-V1, -1, V1-V2, 1} + end, + if + D2 > D4 -> + {D1, D2, D3, D4}; + true -> + [D1, D2, D3, D4] + end. + %% Coverage of beam_dead:shortcut_boolean_label/4. shortcut_boolean(Config) when is_list(Config) -> false = shortcut_boolean_1([0]), |