PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / asm-4.c
blobb86801032bc41492d85af614065bc4b1cdcdb7ee
1 /* Test if functions marked __attribute__((used)), but with address never
2 taken in C code, don't use alternate calling convention for local
3 functions on IA-32. */
4 /* { dg-do run } */
5 /* The asm in this test uses an absolute address. */
6 /* { dg-require-effective-target nonpic } */
7 /* { dg-options "-O2" } */
9 extern void abort (void);
11 static int foo (int, int, int, int) __asm ("foo");
12 static __attribute__((noinline, used)) int
13 foo (int i, int j, int k, int l)
15 return i + j + k + l;
18 void
19 bar (void)
21 if (foo (1, 2, 3, 4) != 10)
22 abort ();
25 int (*fn) (int, int, int, int);
27 void
28 baz (void)
30 /* Darwin loads 64-bit regions above the 4GB boundary so
31 we need to use this instead. */
32 #if defined (__LP64__) && defined (__MACH__)
33 __asm ("leaq foo(%%rip), %0" : "=r" (fn));
34 #else
35 __asm ("movl $foo, %k0" : "=r" (fn));
36 #endif
37 if (fn (2, 3, 4, 5) != 14)
38 abort ();
41 int
42 main (void)
44 bar ();
45 baz ();
46 return 0;