File: tailcall-8-run.c

package info (click to toggle)
gcc-riscv64-unknown-elf 8.3.0.2019.08%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 680,956 kB
  • sloc: ansic: 3,237,715; cpp: 896,882; ada: 772,854; f90: 144,254; asm: 68,788; makefile: 67,456; sh: 29,743; exp: 28,045; objc: 15,273; fortran: 11,885; python: 7,369; pascal: 5,375; awk: 3,725; perl: 2,872; yacc: 316; xml: 311; ml: 285; lex: 198; haskell: 122
file content (86 lines) | stat: -rw-r--r-- 1,100 bytes parent folder | download | duplicates (6)
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
/* { dg-do run } */
/* { dg-options "-O2" } */
/* { dg-additional-sources "tailcall-8.c" } */

struct s { int x; };

int expected;
struct s *last_ptr;
struct s tmp;

void
start (int val, struct s *initial_last_ptr)
{
  expected = val;
  tmp.x = val;
  last_ptr = initial_last_ptr;
}

void
f_direct (struct s param)
{
  if (param.x != expected)
    __builtin_abort ();
}

void
f_indirect (struct s *ptr)
{
  if (ptr->x != expected)
    __builtin_abort ();
  last_ptr = ptr;
  ptr->x += 100;
}

void
f_void (void)
{
  if (last_ptr->x != expected + 100)
    __builtin_abort ();
}


void g1 (struct s);
void g2 (struct s *);
void g3 (struct s *);
void g4 (struct s *);
void g5 (struct s);
void g6 (struct s);
void g7 (struct s);
void g8 (struct s *);
void g9 (struct s *);

int
main (void)
{
  struct s g6_s = { 106 };

  start (1, 0);
  g1 (tmp);

  start (2, 0);
  g2 (&tmp);

  start (3, 0);
  g3 (&tmp);

  start (4, 0);
  g4 (&tmp);

  start (5, 0);
  g5 (tmp);

  start (6, &g6_s);
  g6 (tmp);

  start (7, 0);
  g7 (tmp);

  start (8, 0);
  g8 (&tmp);

  start (9, 0);
  g9 (&tmp);

  return 0;
}