blob: bdfcaf4529fee1f21bfe5e014e94cc5c03782995 (
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
|
(* TEST
flags = "-S -function-sections";
function_sections;
{
arch_arm;
reference = "${test_source_directory}/func_sections.arm.reference";
native;
}{
arch_arm64;
reference = "${test_source_directory}/func_sections.arm.reference";
native;
}{
arch_amd64;
reference = "${test_source_directory}/func_sections.reference";
native;
}{
arch_i386;
reference = "${test_source_directory}/func_sections.reference";
native;
}
*)
(* We have a separate reference output for ARM because
it doesn't emit .text after jump tables. *)
(* Test for anonymous functions which result in a mangled symbol *)
let f4 list =
List.map (fun s -> String.length s) list
let test1 () =
f4 ["a";"asfda";"afda"]
(* Test for jump tables*)
let g1 s = s^"*"
let g2 s = "*"^s
let g3 s = "*"^s^"*"
let f5 = function
| 1 -> g1 "a"
| 2 -> g2 "b"
| 3 -> g3 "c"
| 4 -> g1 "d"
| 5 -> g2 "e"
| 6 -> g3 "f"
| _ -> "x"
let test2 () =
let list = [f5 5;
f5 7;
f5 15;
f5 26]
in
ignore list
let iter = 1_000
let f0 x = x - 7;
[@@inline never]
let f1 x = x + iter
[@@inline never]
let f2 x = f1(x)
[@@inline never]
let f3 x = f2(x)*f0(x)
[@@inline never]
let test3 () =
f3 iter
let () =
ignore (test1 ());
ignore (test2 ());
ignore (test3 ());
()
|