aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-03-14 10:11:40 +0100
committerBjörn Gustavsson <[email protected]>2013-03-19 15:08:45 +0100
commitf70f8f549bc0adca05f89e860b87dccd20a1e086 (patch)
tree2e10724fc9415656930de73a4dd0db5b1299d4c3 /lib/compiler/test
parente5df75bfc94662ffe9c36e0b1643cef0104586e0 (diff)
downloadotp-f70f8f549bc0adca05f89e860b87dccd20a1e086.tar.gz
otp-f70f8f549bc0adca05f89e860b87dccd20a1e086.tar.bz2
otp-f70f8f549bc0adca05f89e860b87dccd20a1e086.zip
Fix slow compilation of complex guards
beam_utils:is_not_used_at/3 could be very slow for complex guards, because the cached result for previously encountered labels were neither used nor updated within blocks. Reported-by: Magnus Müller
Diffstat (limited to 'lib/compiler/test')
-rw-r--r--lib/compiler/test/andor_SUITE.erl33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/compiler/test/andor_SUITE.erl b/lib/compiler/test/andor_SUITE.erl
index 0d00769704..4ffbe07e32 100644
--- a/lib/compiler/test/andor_SUITE.erl
+++ b/lib/compiler/test/andor_SUITE.erl
@@ -21,7 +21,8 @@
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
init_per_group/2,end_per_group/2,
t_case/1,t_and_or/1,t_andalso/1,t_orelse/1,inside/1,overlap/1,
- combined/1,in_case/1,before_and_inside_if/1]).
+ combined/1,in_case/1,before_and_inside_if/1,
+ slow_compilation/1]).
-include_lib("test_server/include/test_server.hrl").
@@ -472,6 +473,36 @@ before_and_inside_if_2(XDo1, XDo2, Do3) ->
end,
{CH1,CH2}.
+
+-record(state, {stack = []}).
+
+slow_compilation(_) ->
+ %% The function slow_compilation_1 used to compile very slowly.
+ ok = slow_compilation_1({a}, #state{}).
+
+slow_compilation_1(T1, #state{stack = [T2|_]})
+ when element(1, T2) == a, element(1, T1) == b, element(1, T1) == c ->
+ ok;
+slow_compilation_1(T, _)
+ when element(1, T) == a1; element(1, T) == b1; element(1, T) == c1 ->
+ ok;
+slow_compilation_1(T, _)
+ when element(1, T) == a2; element(1, T) == b2; element(1, T) == c2 ->
+ ok;
+slow_compilation_1(T, _) when element(1, T) == a ->
+ ok;
+slow_compilation_1(T, _)
+ when
+ element(1, T) == a,
+ (element(1, T) == b) and (element(1, T) == c) ->
+ ok;
+slow_compilation_1(_, T) when element(1, T) == a ->
+ ok;
+slow_compilation_1(_, T) when element(1, T) == b ->
+ ok;
+slow_compilation_1(T, _) when element(1, T) == a ->
+ ok.
+
%% Utilities.
check(V1, V0) ->