summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/lto
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/lto')
-rw-r--r--gcc/testsuite/gcc.dg/lto/20080908_0.c16
-rw-r--r--gcc/testsuite/gcc.dg/lto/20080917_0.c29
-rw-r--r--gcc/testsuite/gcc.dg/lto/20080924_0.c9
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081024_0.c26
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081109_0.c3
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081111_0.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081111_1.c7
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081112_0.c14
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081112_1.c13
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081115_0.c32
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081115_1.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081115_2.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081118_0.c28
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081118_1.c13
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081118_2.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081120-1_0.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081120-1_1.c3
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081120-2_0.c3
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081120-2_1.c2
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081125_0.c6
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081125_1.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081126_0.c8
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081201-1_0.c33
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081201-1_1.c13
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081201-1_2.c7
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081201-2_0.c16
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081201-2_1.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081202-1_0.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081202-1_1.c10
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081202-2_0.c13
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081202-2_1.c16
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081204-1_0.c7
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081204-1_1.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081204-2_0.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081210-1_0.c21
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081212-1_0.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081222_0.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081222_0.h1
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081222_1.c16
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081224_0.c9
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081224_0.h3
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081224_1.c2
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090116_0.c12
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090120_0.c14
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090126-1_0.c7
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090126-2_0.c7
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090206-1_0.c10
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090206-2_0.c18
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090210_0.c6
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090210_1.c22
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090213_0.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090213_1.c6
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090218-1_0.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090218-1_1.c9
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090218-2_0.c3
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090218-2_1.c19
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090218_0.c7
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090218_1.c6
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090218_2.c6
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090218_3.c3
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090219_0.c28
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090312_0.c43
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090312_1.c9
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090313_0.c9
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090706-1_0.c42
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090706-2_0.c16
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090717_0.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090717_1.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090729_0.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090729_1.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090812_0.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090812_1.c26
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090914-1_0.c13
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090914-2_0.c12
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091005-1_0.c3
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091005-1_1.c2
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091005-2_0.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091006-1_0.c14
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091006-1_1.c2
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091006-2_0.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091006-2_1.c1
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091006-2_2.c1
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091013-1_0.c21
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091013-1_1.c111
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091013-1_2.c220
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091014-1_0.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091015-1_0.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091015-1_1.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091015-1_2.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091015-1_a.h2
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091015-1_b.h2
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091016-1_0.c13
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091016-1_1.c18
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091016-1_a.h6
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091017-1_0.c15
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091017-1_1.c6
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091020-1_0.c8
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091020-1_1.c15
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091020-2_0.c18
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091020-2_1.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091020-3_0.c20
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091027-1_0.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091027-1_1.c9
-rw-r--r--gcc/testsuite/gcc.dg/lto/README35
-rw-r--r--gcc/testsuite/gcc.dg/lto/lto.exp57
105 files changed, 1517 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..e842b37f663
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081120-1_0.c
@@ -0,0 +1,5 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-flto -r -nostdlib}} } */
+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..19c4ab34784
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081120-2_0.c
@@ -0,0 +1,3 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-fwhopr -r -nostdlib}} } */
+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..9243da96a79
--- /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 -r -nostdlib}} } */
+
+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..5952b07b76f
--- /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 -r -nostdlib}} } */
+
+/* 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..53446050f95
--- /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 -r -nostdlib}} } */
+
+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..acc00186840
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081212-1_0.c
@@ -0,0 +1,4 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-r -nostdlib}} } */
+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..9c784fe29ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081224_0.c
@@ -0,0 +1,9 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-fwhopr -r -nostdlib -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..9fd83ca0766
--- /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 {-r -nostdlib -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..b2a25b2261c
--- /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 {-r -nostdlib -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..a366c183873
--- /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 -r -nostdlib -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..13cd8861183
--- /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 -r -nostdlib -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..b93dd1fe946
--- /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 -r -nostdlib}} } */
+
+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..906b3c44196
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20090914-2_0.c
@@ -0,0 +1,12 @@
+/* { dg-lto-do run } */
+/* { dg-skip-if "x86 only" { ! { 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/20091006-2_0.c b/gcc/testsuite/gcc.dg/lto/20091006-2_0.c
new file mode 100644
index 00000000000..f8189920cfd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091006-2_0.c
@@ -0,0 +1,4 @@
+/* { dg-lto-do link } */
+
+extern int a[10];
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/20091006-2_1.c b/gcc/testsuite/gcc.dg/lto/20091006-2_1.c
new file mode 100644
index 00000000000..581839344c1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091006-2_1.c
@@ -0,0 +1 @@
+int a[16];
diff --git a/gcc/testsuite/gcc.dg/lto/20091006-2_2.c b/gcc/testsuite/gcc.dg/lto/20091006-2_2.c
new file mode 100644
index 00000000000..a610b2b1292
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091006-2_2.c
@@ -0,0 +1 @@
+extern int a[14];
diff --git a/gcc/testsuite/gcc.dg/lto/20091013-1_0.c b/gcc/testsuite/gcc.dg/lto/20091013-1_0.c
new file mode 100644
index 00000000000..0fecce04f09
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091013-1_0.c
@@ -0,0 +1,21 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-fPIC -r -nostdlib -flto} {-fPIC -r -nostdlib -O2 -flto}} } */
+
+void * HeapAlloc(void*,unsigned int,unsigned long);
+
+typedef struct tagGdiFont GdiFont;
+
+typedef struct tagDC {
+ int xunused;
+ GdiFont *gdiFont;
+ unsigned int font_code_page;
+} DC;
+
+DC *alloc_dc_ptr( void *funcs, unsigned short magic )
+{
+ DC *dc;
+ if (!(dc = HeapAlloc( 0, 0, sizeof(*dc) ))) return ((void *)0);
+ dc->gdiFont = 0;
+ return dc;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091013-1_1.c b/gcc/testsuite/gcc.dg/lto/20091013-1_1.c
new file mode 100644
index 00000000000..68294fa62cb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091013-1_1.c
@@ -0,0 +1,111 @@
+typedef struct HDC__ { int unused; } *HDC;
+typedef struct HFONT__ { int unused; } *HFONT;
+
+typedef struct
+{
+ unsigned int ciACP;
+} CHARSETINFO, *PCHARSETINFO, *LPCHARSETINFO;
+
+typedef struct tagTEXTMETRICW
+{
+ int tmCharSet;
+} TEXTMETRICW, *LPTEXTMETRICW, *PTEXTMETRICW;
+
+struct gdi_obj_funcs
+{
+ void* (*pSelectObject)( void* handle, void* hdc );
+};
+
+typedef struct tagGdiFont GdiFont;
+
+typedef struct tagDC
+{
+ int xunused;
+ GdiFont *gdiFont;
+ unsigned int font_code_page;
+} DC;
+
+extern GdiFont* WineEngCreateFontInstance(DC*, HFONT);
+extern unsigned int WineEngGetTextCharsetInfo(GdiFont *font, void* fs, unsigned int flags);
+extern int WineEngGetTextMetrics(GdiFont*, LPTEXTMETRICW);
+extern void* alloc_gdi_handle( void *obj, unsigned short type, const struct gdi_obj_funcs *funcs );
+
+enum __wine_debug_class
+{
+ __WINE_DBCL_FIXME,
+ __WINE_DBCL_ERR,
+ __WINE_DBCL_WARN,
+ __WINE_DBCL_TRACE,
+
+ __WINE_DBCL_INIT = 7
+};
+
+struct __wine_debug_channel
+{
+ unsigned char flags;
+ char name[15];
+};
+
+extern int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *func,
+ const char *format, ... ) __attribute__((format (printf,4,5)));
+
+static struct __wine_debug_channel __wine_dbch_font = { ~0, "font" };
+static struct __wine_debug_channel * const __wine_dbch___default = &__wine_dbch_font;
+
+static void* FONT_SelectObject( void* handle, void* hdc );
+
+static const struct gdi_obj_funcs font_funcs =
+{
+ FONT_SelectObject,
+};
+
+HFONT CreateFontIndirectW( const void *plf )
+{
+ return alloc_gdi_handle( 0, 6, &font_funcs );
+}
+
+static void update_font_code_page( DC *dc )
+{
+ CHARSETINFO csi;
+ int charset = (unsigned char)1;
+
+ if (dc->gdiFont)
+ charset = WineEngGetTextCharsetInfo( dc->gdiFont, ((void *)0), 0 );
+
+ if (TranslateCharsetInfo( ((void *)(unsigned long)((unsigned long)charset)), &csi, 1) )
+ dc->font_code_page = csi.ciACP;
+ else {
+ switch(charset) {
+ case (unsigned char)1:
+ dc->font_code_page = GetACP();
+ break;
+
+ case (unsigned char)246:
+ dc->font_code_page = 0;
+ break;
+
+ default:
+ do { if((((__wine_dbch___default))->flags & (1 << __WINE_DBCL_FIXME))) { struct __wine_debug_channel * const __dbch = (__wine_dbch___default); const enum __wine_debug_class __dbcl = __WINE_DBCL_FIXME; wine_dbg_log( __dbcl, __dbch, __FUNCTION__, "Can't find codepage for charset %d\n", charset); } } while(0);
+ dc->font_code_page = 0;
+ break;
+ }
+ }
+
+ do { if((((__wine_dbch___default))->flags & (1 << __WINE_DBCL_TRACE))) { struct __wine_debug_channel * const __dbch = (__wine_dbch___default); const enum __wine_debug_class __dbcl = __WINE_DBCL_TRACE; wine_dbg_log( __dbcl, __dbch, __FUNCTION__, "charset %d => cp %d\n", charset, dc->font_code_page); } } while(0);
+}
+
+static void* FONT_SelectObject( void* handle, void* hdc )
+{
+ DC *dc;
+
+ dc->gdiFont = WineEngCreateFontInstance( dc, handle );
+ update_font_code_page( dc );
+ return 0;
+}
+
+int GetTextMetricsW( HDC hdc, TEXTMETRICW *metrics )
+{
+ DC * dc;
+ return WineEngGetTextMetrics(dc->gdiFont, metrics);
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091013-1_2.c b/gcc/testsuite/gcc.dg/lto/20091013-1_2.c
new file mode 100644
index 00000000000..55f8ca1b46d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091013-1_2.c
@@ -0,0 +1,220 @@
+typedef struct HDC__ { int unused; } *HDC;
+typedef struct HFONT__ { int unused; } *HFONT;
+
+void* HeapAlloc(void*,unsigned int,unsigned long);
+
+typedef struct tagLOGFONTW
+{
+ int lfPitchAndFamily;
+ unsigned short lfFaceName[32];
+} LOGFONTW, *PLOGFONTW, *LPLOGFONTW;
+
+typedef struct tagGdiFont GdiFont;
+typedef struct tagDC DC;
+
+extern unsigned int WineEngGetFontData(GdiFont*, unsigned int, unsigned int, void*, unsigned int);
+
+struct list
+{
+ struct list *next;
+ struct list *prev;
+};
+
+typedef struct FT_FaceRec_
+{
+ signed long face_flags;
+} FT_FaceRec, *FT_Face;
+
+typedef struct { } GM;
+
+typedef struct { } FMAT2;
+
+typedef struct {
+ unsigned int hash;
+ LOGFONTW lf;
+ int can_use_bitmap;
+} FONT_DESC;
+
+
+
+typedef struct tagHFONTLIST {
+ struct list entry;
+ HFONT hfont;
+} HFONTLIST;
+
+typedef struct {
+ struct list entry;
+ void *face;
+ GdiFont *font;
+} CHILD_FONT;
+
+
+struct tagGdiFont {
+ struct list entry;
+ GM **gm;
+ struct list hfontlist;
+ struct list child_fonts;
+
+ FT_Face ft_face;
+ FONT_DESC font_desc;
+ long ppem;
+};
+
+
+
+static struct list gdi_font_list = { &(gdi_font_list), &(gdi_font_list) };
+
+
+
+
+static int get_glyph_index_linked(GdiFont *font, unsigned int c, GdiFont **linked_font, unsigned int *glyph);
+static long load_VDMX(GdiFont*, long);
+
+extern int f1(void*,int);
+
+static FT_Face OpenFontFace(GdiFont *font, void *face, long width, long height)
+{
+ FT_Face ft_face;
+
+ font->ppem = load_VDMX(font, height);
+ if(font->ppem == 0)
+ font->ppem = f1(ft_face, height);
+ return ft_face;
+}
+
+
+static GdiFont *alloc_font(void)
+{
+ GdiFont *ret = HeapAlloc(0, 0x00000008, sizeof(*ret));
+ ret->gm = HeapAlloc(0, 0x00000008, sizeof(GM*));
+ return ret;
+}
+
+
+static long load_VDMX(GdiFont *font,long height)
+{
+ unsigned short hdr[3];
+
+ WineEngGetFontData(font, 0x42424242, 0, hdr, 6);
+ return 0;
+}
+
+static int fontcmp(const GdiFont *font, FONT_DESC *fd)
+{
+ if(font->font_desc.hash != fd->hash) return 1;
+ if(memcmp(&font->font_desc.lf, &fd->lf, __builtin_offsetof (LOGFONTW, lfFaceName))) return 1;
+ if(!font->font_desc.can_use_bitmap != !fd->can_use_bitmap) return 1;
+ return strcmpiW(font->font_desc.lf.lfFaceName, fd->lf.lfFaceName);
+}
+
+static GdiFont *find_in_cache(HFONT hfont, const LOGFONTW *plf, const FMAT2 *pmat, int can_use_bitmap)
+{
+ GdiFont *ret;
+ FONT_DESC fd;
+ HFONTLIST *hflist;
+ struct list *font_elem_ptr, *hfontlist_elem_ptr;
+
+ fd.lf = *plf;
+ fd.can_use_bitmap = can_use_bitmap;
+
+
+ for ((font_elem_ptr) = (&gdi_font_list)->next; (font_elem_ptr) != (&gdi_font_list); (font_elem_ptr) = (font_elem_ptr)->next) {
+ ret = ((struct tagGdiFont *)((char *)(font_elem_ptr) - (unsigned long)(&((struct tagGdiFont *)0)->entry)));
+ if(!fontcmp(ret, &fd)) {
+ if(!can_use_bitmap && !( ret->ft_face->face_flags & ( 1L << 0 ) )) continue;
+ for ((hfontlist_elem_ptr) = (&ret->hfontlist)->next; (hfontlist_elem_ptr) != (&ret->hfontlist); (hfontlist_elem_ptr) = (hfontlist_elem_ptr)->next) {
+ hflist = ((struct tagHFONTLIST *)((char *)(hfontlist_elem_ptr) - (unsigned long)(&((struct tagHFONTLIST *)0)->entry)));
+ if(hflist->hfont == hfont)
+ return ret;
+ }
+ hflist = HeapAlloc(0, 0, sizeof(*hflist));
+ hflist->hfont = hfont;
+ return ret;
+ }
+ }
+
+ while(font_elem_ptr) {
+ ret = ((struct tagGdiFont *)((char *)(font_elem_ptr) - (unsigned long)(&((struct tagGdiFont *)0)->entry)));
+ if(!fontcmp(ret, &fd)) {
+ if(!can_use_bitmap && !( ret->ft_face->face_flags & ( 1L << 0 ) )) continue;
+ hflist = HeapAlloc(0, 0, sizeof(*hflist));
+ hflist->hfont = hfont;
+ return ret;
+ }
+ }
+ return ((void *)0);
+}
+
+
+
+
+GdiFont *WineEngCreateFontInstance(DC *dc, HFONT hfont)
+{
+ GdiFont *ret;
+ int can_use_bitmap;
+ LOGFONTW lf;
+ FMAT2 dcmat;
+
+ if((ret = find_in_cache(hfont, &lf, &dcmat, can_use_bitmap)) != ((void *)0))
+ return ret;
+ return alloc_font();
+}
+
+extern unsigned int f(void*,unsigned int g);
+
+static unsigned int get_glyph_index(void*font, unsigned int glyph)
+{
+ return f(font, glyph);
+}
+
+unsigned int WineEngGetGlyphOutline(GdiFont *incoming_font, unsigned int glyph, unsigned int format,
+ void* lpgm, unsigned int buflen, void* buf,
+ const void* lpmat)
+{
+ unsigned int glyph_index;
+
+ get_glyph_index_linked(incoming_font, glyph, &incoming_font, &glyph_index);
+ return 0;
+}
+
+static int load_child_font(GdiFont *font, CHILD_FONT *child)
+{
+ child->font = alloc_font();
+ child->font->ft_face = OpenFontFace(child->font, child->face, 0, -font->ppem);
+ if(!child->font->ft_face)
+ return 0;
+ return 1;
+}
+
+static int get_glyph_index_linked(GdiFont *font, unsigned int c, GdiFont **linked_font, unsigned int *glyph)
+{
+ unsigned int g;
+ CHILD_FONT *child_font;
+
+ for ((child_font) = ((CHILD_FONT *)((char *)((&font->child_fonts)->next) - (unsigned long)(&((CHILD_FONT *)0)->entry))); &(child_font)->entry != (&font->child_fonts); (child_font) = ((CHILD_FONT *)((char *)((child_font)->entry.next) - (unsigned long)(&((CHILD_FONT *)0)->entry))))
+ {
+ if(!load_child_font(font, child_font))
+ continue;
+
+ g = get_glyph_index(child_font->font, c);
+ if(g) {
+ *glyph = g;
+ *linked_font = child_font->font;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+unsigned int WineEngGetFontData(GdiFont *font, unsigned int table, unsigned int offset, void* buf,
+ unsigned int cbData)
+{
+ unsigned long len;
+ load_sfnt_table(font->ft_face, table, offset, buf, &len);
+ return len;
+}
+
+int WineEngGetLinkedHFont(DC *dc, unsigned short c, HFONT *new_hfont, unsigned int *glyph) {
+ return get_glyph_index_linked(0, 0, 0, 0);
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091014-1_0.c b/gcc/testsuite/gcc.dg/lto/20091014-1_0.c
new file mode 100644
index 00000000000..975214e0430
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091014-1_0.c
@@ -0,0 +1,4 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-fPIC -r -nostdlib -flto}} } */
+
+/* Empty file. See PR41173. */
diff --git a/gcc/testsuite/gcc.dg/lto/20091015-1_0.c b/gcc/testsuite/gcc.dg/lto/20091015-1_0.c
new file mode 100644
index 00000000000..d55ebcf4042
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091015-1_0.c
@@ -0,0 +1,5 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-fPIC -r -nostdlib -O2 -flto} {-fPIC -r -nostdlib -O2 -fwhopr}} } */
+
+#include "20091015-1_b.h"
+void diagnostic_initialize (FILE **stream) { *stream = stderr; }
diff --git a/gcc/testsuite/gcc.dg/lto/20091015-1_1.c b/gcc/testsuite/gcc.dg/lto/20091015-1_1.c
new file mode 100644
index 00000000000..c000518f45d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091015-1_1.c
@@ -0,0 +1,4 @@
+#include "20091015-1_a.h"
+#include "20091015-1_b.h"
+void ggc_print_common_statistics (FILE *stream) {
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20091015-1_2.c b/gcc/testsuite/gcc.dg/lto/20091015-1_2.c
new file mode 100644
index 00000000000..fd10680866a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091015-1_2.c
@@ -0,0 +1,5 @@
+#include "20091015-1_a.h"
+#include "20091015-1_b.h"
+void debug_optab_libfuncs (void) {
+foo (stderr, 4 );
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20091015-1_a.h b/gcc/testsuite/gcc.dg/lto/20091015-1_a.h
new file mode 100644
index 00000000000..61e56c9a95f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091015-1_a.h
@@ -0,0 +1,2 @@
+struct _IO_FILE { int _flags;
+};
diff --git a/gcc/testsuite/gcc.dg/lto/20091015-1_b.h b/gcc/testsuite/gcc.dg/lto/20091015-1_b.h
new file mode 100644
index 00000000000..88139027467
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091015-1_b.h
@@ -0,0 +1,2 @@
+typedef struct _IO_FILE FILE;
+extern struct _IO_FILE *stderr;
diff --git a/gcc/testsuite/gcc.dg/lto/20091016-1_0.c b/gcc/testsuite/gcc.dg/lto/20091016-1_0.c
new file mode 100644
index 00000000000..39a04b950bf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091016-1_0.c
@@ -0,0 +1,13 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-fPIC -r -nostdlib -O2 -flto}} } */
+
+typedef struct VEC_constructor_elt_gc { } VEC_constructor_elt_gc;
+#include "20091016-1_a.h"
+struct stmt_tree_s {
+ tree x_cur_stmt_list;
+};
+void *add_stmt (struct stmt_tree_s *x)
+{
+ return &x->x_cur_stmt_list;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091016-1_1.c b/gcc/testsuite/gcc.dg/lto/20091016-1_1.c
new file mode 100644
index 00000000000..06389b8e309
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091016-1_1.c
@@ -0,0 +1,18 @@
+typedef struct VEC_constructor_elt_gcx { } VEC_constructor_elt_gc;
+#include "20091016-1_a.h"
+struct gcc_target {
+ void (* builtin_vec_perm) (tree*);
+};
+extern struct gcc_target targetm;
+void dwarf2out_begin_prologue (tree t)
+{
+ (*targetm.builtin_vec_perm) (&t);
+}
+struct die_arg_entry_struct {
+ tree arg;
+};
+void *gt_pch_p_20VEC_die_arg_entry_gc (struct die_arg_entry_struct *vec)
+{
+ return &(vec->arg);
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091016-1_a.h b/gcc/testsuite/gcc.dg/lto/20091016-1_a.h
new file mode 100644
index 00000000000..8eefed5cfad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091016-1_a.h
@@ -0,0 +1,6 @@
+typedef union tree_node *tree;
+union tree_node {
+ tree * use;
+ VEC_constructor_elt_gc *elts;
+};
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091017-1_0.c b/gcc/testsuite/gcc.dg/lto/20091017-1_0.c
new file mode 100644
index 00000000000..ec4c62e4d7c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091017-1_0.c
@@ -0,0 +1,15 @@
+/* { dg-lto-do run } */
+
+struct X {
+ int i;
+};
+extern void foo (void *);
+extern void abort (void);
+int main ()
+{
+ struct X *p;
+ foo(&p);
+ if (p != (struct X *)0)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20091017-1_1.c b/gcc/testsuite/gcc.dg/lto/20091017-1_1.c
new file mode 100644
index 00000000000..23e5992bde6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091017-1_1.c
@@ -0,0 +1,6 @@
+struct X;
+void foo (void *q)
+{
+ struct X **p = (struct X **)q;
+ *p = (struct X *)0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20091020-1_0.c b/gcc/testsuite/gcc.dg/lto/20091020-1_0.c
new file mode 100644
index 00000000000..c9bcb565d96
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091020-1_0.c
@@ -0,0 +1,8 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-fPIC -r -nostdlib -flto}} } */
+
+typedef struct {
+ int NumPackStreams;
+} CSzAr;
+void cli_7unz (CSzAr db) { }
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091020-1_1.c b/gcc/testsuite/gcc.dg/lto/20091020-1_1.c
new file mode 100644
index 00000000000..899183a2459
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091020-1_1.c
@@ -0,0 +1,15 @@
+typedef struct {
+ int NumPackStreams;
+} CSzAr;
+typedef struct {
+ CSzAr db;
+} CSzArEx;
+int SzArEx_Init(CSzArEx *p)
+{
+ return p->db.NumPackStreams;
+}
+int SzArEx_GetFolderFullPackSize(const CSzArEx *p)
+{
+ return p->db.NumPackStreams;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091020-2_0.c b/gcc/testsuite/gcc.dg/lto/20091020-2_0.c
new file mode 100644
index 00000000000..fb1a82bb8c6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091020-2_0.c
@@ -0,0 +1,18 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-fPIC -r -nostdlib -flto}} } */
+
+typedef struct {
+ int NumPackStreams;
+} CSzAr;
+typedef struct {
+ CSzAr db;
+} CSzArEx;
+int SzArEx_Init(CSzArEx *p)
+{
+ return p->db.NumPackStreams;
+}
+int SzArEx_GetFolderFullPackSize(const CSzArEx *p)
+{
+ return p->db.NumPackStreams;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091020-2_1.c b/gcc/testsuite/gcc.dg/lto/20091020-2_1.c
new file mode 100644
index 00000000000..9174f26c35c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091020-2_1.c
@@ -0,0 +1,5 @@
+typedef struct {
+ int NumPackStreams;
+} CSzAr;
+void cli_7unz (CSzAr db) { }
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091020-3_0.c b/gcc/testsuite/gcc.dg/lto/20091020-3_0.c
new file mode 100644
index 00000000000..441a7b91a7f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091020-3_0.c
@@ -0,0 +1,20 @@
+/* { dg-lto-do assemble } */
+
+typedef __SIZE_TYPE__ size_t;
+static int stack_dir;
+static void find_stack_direction ()
+{
+ static char *addr = ((void *)0);
+ auto char dummy;
+ if (addr == ((void *)0))
+ {
+ addr = &(dummy);
+ find_stack_direction ();
+ }
+}
+void * C_alloca (size_t size)
+{
+ if (stack_dir == 0)
+ find_stack_direction ();
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091027-1_0.c b/gcc/testsuite/gcc.dg/lto/20091027-1_0.c
new file mode 100644
index 00000000000..f2669fe0f00
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091027-1_0.c
@@ -0,0 +1,11 @@
+/* { dg-lto-do link } */
+/* { dg-extra-ld-options "-r -nostdlib" } */
+
+typedef struct _xmlDict xmlDict;
+struct _xmlDict {
+ int ref_counter;
+};
+void xmlDictCreate(void) {
+ xmlDict * dict;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20091027-1_1.c b/gcc/testsuite/gcc.dg/lto/20091027-1_1.c
new file mode 100644
index 00000000000..d92394cc591
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091027-1_1.c
@@ -0,0 +1,9 @@
+typedef struct _xmlDict xmlDict;
+struct _xmlDoc {
+ struct _xmlDict *dict;
+};
+void xmlAddEntity(struct _xmlDoc *a) {
+ xmlDict * dict = a->dict;
+ xmlHashCreateDict(0, dict);
+}
+
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
+}