summaryrefslogtreecommitdiff
path: root/lib/compiler/test
diff options
context:
space:
mode:
authorJohn Högberg <john@erlang.org>2023-03-16 14:17:56 +0100
committerJohn Högberg <john@erlang.org>2023-03-16 20:48:09 +0100
commitc62f3fabe2ee9ca610f1fc9605181b06f820c31c (patch)
treef3443e344bfafa642aeb15588b2aff8fb7ddfb9b /lib/compiler/test
parent5400ccf243a31d664153a4b9ceb9de3edfce1e0e (diff)
downloaderlang-c62f3fabe2ee9ca610f1fc9605181b06f820c31c.tar.gz
jit: Fix hd/1 and tl/1 BIF specialization
While we're at it, remove related loader transformations that only kicks in for unoptimized code.
Diffstat (limited to 'lib/compiler/test')
-rw-r--r--lib/compiler/test/bif_SUITE.erl28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/compiler/test/bif_SUITE.erl b/lib/compiler/test/bif_SUITE.erl
index 8480569507..34bf54a871 100644
--- a/lib/compiler/test/bif_SUITE.erl
+++ b/lib/compiler/test/bif_SUITE.erl
@@ -24,7 +24,8 @@
-export([all/0,suite/0,groups/0,init_per_suite/1,end_per_suite/1,
init_per_group/2,end_per_group/2,
beam_validator/1,trunc_and_friends/1,cover_safe_and_pure_bifs/1,
- cover_trim/1]).
+ cover_trim/1,
+ head_tail/1]).
suite() ->
[{ct_hooks,[ts_install_cth]}].
@@ -37,7 +38,8 @@ groups() ->
[beam_validator,
trunc_and_friends,
cover_safe_and_pure_bifs,
- cover_trim
+ cover_trim,
+ head_tail
]}].
init_per_suite(Config) ->
@@ -167,6 +169,28 @@ cover_trim_3(Header, N)->
false
end.
+%% GH-7024: The loader transformations for hd/1 and tl/1 were incorrect and
+%% failed when certain optimizations were turned off.
+head_tail(_Config) ->
+ {1, ok} = head_case(),
+ {1, ok} = tail_case(),
+
+ 1 = hd(id([1])),
+ [] = tl(id([1])),
+
+ ok.
+
+head_case() ->
+ case 1 of
+ X when hd(X) -> blurf;
+ X -> {X, ok}
+ end.
+
+tail_case() ->
+ case 1 of
+ X when tl(X) -> blurf;
+ X -> {X, ok}
+ end.
id(I) ->
I.