aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test/core_SUITE.erl
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2018-07-16 15:21:04 +0200
committerBjörn Gustavsson <[email protected]>2018-08-08 13:10:45 +0200
commita2b94643d345505bcee103b114147e3cb962b8ac (patch)
tree77b7405d816b0021d1ebb72f4a5c38d2c76587b4 /lib/compiler/test/core_SUITE.erl
parent212e8b4caa9968d50f0701ce70aa0ebe5b25f1a6 (diff)
downloadotp-a2b94643d345505bcee103b114147e3cb962b8ac.tar.gz
otp-a2b94643d345505bcee103b114147e3cb962b8ac.tar.bz2
otp-a2b94643d345505bcee103b114147e3cb962b8ac.zip
Fix side-effect optimization when compiling from Core Erlang
When an expression is only used for its side effects, we try to remove everything that doesn't tie into a side-effect, but we went a bit too far when we applied the optimization to funs defined in such a context. Consider the following: do letrec 'f'/0 = fun () -> ... whatever ... in call 'side':'effect'(apply 'f'/0()) 'ok' When f/0 is optimized under the assumption that its return value is unused, side:effect/1 will be fed the result of the last side-effecting expression in f/0 instead of its actual result. https://bugs.erlang.org/browse/ERL-658 Co-authored-by: Björn Gustavsson <[email protected]>
Diffstat (limited to 'lib/compiler/test/core_SUITE.erl')
-rw-r--r--lib/compiler/test/core_SUITE.erl5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/compiler/test/core_SUITE.erl b/lib/compiler/test/core_SUITE.erl
index 23f420f5f2..e5611e99d1 100644
--- a/lib/compiler/test/core_SUITE.erl
+++ b/lib/compiler/test/core_SUITE.erl
@@ -29,7 +29,7 @@
bs_shadowed_size_var/1,
cover_v3_kernel_1/1,cover_v3_kernel_2/1,cover_v3_kernel_3/1,
cover_v3_kernel_4/1,cover_v3_kernel_5/1,
- non_variable_apply/1,name_capture/1]).
+ non_variable_apply/1,name_capture/1,fun_letrec_effect/1]).
-include_lib("common_test/include/ct.hrl").
@@ -57,7 +57,7 @@ groups() ->
bs_shadowed_size_var,
cover_v3_kernel_1,cover_v3_kernel_2,cover_v3_kernel_3,
cover_v3_kernel_4,cover_v3_kernel_5,
- non_variable_apply,name_capture
+ non_variable_apply,name_capture,fun_letrec_effect
]}].
@@ -94,6 +94,7 @@ end_per_group(_GroupName, Config) ->
?comp(cover_v3_kernel_5).
?comp(non_variable_apply).
?comp(name_capture).
+?comp(fun_letrec_effect).
try_it(Mod, Conf) ->
Src = filename:join(proplists:get_value(data_dir, Conf),