1 // { dg-do link } 2 // { dg-skip-if "" { "powerpc-ibm-aix*" } { "*" } { "" } } 3 // { dg-require-alias "" } 4 // { dg-options "-O2 -fno-common" } 5 6 // Copyright 2005 Free Software Foundation, Inc. 7 // Contributed by Alexandre Oliva <aoliva@redhat.com> 8 9 // PR middle-end/24295 10 11 // The unit-at-a-time call graph code used to fail to emit variables 12 // without external linkage that were only used indirectly, through 13 // aliases. Although the PR above is about #pragma weak-introduced 14 // aliases, the underlying machinery is the same. 15 16 #ifndef ATTRIBUTE_USED 17 # define ATTRIBUTE_USED __attribute__((used)) 18 #endif 19 20 static int lv1; 21 extern int Av1a __attribute__((alias ("lv1"))); 22 int *pv1a = &Av1a; 23 24 static int lv2; 25 extern int Av2a __attribute__((alias ("lv2"))); 26 int *pv2a = &lv2; 27 28 static int lv3; 29 extern int Av3a __attribute__((alias ("lv3"))); 30 static int *pv3a ATTRIBUTE_USED = &Av3a; 31 32 static int lv4; 33 extern int Av4a __attribute__((alias ("lv4"))); 34 static int *pv4a = &Av4a; 35 36 typedef void ftype(void); 37 lf1(void)38static void lf1(void) {} 39 extern ftype Af1a __attribute__((alias ("lf1"))); 40 ftype *pf1a = &Af1a; 41 lf2(void)42static void lf2(void) {} 43 extern ftype Af2a __attribute__((alias ("lf2"))); 44 ftype *pf2a = &Af2a; 45 lf3(void)46static void lf3(void) {} 47 extern ftype Af3a __attribute__((alias ("lf3"))); 48 static ftype *pf3a ATTRIBUTE_USED = &Af3a; 49 lf4(void)50static void lf4(void) {} 51 extern ftype Af4a __attribute__((alias ("lf4"))); 52 static ftype *pf4a = &Af4a; 53 main()54main() { 55 #ifdef __mips 56 /* Use real asm for MIPS, to stop the assembler warning about 57 orphaned high-part relocations. */ 58 asm volatile ("lw $2,%0\n\tlw $2,%1" : : "m" (pv4a), "m" (pf4a) : "$2"); 59 #else 60 asm volatile ("" : : "m" (pv4a), "m" (pf4a)); 61 #endif 62 } 63