File: attr-alias-3.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (63 lines) | stat: -rw-r--r-- 1,665 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
// { dg-do link }
// { dg-skip-if "" { "powerpc-ibm-aix*" } }
// { dg-require-alias "" }
// { dg-options "-O2 -fno-common" }

// Copyright 2005 Free Software Foundation, Inc.
// Contributed by Alexandre Oliva <aoliva@redhat.com>

// PR middle-end/24295

// The unit-at-a-time call graph code used to fail to emit variables
// without external linkage that were only used indirectly, through
// aliases.  Although the PR above is about #pragma weak-introduced
// aliases, the underlying machinery is the same.

#ifndef ATTRIBUTE_USED
# define ATTRIBUTE_USED __attribute__((used))
#endif

static int lv1;
extern int Av1a __attribute__((alias ("lv1")));
int *pv1a = &Av1a;

static int lv2;
extern int Av2a __attribute__((alias ("lv2")));
int *pv2a = &lv2;

static int lv3;
extern int Av3a __attribute__((alias ("lv3")));
static int *pv3a ATTRIBUTE_USED = &Av3a;

static int lv4;
extern int Av4a __attribute__((alias ("lv4")));
static int *pv4a = &Av4a;

typedef void ftype(void);

static void lf1(void) {}
extern ftype Af1a __attribute__((alias ("lf1")));
ftype *pf1a = &Af1a;

static void lf2(void) {}
extern ftype Af2a __attribute__((alias ("lf2")));
ftype *pf2a = &Af2a;

static void lf3(void) {}
extern ftype Af3a __attribute__((alias ("lf3")));
static ftype *pf3a ATTRIBUTE_USED = &Af3a;

static void lf4(void) {}
extern ftype Af4a __attribute__((alias ("lf4")));
static ftype *pf4a = &Af4a;

int
main() {
#ifdef __mips
  /* Use real asm for MIPS, to stop the assembler warning about
     orphaned high-part relocations.  */
  asm volatile ("lw $2,%0\n\tlw $2,%1" : : "m" (pv4a), "m" (pf4a) : "$2");
#else
  asm volatile ("" : : "m" (pv4a), "m" (pf4a));
#endif
}