summaryrefslogtreecommitdiff
path: root/lib/compiler/test/beam_ssa_check_SUITE_data/alias_chain.erl
blob: 7d46176fb9b34c0d0fcce5a03a90be24f89cceb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2023. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%%     http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% %CopyrightEnd%
%%
%% This module tests that beam_ssa_alias_opt:opt/2 does not annotate
%% instructions with information about aliased operands when more than
%% MAX_REPETITIONS are required for the analysis to converge.
%%
%% A specially crafted module which is designed to hit the alias
%% analysis iteration limit if functions are visited naïvely in the
%% order they occur in the module.
%%
-compile(no_ssa_opt_private_append).

-module(alias_chain).

-export([top/1]).

top(L) ->
%ssa% (A) when post_ssa_opt ->
%ssa% _ = call(...) { aliased => [A] }.
    fF(L, <<>>).

fF([H|T], AccA) ->
    fE(T, <<AccA/binary, H:8>>);
fF([], Acc) ->
    Acc.

fE([H|T], AccA) ->
    fD(T, <<AccA/binary, H:8>>);
fE([], Acc) ->
    Acc.

fD([H|T], AccA) ->
    fC(T, <<AccA/binary, H:8>>);
fD([], Acc) ->
    Acc.

fC([H|T], AccA) ->
    fB(T, <<AccA/binary, H:8>>);
fC([], Acc) ->
    Acc.

fB([H|T], AccA) ->
    fA(T, <<AccA/binary, H:8>>);
fB([], Acc) ->
    Acc.

fA([H|T], AccA) ->
    f9(T, <<AccA/binary, H:8>>);
fA([], Acc) ->
    Acc.

f9([H|T], AccA) ->
    f8(T, <<AccA/binary, H:8>>);
f9([], Acc) ->
    Acc.

f8([H|T], AccA) ->
    f7(T, <<AccA/binary, H:8>>);
f8([], Acc) ->
    Acc.

f7([H|T], AccA) ->
    f6(T, <<AccA/binary, H:8>>);
f7([], Acc) ->
    Acc.

f6([H|T], AccA) ->
    f5(T, <<AccA/binary, H:8>>);
f6([], Acc) ->
    Acc.

f5([H|T], AccA) ->
    f4(T, <<AccA/binary, H:8>>);
f5([], Acc) ->
    Acc.

f4([H|T], AccA) ->
    f3(T, <<AccA/binary, H:8>>);
f4([], Acc) ->
    Acc.

f3([H|T], AccA) ->
    f2(T, <<AccA/binary, H:8>>);
f3([], Acc) ->
    Acc.

f2([H|T], AccA) ->
    f1(T, <<AccA/binary, H:8>>);
f2([], Acc) ->
    Acc.

f1([H|T], AccA) ->
    f0(T, <<AccA/binary, H:8>>);
f1([], Acc) ->
    Acc.

f0([H|T], AccA) ->
    f3(T, <<AccA/binary, H:8>>);
f0([], Acc) ->
    Acc.