diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/lto')
81 files changed, 992 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/lto/20080908_0.c b/gcc/testsuite/gcc.dg/lto/20080908_0.c new file mode 100644 index 00000000000..3bc1c3a725c --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20080908_0.c @@ -0,0 +1,16 @@ +/* { dg-lto-do assemble } */ +void foo(void) { + char *bar; + int baz; + while (1) + { + if (baz) + { + baz = -baz; + do + *bar++ = 0; + while (++baz); + } + ++baz; + } +} diff --git a/gcc/testsuite/gcc.dg/lto/20080917_0.c b/gcc/testsuite/gcc.dg/lto/20080917_0.c new file mode 100644 index 00000000000..ac0891081fe --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20080917_0.c @@ -0,0 +1,29 @@ +/* { dg-lto-do assemble } */ +/* { dg-lto-options {{-O2 -funsigned-char}} } */ +int +foo (char *s, int flag) +{ + for (;;) + { + unsigned char c; + if (flag) + c = *s; + else + c = *s; + return c; + } +} + +int +baz (const char *s, int flag) +{ + for (;;) + { + unsigned char c; + if (flag) + c = *s; + else + c = *s; + return c; + } +} diff --git a/gcc/testsuite/gcc.dg/lto/20080924_0.c b/gcc/testsuite/gcc.dg/lto/20080924_0.c new file mode 100644 index 00000000000..db7745077e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20080924_0.c @@ -0,0 +1,9 @@ +/* { dg-lto-do assemble } */ +/* { dg-lto-options {{-O2 -flto -funsigned-char}} } */ +typedef unsigned int size_t; +foo (const char *src, unsigned char *dst, size_t size) +{ + int ch; + while ((ch = *src++) != '\0') { + } +} diff --git a/gcc/testsuite/gcc.dg/lto/20081024_0.c b/gcc/testsuite/gcc.dg/lto/20081024_0.c new file mode 100644 index 00000000000..9fa297abc0e --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081024_0.c @@ -0,0 +1,26 @@ +/* { dg-lto-do run } */ + +#include <stdarg.h> +#include <stdio.h> +#include <string.h> + +char * +myprintf (const char *fmt, ...) +{ + va_list args; + static char buf[80]; + + va_start (args, fmt); + (void) vsnprintf (buf, sizeof (buf), fmt, args); + va_end (args); + return buf; +} + +int +main () +{ + char *s; + + s = myprintf ("%s: %d\n", "foo", 1); + return strcmp (s, "foo: 1\n") != 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081109_0.c b/gcc/testsuite/gcc.dg/lto/20081109_0.c new file mode 100644 index 00000000000..eaa25f673d3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081109_0.c @@ -0,0 +1,3 @@ +/* { dg-lto-do assemble } */ +/* { dg-lto-options {{-w -flto}} } */ +void Foo(void) { char bar[1]; free(bar); } diff --git a/gcc/testsuite/gcc.dg/lto/20081111_0.c b/gcc/testsuite/gcc.dg/lto/20081111_0.c new file mode 100644 index 00000000000..899689c1bc4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081111_0.c @@ -0,0 +1,11 @@ +extern int mumble; +extern void abort (void); +extern void exit (int); + +int +main () +{ + if (++mumble != 42) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081111_1.c b/gcc/testsuite/gcc.dg/lto/20081111_1.c new file mode 100644 index 00000000000..2b7fee58690 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081111_1.c @@ -0,0 +1,7 @@ +int mumble = 41; + +int +bar (void) +{ + return mumble; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081112_0.c b/gcc/testsuite/gcc.dg/lto/20081112_0.c new file mode 100644 index 00000000000..a90aa70b3ab --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081112_0.c @@ -0,0 +1,14 @@ +extern void exit (int); +extern void abort (void); + +extern void f (); +extern int g (); + +int +main () +{ + f (); + if (g () != 42) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081112_1.c b/gcc/testsuite/gcc.dg/lto/20081112_1.c new file mode 100644 index 00000000000..2ba1cb9405c --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081112_1.c @@ -0,0 +1,13 @@ +static int mumble; + +void +f (void) +{ + mumble = 41; +} + +int __attribute__((noinline)) +g (void) +{ + return ++mumble; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081115_0.c b/gcc/testsuite/gcc.dg/lto/20081115_0.c new file mode 100644 index 00000000000..f24a92deda4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081115_0.c @@ -0,0 +1,32 @@ +/* { dg-lto-options {{-O2 -DOPTIMIZE -fwhopr} {-O0 -fwhopr}} } */ + +extern void abort (void); + +int f (void) +{ + return 1; +} + +extern inline int +e_inline_baz (void) +{ + return 1 + f(); +} + +int +bar (void) +{ + return e_inline_baz (); +} + +main () +{ +#ifdef OPTIMIZE + if (bar () != 2 || foo () != 3) + abort (); +#else + if (bar () != 0 || foo () != 0) + abort (); +#endif + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081115_1.c b/gcc/testsuite/gcc.dg/lto/20081115_1.c new file mode 100644 index 00000000000..62ffa520000 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081115_1.c @@ -0,0 +1,11 @@ +extern inline int +e_inline_baz (void) +{ + return 2 + 1; +} + +int +foo (void) +{ + return e_inline_baz (); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081115_2.c b/gcc/testsuite/gcc.dg/lto/20081115_2.c new file mode 100644 index 00000000000..0ccecd7363d --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081115_2.c @@ -0,0 +1,5 @@ +int +e_inline_baz (void) +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081118_0.c b/gcc/testsuite/gcc.dg/lto/20081118_0.c new file mode 100644 index 00000000000..0640428be6d --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081118_0.c @@ -0,0 +1,28 @@ +/* { dg-lto-options {{-O2 -DOPTIMIZE -fwhopr} {-O0 -fwhopr}} } */ + +extern void abort (void); +extern int f (void); + +extern inline int +e_inline_baz (void) +{ + return 1 + f(); +} + +int +bar (void) +{ + return e_inline_baz (); +} + +main () +{ +#ifdef OPTIMIZE + if (bar () != 2 || foo () != 3) + abort (); +#else + if (bar () != 0 || foo () != 0) + abort (); +#endif + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081118_1.c b/gcc/testsuite/gcc.dg/lto/20081118_1.c new file mode 100644 index 00000000000..f0a8c3c876b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081118_1.c @@ -0,0 +1,13 @@ +extern int f (void); + +extern inline int +e_inline_baz (void) +{ + return 2 + f (); +} + +int +foo (void) +{ + return e_inline_baz (); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081118_2.c b/gcc/testsuite/gcc.dg/lto/20081118_2.c new file mode 100644 index 00000000000..32ce432a128 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081118_2.c @@ -0,0 +1,11 @@ +int +e_inline_baz (void) +{ + return 0; +} + + __attribute__((noinline)) int +f (void) +{ + return 1; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081120-1_0.c b/gcc/testsuite/gcc.dg/lto/20081120-1_0.c new file mode 100644 index 00000000000..c35119605d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081120-1_0.c @@ -0,0 +1,5 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options {{-flto -shared}} } */ +extern int stat(void) __asm__("" "stat64"); +extern inline int stat(void) { } +static void foo(void) { stat(); } diff --git a/gcc/testsuite/gcc.dg/lto/20081120-1_1.c b/gcc/testsuite/gcc.dg/lto/20081120-1_1.c new file mode 100644 index 00000000000..73d25000c91 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081120-1_1.c @@ -0,0 +1,3 @@ +extern int stat(void) __asm__("" "stat64"); +extern inline int stat(void) { } +static void foo(void) { stat(); } diff --git a/gcc/testsuite/gcc.dg/lto/20081120-2_0.c b/gcc/testsuite/gcc.dg/lto/20081120-2_0.c new file mode 100644 index 00000000000..ff8a9a435f2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081120-2_0.c @@ -0,0 +1,3 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options {{-fwhopr -shared}} } */ +void bar(void) {} diff --git a/gcc/testsuite/gcc.dg/lto/20081120-2_1.c b/gcc/testsuite/gcc.dg/lto/20081120-2_1.c new file mode 100644 index 00000000000..c81f8c7fd07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081120-2_1.c @@ -0,0 +1,2 @@ +int mumble = 0; +void foo(void) {} diff --git a/gcc/testsuite/gcc.dg/lto/20081125_0.c b/gcc/testsuite/gcc.dg/lto/20081125_0.c new file mode 100644 index 00000000000..4b2e7191fed --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081125_0.c @@ -0,0 +1,6 @@ +int foo (int); + +int main() +{ + return foo (0); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081125_1.c b/gcc/testsuite/gcc.dg/lto/20081125_1.c new file mode 100644 index 00000000000..1fcf4e7d391 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081125_1.c @@ -0,0 +1,4 @@ +int foo (int x) +{ + return x; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081126_0.c b/gcc/testsuite/gcc.dg/lto/20081126_0.c new file mode 100644 index 00000000000..9d0bb14c4cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081126_0.c @@ -0,0 +1,8 @@ +/* { dg-lto-do link } */ +/* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } { "*" } { "" } } */ +/* { dg-lto-options {{-flto -shared}} } */ + +int f(void) { + register int ri asm("edi"); + return ri; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081201-1_0.c b/gcc/testsuite/gcc.dg/lto/20081201-1_0.c new file mode 100644 index 00000000000..05cbb82fdd1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081201-1_0.c @@ -0,0 +1,33 @@ +/* { dg-lto-options {{-O2 -DOPTIMIZE -fwhopr} {-O0 -fwhopr}} } */ + +extern void abort (void); + +int +f (void) +{ + return 1; +} + +extern inline int +e_inline_baz (void) +{ + return 1 + f(); +} + +int +bar (void) +{ + return e_inline_baz (); +} + +main () +{ +#ifdef OPTIMIZE + if (bar () != 2 || foo () != 3) + abort (); +#else + if (bar () != 0 || foo () != 0) + abort (); +#endif + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081201-1_1.c b/gcc/testsuite/gcc.dg/lto/20081201-1_1.c new file mode 100644 index 00000000000..f0a8c3c876b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081201-1_1.c @@ -0,0 +1,13 @@ +extern int f (void); + +extern inline int +e_inline_baz (void) +{ + return 2 + f (); +} + +int +foo (void) +{ + return e_inline_baz (); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081201-1_2.c b/gcc/testsuite/gcc.dg/lto/20081201-1_2.c new file mode 100644 index 00000000000..bcf87a749b5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081201-1_2.c @@ -0,0 +1,7 @@ +int +e_inline_baz (void) +{ + return 0; +} + + diff --git a/gcc/testsuite/gcc.dg/lto/20081201-2_0.c b/gcc/testsuite/gcc.dg/lto/20081201-2_0.c new file mode 100644 index 00000000000..4c1510d1cec --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081201-2_0.c @@ -0,0 +1,16 @@ +/* { dg-lto-options {{-O3 -fwhopr}} } */ + +/* Test that cross-TU inlining works. */ + +extern void abort (); +extern void exit (int); +extern void *foo (void); + +int +main () +{ + if (foo () != __builtin_return_address (0)) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081201-2_1.c b/gcc/testsuite/gcc.dg/lto/20081201-2_1.c new file mode 100644 index 00000000000..f93e1fd025f --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081201-2_1.c @@ -0,0 +1,5 @@ +void * +foo (void) +{ + return __builtin_return_address (0); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081202-1_0.c b/gcc/testsuite/gcc.dg/lto/20081202-1_0.c new file mode 100644 index 00000000000..933610a894b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081202-1_0.c @@ -0,0 +1,11 @@ +/* { dg-lto-options {{-fwhopr -O3}} } */ + +extern void exit (int); +extern void foo (void); + +int +main () +{ + foo (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081202-1_1.c b/gcc/testsuite/gcc.dg/lto/20081202-1_1.c new file mode 100644 index 00000000000..2f6777864a0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081202-1_1.c @@ -0,0 +1,10 @@ +static void __attribute__((noinline)) +bar (void) +{ +} + +void +foo (void) +{ + bar (); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081202-2_0.c b/gcc/testsuite/gcc.dg/lto/20081202-2_0.c new file mode 100644 index 00000000000..09f417698ca --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081202-2_0.c @@ -0,0 +1,13 @@ +/* { dg-lto-options {{-fwhopr -O3}} } */ + +extern void exit (int); +extern void *foo (void); + +void *p; + +int +main () +{ + p = foo (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081202-2_1.c b/gcc/testsuite/gcc.dg/lto/20081202-2_1.c new file mode 100644 index 00000000000..adb15024502 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081202-2_1.c @@ -0,0 +1,16 @@ +static void __attribute__((noinline)) +bar (void) +{ +} + +void * +foo (void) +{ + return bar; +} + +void +quxx (void) +{ + return bar (); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081204-1_0.c b/gcc/testsuite/gcc.dg/lto/20081204-1_0.c new file mode 100644 index 00000000000..92598085c9a --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081204-1_0.c @@ -0,0 +1,7 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options {{-fwhopr -fPIC -shared}} } */ + +/* Tests for the absence during linking of: + lto1: error: type of 'i' does not match original declaration */ + +const int i[1]; diff --git a/gcc/testsuite/gcc.dg/lto/20081204-1_1.c b/gcc/testsuite/gcc.dg/lto/20081204-1_1.c new file mode 100644 index 00000000000..95761ea156b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081204-1_1.c @@ -0,0 +1,5 @@ +extern const int i[]; + +int dummy(void) { + return i[0]; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081204-2_0.c b/gcc/testsuite/gcc.dg/lto/20081204-2_0.c new file mode 100644 index 00000000000..241ac5d607a --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081204-2_0.c @@ -0,0 +1,5 @@ +/* { dg-lto-do link } */ +/* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } { "*" } { "" } } */ +/* { dg-lto-options {{-w -flto -fPIC -shared}} } */ + +register int ri asm("edi"); diff --git a/gcc/testsuite/gcc.dg/lto/20081210-1_0.c b/gcc/testsuite/gcc.dg/lto/20081210-1_0.c new file mode 100644 index 00000000000..5cf020ec227 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081210-1_0.c @@ -0,0 +1,21 @@ +#if defined(_LP64) || defined(_WIN64) +typedef unsigned long int uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif + +extern void srand (uintptr_t); + +inline void +foo (uintptr_t seed) +{ + srand (seed * seed); +} + +int +main () +{ + foo (0); + srand ((uintptr_t) (&foo)); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081212-1_0.c b/gcc/testsuite/gcc.dg/lto/20081212-1_0.c new file mode 100644 index 00000000000..a19bff1bac5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081212-1_0.c @@ -0,0 +1,4 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options {{-shared}} } */ +int exported_var = 42; +/* { dg-final { scan-symbol "exported_var" } } */ diff --git a/gcc/testsuite/gcc.dg/lto/20081222_0.c b/gcc/testsuite/gcc.dg/lto/20081222_0.c new file mode 100644 index 00000000000..e44766613bd --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081222_0.c @@ -0,0 +1,11 @@ +#include "20081222_0.h" + +extern void abort (void); + +int +main () +{ + if (x () == 7) + return 0; + abort (); +} diff --git a/gcc/testsuite/gcc.dg/lto/20081222_0.h b/gcc/testsuite/gcc.dg/lto/20081222_0.h new file mode 100644 index 00000000000..4c26f461651 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081222_0.h @@ -0,0 +1 @@ +int x(); diff --git a/gcc/testsuite/gcc.dg/lto/20081222_1.c b/gcc/testsuite/gcc.dg/lto/20081222_1.c new file mode 100644 index 00000000000..e8f9254421b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081222_1.c @@ -0,0 +1,16 @@ +#include "20081222_0.h" + +/* Actually, call "x" "INT_X", and make it hidden. */ +extern __typeof (x) x + __asm__ ("INT_x") + __attribute__ ((__visibility__ ("hidden"))); + +int x () +{ + return 7; +} + +/* Make an externally-visible symbol "X" that's an alias for INT_x. */ +extern __typeof (x) EXT_x + __asm__ ("x") + __attribute__ ((__alias__ ("INT_x"))); diff --git a/gcc/testsuite/gcc.dg/lto/20081224_0.c b/gcc/testsuite/gcc.dg/lto/20081224_0.c new file mode 100644 index 00000000000..c146115b086 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081224_0.c @@ -0,0 +1,9 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options {{-fwhopr -shared -fPIC}} } */ +#include "20081224_0.h" + +extern struct foo x; + +void f(void) { + x.x = 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20081224_0.h b/gcc/testsuite/gcc.dg/lto/20081224_0.h new file mode 100644 index 00000000000..7b62a079667 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081224_0.h @@ -0,0 +1,3 @@ +typedef struct foo { + int x; +} foo_t; diff --git a/gcc/testsuite/gcc.dg/lto/20081224_1.c b/gcc/testsuite/gcc.dg/lto/20081224_1.c new file mode 100644 index 00000000000..3e1ff341088 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20081224_1.c @@ -0,0 +1,2 @@ +#include "20081224_0.h" +foo_t x; diff --git a/gcc/testsuite/gcc.dg/lto/20090116_0.c b/gcc/testsuite/gcc.dg/lto/20090116_0.c new file mode 100644 index 00000000000..4b88e4ab3b1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090116_0.c @@ -0,0 +1,12 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options {{-O1 -fwhopr -fPIC}} } */ +/* { dg-extra-ld-options {-shared -O0} } */ + +int foo(void) { + int ret, i; + for (i = 0; i < 1; i++) + ret = 0; + for (i = 0; i < 1; i++) + ret = 1; + return ret; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090120_0.c b/gcc/testsuite/gcc.dg/lto/20090120_0.c new file mode 100644 index 00000000000..6c69a9918b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090120_0.c @@ -0,0 +1,14 @@ +/* { dg-lto-options {{-flto -funsigned-char}} } */ + +extern void abort (); + +char c = 0xff; + +int +main () +{ + int i = (unsigned) c; + if (i < 0) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090126-1_0.c b/gcc/testsuite/gcc.dg/lto/20090126-1_0.c new file mode 100644 index 00000000000..0ed8ea32401 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090126-1_0.c @@ -0,0 +1,7 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options {{-O0 -fwhopr}} } */ +/* { dg-extra-ld-options {-shared -O2 -fwhopr} } */ + +int main(int argc, char **argv) { + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090126-2_0.c b/gcc/testsuite/gcc.dg/lto/20090126-2_0.c new file mode 100644 index 00000000000..64e63853250 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090126-2_0.c @@ -0,0 +1,7 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options {{-fPIC -O2 -fwhopr}} } */ +/* { dg-extra-ld-options {-fno-PIC -shared -O2 -fwhopr} } */ + +int main(int argc, char **argv) { + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090206-1_0.c b/gcc/testsuite/gcc.dg/lto/20090206-1_0.c new file mode 100644 index 00000000000..42eaca9d5e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090206-1_0.c @@ -0,0 +1,10 @@ +/* { dg-lto-do link } */ +/* { dg-skip-if "" { ! { i?86-*-linux* x86_64-*-linux* } } { "*" } { "" } } */ +/* { dg-lto-options {{-fPIC -shared -fwhopr -msse2}} } */ +/* { dg-suppress-ld-options {-fPIC -msse2} } */ + +typedef short v8hi __attribute__((__vector_size__(16))); +void func (void) { + v8hi x, y, z; + z = __builtin_ia32_paddw128 (x, y); +} diff --git a/gcc/testsuite/gcc.dg/lto/20090206-2_0.c b/gcc/testsuite/gcc.dg/lto/20090206-2_0.c new file mode 100644 index 00000000000..3e85c5d227c --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090206-2_0.c @@ -0,0 +1,18 @@ +/* { dg-lto-do link } */ +/* { dg-skip-if "" { ! { i?86-*-linux* x86_64-*-linux* } } { "*" } { "" } } */ +/* { dg-lto-options {{-fwhopr -fPIC}} } */ +/* { dg-suppress-ld-options {-fPIC} } */ + +void func(int n) { + static int __thread v = 0; + int i; + for (i = 0; i < n; ++i) { + volatile int *p = &v; + volatile int x __attribute__ ((unused)) = *p; + } +} + +int main(int argc, char **argv) { + func(argc); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090210_0.c b/gcc/testsuite/gcc.dg/lto/20090210_0.c new file mode 100644 index 00000000000..c588e8a2778 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090210_0.c @@ -0,0 +1,6 @@ +/* { dg-lto-do run } */ +/* { dg-suppress-ld-options {-fPIC} } */ +int foo (int x) +{ + return x; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090210_1.c b/gcc/testsuite/gcc.dg/lto/20090210_1.c new file mode 100644 index 00000000000..bf12aa6c08b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090210_1.c @@ -0,0 +1,22 @@ +/* { dg-options "-fPIC" } */ +static void +f (int n) +{ + int i; + static int __thread value = 100; + for (i = 0; i < n; ++i) + { + volatile int *p = &value; + volatile int x __attribute__ ((unused)) = *p; + } +} + + +extern int foo (int); + +int +main (int argc, char **argv) +{ + f (foo (4) + argc); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090213_0.c b/gcc/testsuite/gcc.dg/lto/20090213_0.c new file mode 100644 index 00000000000..6387a0e4716 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090213_0.c @@ -0,0 +1,11 @@ +/* { dg-lto-do run } */ +#include <stdio.h> + +extern int foo (int); + +main() +{ + int x = foo (10); + printf ("x is %d, foo is at 0x%p\n", x, foo); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090213_1.c b/gcc/testsuite/gcc.dg/lto/20090213_1.c new file mode 100644 index 00000000000..4a852efd193 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090213_1.c @@ -0,0 +1,6 @@ +int foo (int x) +{ + return x * 32; +} + + diff --git a/gcc/testsuite/gcc.dg/lto/20090218-1_0.c b/gcc/testsuite/gcc.dg/lto/20090218-1_0.c new file mode 100644 index 00000000000..1dc9ee08540 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090218-1_0.c @@ -0,0 +1,4 @@ +void set_mem_alias_set () __attribute__ ((always_inline)); +void emit_push_insn () { + set_mem_alias_set (); +} diff --git a/gcc/testsuite/gcc.dg/lto/20090218-1_1.c b/gcc/testsuite/gcc.dg/lto/20090218-1_1.c new file mode 100644 index 00000000000..33d4fb000f3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090218-1_1.c @@ -0,0 +1,9 @@ +int main(void) +{ + return 0; +} +static void __attribute__ ((noinline)) get_mem_attrs () { +} +void __attribute__ ((always_inline)) set_mem_alias_set () { + get_mem_attrs (); +} diff --git a/gcc/testsuite/gcc.dg/lto/20090218-2_0.c b/gcc/testsuite/gcc.dg/lto/20090218-2_0.c new file mode 100644 index 00000000000..8857e7a6d21 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090218-2_0.c @@ -0,0 +1,3 @@ +void emit_push_insn () { + set_mem_alias_set (); +} diff --git a/gcc/testsuite/gcc.dg/lto/20090218-2_1.c b/gcc/testsuite/gcc.dg/lto/20090218-2_1.c new file mode 100644 index 00000000000..119fbe4a16b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090218-2_1.c @@ -0,0 +1,19 @@ +typedef struct { +} mem_attrs; +int main(void) +{ + return 0; +} +void *malloc(unsigned long size); +void *memcpy(void *dest, const void *src, unsigned long n); +static mem_attrs * get_mem_attrs () { + void **slot; + *slot = malloc (3); + memcpy (*slot, 0, 3); +} +void set_mem_attributes () { + get_mem_attrs (); +} +void set_mem_alias_set () { + get_mem_attrs (); +} diff --git a/gcc/testsuite/gcc.dg/lto/20090218_0.c b/gcc/testsuite/gcc.dg/lto/20090218_0.c new file mode 100644 index 00000000000..c4390fa1f10 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090218_0.c @@ -0,0 +1,7 @@ +void __attribute__((noinline)) *foo1(void); +void __attribute__((noinline)) *foo2(void); + +int main(void) +{ + return foo1() != foo2(); +} diff --git a/gcc/testsuite/gcc.dg/lto/20090218_1.c b/gcc/testsuite/gcc.dg/lto/20090218_1.c new file mode 100644 index 00000000000..c28b84ada6e --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090218_1.c @@ -0,0 +1,6 @@ +void bar(void); +void __attribute__((noinline)) *foo1 (void) +{ + bar(); + return (void *) bar; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090218_2.c b/gcc/testsuite/gcc.dg/lto/20090218_2.c new file mode 100644 index 00000000000..e9f835f3627 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090218_2.c @@ -0,0 +1,6 @@ +void bar(void); +void __attribute__((noinline)) *foo2 (void) +{ + bar(); + return (void *) bar; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090218_3.c b/gcc/testsuite/gcc.dg/lto/20090218_3.c new file mode 100644 index 00000000000..e1f4df61479 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090218_3.c @@ -0,0 +1,3 @@ +void bar(void) +{ +} diff --git a/gcc/testsuite/gcc.dg/lto/20090219_0.c b/gcc/testsuite/gcc.dg/lto/20090219_0.c new file mode 100644 index 00000000000..6229de7aef1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090219_0.c @@ -0,0 +1,28 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options {{-O3 -fwhopr -fPIC -shared}} } */ + +struct Foo { int f1, f2, f3, f4, f5; }; + +int x = 0; +struct Foo *foo; + +inline void Bar(int n){ + foo[x].f1 = 0; + foo[x].f2 = 0; + foo[x].f3 = 0; + foo[x].f4 = 0; + foo[x].f5 = n; +} + +int ei[1]; +inline void Baz(int n) { + if (ei[n] == 1) + Bar (0); + else if (ei[n] == 0) + Bar (1); +} + +void mumble(void) { + for (;;) + Baz (0); +} diff --git a/gcc/testsuite/gcc.dg/lto/20090312_0.c b/gcc/testsuite/gcc.dg/lto/20090312_0.c new file mode 100644 index 00000000000..8aaad754cc3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090312_0.c @@ -0,0 +1,43 @@ +/* { dg-lto-do link } */ +extern int **foo (void); +extern void mumble (char*, char*, char*); + +static int * +bar (char **sp) +{ + char *s = *sp, *rs = s; + int c; + while (*foo ()[c]) + rs++; + while (c = *rs) + { + if (c || ((c == '"') || (c == '\''))) + { + if (c) + *rs++ = c; + else + mumble (0, "", ""); + } + else if (c || (*foo ()[c] & 1)) + *rs++ = c; + } + if (c) + mumble (0, "", ""); +} + +static void +baz (char *s) +{ + char *args[100]; + while (bar (&s)) + { + mumble (args[0], "", ""); + } +} + +int +main (void) +{ + baz (""); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090312_1.c b/gcc/testsuite/gcc.dg/lto/20090312_1.c new file mode 100644 index 00000000000..882fb0f4157 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090312_1.c @@ -0,0 +1,9 @@ +int **foo (void) +{ + +} + +void mumble (char* a, char* b , char* c) +{ + +} diff --git a/gcc/testsuite/gcc.dg/lto/20090313_0.c b/gcc/testsuite/gcc.dg/lto/20090313_0.c new file mode 100644 index 00000000000..120ba3c50e0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090313_0.c @@ -0,0 +1,9 @@ +void +_cairo_clip_path_reference () { + int a; + __sync_fetch_and_add(&a, 1); +} + +int main(void) { + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090706-1_0.c b/gcc/testsuite/gcc.dg/lto/20090706-1_0.c new file mode 100644 index 00000000000..7877fd350d7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090706-1_0.c @@ -0,0 +1,42 @@ +#include <stdarg.h> + +extern void abort (void); + +void foo (int size, ...) +{ + struct + { + struct + { + char x[size]; + } e; + unsigned r; + } d; + va_list ap; + char c; + int i; + + va_start (ap, size); + d = va_arg (ap, typeof (d)); + c = d.e.x[3]; + if (c != '3') + abort (); + if (d.r != 2602) + abort (); + va_end (ap); +} + +int main (void) +{ + int z = 5, i; + struct { struct { char a[z]; } y; unsigned r; } x; + + x.y.a[0] = '0'; + x.y.a[1] = '1'; + x.y.a[2] = '2'; + x.y.a[3] = '3'; + x.y.a[4] = '4'; + x.r = 2602; + foo (z, x); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090706-2_0.c b/gcc/testsuite/gcc.dg/lto/20090706-2_0.c new file mode 100644 index 00000000000..69da98b5cca --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090706-2_0.c @@ -0,0 +1,16 @@ +extern void abort (void); + +int foo (int size) +{ + int a[size]; + a[size - 10] = 42; + return a[size - 10] + size; +} + +main() +{ + int x = foo (20); + if (x != 62) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090717_0.c b/gcc/testsuite/gcc.dg/lto/20090717_0.c new file mode 100644 index 00000000000..fe13bdf78d4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090717_0.c @@ -0,0 +1,4 @@ +struct variable { + const char *string; +}; +struct variable table[] = { }; diff --git a/gcc/testsuite/gcc.dg/lto/20090717_1.c b/gcc/testsuite/gcc.dg/lto/20090717_1.c new file mode 100644 index 00000000000..bda8138214b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090717_1.c @@ -0,0 +1,11 @@ +struct variable { + const char *string; +}; +extern struct variable table[]; +int main(int argc, char *argv[]) +{ + struct variable *p; + for(p = table; p->string; p++) + ; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090729_0.c b/gcc/testsuite/gcc.dg/lto/20090729_0.c new file mode 100644 index 00000000000..05ae74f872e --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090729_0.c @@ -0,0 +1,4 @@ +/* { dg-lto-options "-w" } */ + +double i; +int j; diff --git a/gcc/testsuite/gcc.dg/lto/20090729_1.c b/gcc/testsuite/gcc.dg/lto/20090729_1.c new file mode 100644 index 00000000000..0a5091ac29e --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090729_1.c @@ -0,0 +1,4 @@ +double j; +int i; +int main () { return i; } + diff --git a/gcc/testsuite/gcc.dg/lto/20090812_0.c b/gcc/testsuite/gcc.dg/lto/20090812_0.c new file mode 100644 index 00000000000..baf20f520a2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090812_0.c @@ -0,0 +1,11 @@ +struct X; +struct Y +{ + struct X *p; + int i; +}; + +void foo (struct Y *p) +{ + p->i = 1; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090812_1.c b/gcc/testsuite/gcc.dg/lto/20090812_1.c new file mode 100644 index 00000000000..e91424492a0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090812_1.c @@ -0,0 +1,26 @@ +/* struct X is complete in this TU, this causes us to not merge Y and + thus assign different alias-sets to them. */ +struct X +{ + int i; +}; +struct Y +{ + struct X *p; + int i; +}; +extern void abort (void); +extern void foo(struct Y *); +int __attribute__((noinline)) bar(struct Y *p) +{ + p->i = 0; + foo (p); + return p->i; +} +int main() +{ + struct Y y; + if (bar (&y) != 1) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090914-1_0.c b/gcc/testsuite/gcc.dg/lto/20090914-1_0.c new file mode 100644 index 00000000000..ef9f7b35182 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090914-1_0.c @@ -0,0 +1,13 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options {{-flto -g -fvar-tracking-assignments}} } */ +/* { dg-suppress-ld-options "-g -fvar-tracking-assignments" } */ + +void foo() +{ + int hex = 0x4; +} + +int main() +{ + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/20090914-2_0.c b/gcc/testsuite/gcc.dg/lto/20090914-2_0.c new file mode 100644 index 00000000000..f78ecf8899f --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20090914-2_0.c @@ -0,0 +1,11 @@ +/* { dg-lto-do run { target x86_64-*-* i?86-*-* } } */ + +/* Doesn't work without this dummy function with -fwhopr. */ +int foo(void) { } + +asm(".text\n" + ".globl main\n" + "\t.type main,@function\n" + "main:\n" + "\txorl %eax, %eax\n" + "\tret\n"); diff --git a/gcc/testsuite/gcc.dg/lto/20091005-1_0.c b/gcc/testsuite/gcc.dg/lto/20091005-1_0.c new file mode 100644 index 00000000000..f4316efbc35 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20091005-1_0.c @@ -0,0 +1,3 @@ +/* { dg-lto-do run } */ + +const int i[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; diff --git a/gcc/testsuite/gcc.dg/lto/20091005-1_1.c b/gcc/testsuite/gcc.dg/lto/20091005-1_1.c new file mode 100644 index 00000000000..52eb8e78b3f --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20091005-1_1.c @@ -0,0 +1,2 @@ +extern int i[10]; +int main () { return i[0]; } diff --git a/gcc/testsuite/gcc.dg/lto/20091005-2_0.c b/gcc/testsuite/gcc.dg/lto/20091005-2_0.c new file mode 100644 index 00000000000..d1485d671d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20091005-2_0.c @@ -0,0 +1,11 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options {{-fstrict-aliasing -flto}} } */ + +typedef struct { } t_commrec; +typedef struct { } t_fft_c; +void +solve_pme(t_commrec *cr) +{ + t_fft_c *ptr; +} +int main () { return 0; } diff --git a/gcc/testsuite/gcc.dg/lto/20091006-1_0.c b/gcc/testsuite/gcc.dg/lto/20091006-1_0.c new file mode 100644 index 00000000000..9b4356edc22 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20091006-1_0.c @@ -0,0 +1,14 @@ +/* { dg-lto-do link } */ + +typedef void (*fnt) (void); +void __attribute__((noinline)) bar (void) {} +extern inline void check3 (void) +{ + bar (); +} +void test (void) +{ + const fnt pcheck3 = check3; + pcheck3 (); +} +int main() { return 0; } diff --git a/gcc/testsuite/gcc.dg/lto/20091006-1_1.c b/gcc/testsuite/gcc.dg/lto/20091006-1_1.c new file mode 100644 index 00000000000..f82f827002a --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/20091006-1_1.c @@ -0,0 +1,2 @@ +extern void bar (void); +void check3 (void) { bar (); } diff --git a/gcc/testsuite/gcc.dg/lto/README b/gcc/testsuite/gcc.dg/lto/README new file mode 100644 index 00000000000..1a13dd92c62 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/README @@ -0,0 +1,35 @@ +This directory contains tests for link-time optimization (LTO). +Tests in this directory may span multiple files, so the naming of +the files is significant. + +The name of every file must end with '_N' where N is an integer. +All the files with the same name base and different _N suffixes +will be compiled separately and linked together to form the final +executable. + +By default, each set of files will be compiled with list of +options listed in LTO_OPTIONS (../../lib/lto.exp), which can be +overwritten in the shell environment or using the 'dg-lto-options' +command in the main file of the set (i.e., the file with _0 +suffix). + +For example, given the files a_0.C a_1.C a_2.C, they will be +compiled as: + +$ g++ -c <flags> a_0.C +$ g++ -c <flags> a_1.C +$ g++ -c <flags> a_2.C +$ g++ -o <executable> a_0.o a_1.o a_2.o + +Tests that do not need more than one file are a special case +where there is a single file named 'foo_0.C'. + +The only supported dg-lto-do option are 'assemble', 'run' and 'link'. +Additionally, these can only be used in the main file. If +'assemble' is used, only the individual object files are +generated. If 'link' is used, the final executable is generated +but not executed (in this case, function main() needs to exist +but it does not need to do anything). If 'run' is used, the +final executable is generated and the resulting binary executed. + +The default value for dg-lto-do is 'run'. diff --git a/gcc/testsuite/gcc.dg/lto/lto.exp b/gcc/testsuite/gcc.dg/lto/lto.exp new file mode 100644 index 00000000000..0e343c19b77 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/lto.exp @@ -0,0 +1,57 @@ +# Copyright (C) 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. +# +# Contributed by Diego Novillo <dnovillo@google.com> + + +# Test link-time optimization across multiple files. +# +# Programs are broken into multiple files. Each one is compiled +# separately with LTO information. The final executable is generated +# by collecting all the generated object files using regular LTO or WHOPR. + +if $tracelevel then { + strace $tracelevel +} + +# Load procedures from common libraries. +load_lib standard.exp +load_lib gcc.exp + +# Load the language-independent compabibility support procedures. +load_lib lto.exp + +gcc_init +lto_init + +# Define an identifier for use with this suite to avoid name conflicts +# with other lto tests running at the same time. +set sid "c_lto" + +# If LTO has not been enabled, bail. +if { ![check_effective_target_lto] } { + return +} + +# Main loop. +foreach src [lsort [find $srcdir/$subdir *_0.c]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + lto-execute $src $sid +} |