aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tls/pr78796.c
blob: 96f87d47ba47ad55301861b8b5c4f3a039671211 (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
/* PR target/78796 */
/* { dg-do run } */
/* { dg-options "-O2" } */
/* { dg-additional-options "-mcmodel=large -fno-pie -no-pie" { target aarch64-*-* } } */
/* { dg-require-effective-target tls_runtime } */
/* { dg-add-options tls } */

struct S { int a, b, c, d, e; };
struct S t;
__thread struct S s;

__attribute__((used, noinline, noclone)) void
foo (int *x, int *y)
{
  asm volatile ("" : : "g" (x), "g" (y) : "memory");
  if (*x != 1 || *y != 2)
    __builtin_abort ();
}

__attribute__((used, noinline, noclone)) void
bar (void)
{
  foo (&t.c, &s.c);
}

int
main ()
{
  t.c = 1;
  s.c = 2;
  bar ();
  return 0;
}