File: pr78468.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 (102 lines) | stat: -rw-r--r-- 1,909 bytes parent folder | download | duplicates (4)
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
/* { dg-do run } */
/* { dg-require-effective-target alloca } */
/* { dg-options "-O2 -fno-inline" } */

/* Test that targets correctly round the size of the outgoing arguments
   to a multiple of STACK_BOUNDARY.  There is a serious alignment bug if
   aligned alloca does not get aligned!  */

__extension__ typedef __UINTPTR_TYPE__ uintptr_t;
extern void abort (void);

volatile int xx;
volatile int x = 16;

void
t1 (int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7,
    void *p, int align)
{
  xx = x0 + x1 + x2 + x3 + x4 + x4 + x6 + x7;
  if ((int)(uintptr_t)p & (align-1))
    abort ();
}

void
t2 (int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7,
    void *p, int align, int dummy)
{
  xx = x0 + x1 + x2 + x3 + x4 + x4 + x6 + x7;
  if ((int)(uintptr_t)p & (align-1))
    abort ();
}

void
t1_a4 (int size)
{
  void *p = __builtin_alloca_with_align (size, 32);
  t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 4);
}

void
t2_a4 (int size)
{
  void *p = __builtin_alloca_with_align (size, 32);
  t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 4, 0);
}

void
t1_a8 (int size)
{
  void *p = __builtin_alloca_with_align (size, 64);
  t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 8);
}

void
t2_a8 (int size)
{
  void *p = __builtin_alloca_with_align (size, 64);
  t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 8, 0);
}

void
t1_a16 (int size)
{
  void *p = __builtin_alloca_with_align (size, 128);
  t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 16);
}

void
t2_a16 (int size)
{
  void *p = __builtin_alloca_with_align (size, 128);
  t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 16, 0);
}

void
t1_a32 (int size)
{
  void *p = __builtin_alloca_with_align (size, 256);
  t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 32);
}

void
t2_a32 (int size)
{
  void *p = __builtin_alloca_with_align (size, 256);
  t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 32, 0);
}


int
main ()
{
  t1_a4 (x);
  t2_a4 (x);
  t1_a8 (x);
  t2_a8 (x);
  t1_a16 (x);
  t2_a16 (x);
  t1_a32 (x);
  t2_a32 (x);
  return 0;
}