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.c23
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081212-1_0.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20081222_0.c12
-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.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090206-2_0.c18
-rw-r--r--gcc/testsuite/gcc.dg/lto/20090210_0.c8
-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.c11
-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.c13
-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.c5
-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/20091209-1_0.c23
-rw-r--r--gcc/testsuite/gcc.dg/lto/20091216-1_0.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100103-1_0.c8
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100103-2_0.c12
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100104_0.c8
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100108_0.c9
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100227-1_0.c14
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100227-1_1.c8
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100423-1_0.c10
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100423-1_1.c7
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100423-2_0.c25
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100423-2_1.c20
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100426_0.c7
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100430-1_0.c14
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100518_0.c14
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100603-1_0.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100603-2_0.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100603-3_0.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100709-1_0.c7
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100709-1_1.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100720-1_0.c22
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100720-1_1.c15
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100720-2_0.c23
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100720-2_1.c16
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100720-3_0.c24
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100720-3_1.c17
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100720-4_0.c15
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100722-1_0.c6
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100724-1_0.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100724-1_1.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100825-1_0.c57
-rw-r--r--gcc/testsuite/gcc.dg/lto/20101009-1_0.c16
-rw-r--r--gcc/testsuite/gcc.dg/lto/20101009-2_0.c3
-rw-r--r--gcc/testsuite/gcc.dg/lto/20101009-2_1.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20101009-2_2.c5
-rw-r--r--gcc/testsuite/gcc.dg/lto/20101125-1_0.c24
-rw-r--r--gcc/testsuite/gcc.dg/lto/20101125-1_1.c17
-rw-r--r--gcc/testsuite/gcc.dg/lto/20110201-1_0.c19
-rw-r--r--gcc/testsuite/gcc.dg/lto/README35
-rw-r--r--gcc/testsuite/gcc.dg/lto/const-uniq_0.c16
-rw-r--r--gcc/testsuite/gcc.dg/lto/const-uniq_1.c23
-rw-r--r--gcc/testsuite/gcc.dg/lto/ipacp_0.c15
-rw-r--r--gcc/testsuite/gcc.dg/lto/ipacp_1.c12
-rw-r--r--gcc/testsuite/gcc.dg/lto/ipareference2_0.c16
-rw-r--r--gcc/testsuite/gcc.dg/lto/ipareference2_1.c13
-rw-r--r--gcc/testsuite/gcc.dg/lto/ipareference_0.c26
-rw-r--r--gcc/testsuite/gcc.dg/lto/ipareference_1.c14
-rw-r--r--gcc/testsuite/gcc.dg/lto/lto.exp59
-rw-r--r--gcc/testsuite/gcc.dg/lto/materialize-1_0.c8
-rw-r--r--gcc/testsuite/gcc.dg/lto/materialize-1_1.c22
-rw-r--r--gcc/testsuite/gcc.dg/lto/noreturn-1_0.c10
-rw-r--r--gcc/testsuite/gcc.dg/lto/noreturn-1_1.c6
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr27898_0.c8
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr27898_1.c3
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr28706_0.c12
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr28706_1.c9
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr28712_0.c16
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr28712_1.c12
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr28712_2.c13
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr34989-1_0.c10
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr34989-1_1.c1
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr45721_0.c4
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr45721_1.c2
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr45736_0.c16
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr46940_0.c11
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr46940_1.c7
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr47188_0.c7
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr47188_1.c8
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr47259_0.c13
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr47259_1.c9
-rw-r--r--gcc/testsuite/gcc.dg/lto/pr47924_0.c19
174 files changed, 2411 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 000000000..3bc1c3a72
--- /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 000000000..ac0891081
--- /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 000000000..db7745077
--- /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 000000000..9fa297abc
--- /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 000000000..eaa25f673
--- /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 000000000..899689c1b
--- /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 000000000..2b7fee586
--- /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 000000000..a90aa70b3
--- /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 000000000..2ba1cb940
--- /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 000000000..c9f4c803f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081115_0.c
@@ -0,0 +1,32 @@
+/* { dg-lto-options {{-O2 -DOPTIMIZE -flto -flto-partition=1to1} {-O0 -flto -flto-partition=1to1}} } */
+
+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 000000000..62ffa5200
--- /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 000000000..0ccecd736
--- /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 000000000..b37eb31a4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081118_0.c
@@ -0,0 +1,28 @@
+/* { dg-lto-options {{-O2 -DOPTIMIZE -flto -flto-partition=1to1} {-O0 -flto -flto-partition=1to1}} } */
+
+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 000000000..f0a8c3c87
--- /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 000000000..32ce432a1
--- /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 000000000..e842b37f6
--- /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 000000000..73d25000c
--- /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 000000000..e2e11d64b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081120-2_0.c
@@ -0,0 +1,3 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-flto -flto-partition=1to1 -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 000000000..c81f8c7fd
--- /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 000000000..4b2e7191f
--- /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 000000000..1fcf4e7d3
--- /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 000000000..9243da96a
--- /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 000000000..b6896446d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081201-1_0.c
@@ -0,0 +1,33 @@
+/* { dg-lto-options {{-O2 -DOPTIMIZE -flto -flto-partition=1to1} {-O0 -flto -flto-partition=1to1}} } */
+
+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 000000000..f0a8c3c87
--- /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 000000000..bcf87a749
--- /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 000000000..fd021eb1c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081201-2_0.c
@@ -0,0 +1,16 @@
+/* { dg-lto-options {{-O3 -flto -flto-partition=1to1}} } */
+
+/* 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 000000000..f93e1fd02
--- /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 000000000..1bdb91f81
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081202-1_0.c
@@ -0,0 +1,11 @@
+/* { dg-lto-options {{-flto -flto-partition=1to1 -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 000000000..2f6777864
--- /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 000000000..9d34f740b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081202-2_0.c
@@ -0,0 +1,13 @@
+/* { dg-lto-options {{-flto -flto-partition=1to1 -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 000000000..adb150245
--- /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 000000000..a4b25ff82
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081204-1_0.c
@@ -0,0 +1,7 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-flto -flto-partition=1to1 -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 000000000..95761ea15
--- /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 000000000..53446050f
--- /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 000000000..34e0ec400
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081210-1_0.c
@@ -0,0 +1,23 @@
+#if defined(_LP64)
+typedef unsigned long int uintptr_t;
+#elif defined (_WIN64)
+typedef unsigned long 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 000000000..acc001868
--- /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 000000000..091647a01
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081222_0.c
@@ -0,0 +1,12 @@
+/* { dg-require-alias "" } */
+#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 000000000..4c26f4616
--- /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 000000000..e8f925442
--- /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 000000000..d050e2312
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20081224_0.c
@@ -0,0 +1,9 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-flto -flto-partition=1to1 -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 000000000..7b62a0796
--- /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 000000000..3e1ff3410
--- /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 000000000..5bb3a919a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20090116_0.c
@@ -0,0 +1,12 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-O1 -flto -flto-partition=1to1 -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 000000000..6c69a9918
--- /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 000000000..01a129940
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20090126-1_0.c
@@ -0,0 +1,7 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-O0 -flto -flto-partition=1to1}} } */
+/* { dg-extra-ld-options {-r -nostdlib -O2 -flto -flto-partition=1to1} } */
+
+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 000000000..2239412d1
--- /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 -flto -flto-partition=1to1}} } */
+/* { dg-extra-ld-options {-fno-PIC -r -nostdlib -O2 -flto -flto-partition=1to1} } */
+
+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 000000000..c9fc97334
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20090206-1_0.c
@@ -0,0 +1,11 @@
+/* { dg-lto-do link } */
+/* { dg-skip-if "" { ! { i?86-*-linux* x86_64-*-linux* } } { "*" } { "" } } */
+/* { dg-lto-options {{-fPIC -r -nostdlib -flto -flto-partition=1to1 -msse2}} } */
+/* { dg-require-effective-target sse2 } */
+/* { 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 000000000..4ca80ea48
--- /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 {{-flto -flto-partition=1to1 -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 000000000..2c858a67d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20090210_0.c
@@ -0,0 +1,8 @@
+/* { dg-lto-do run } */
+/* { dg-suppress-ld-options {-fPIC} } */
+/* { dg-require-effective-target tls } */
+/* { dg-extra-ld-options "-pthread" { target *-*-solaris2.[89] } } */
+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 000000000..960411972
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20090210_1.c
@@ -0,0 +1,22 @@
+/* { dg-options "-fPIC" { target { ! sparc*-*-* } } } */
+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 000000000..6387a0e47
--- /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 000000000..4a852efd1
--- /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 000000000..1dc9ee085
--- /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 000000000..33d4fb000
--- /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 000000000..8857e7a6d
--- /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 000000000..119fbe4a1
--- /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 000000000..c4390fa1f
--- /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 000000000..c28b84ada
--- /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 000000000..e9f835f36
--- /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 000000000..e1f4df614
--- /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 000000000..81a93e6da
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20090219_0.c
@@ -0,0 +1,28 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-O3 -flto -flto-partition=1to1 -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 000000000..8aaad754c
--- /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 000000000..882fb0f41
--- /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 000000000..226e64713
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20090313_0.c
@@ -0,0 +1,11 @@
+/* { dg-lto-options "-mcpu=v9" { target sparc*-*-* } } */
+/* { dg-require-effective-target sync_char_short } */
+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 000000000..7877fd350
--- /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 000000000..69da98b5c
--- /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 000000000..fe13bdf78
--- /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 000000000..bda813821
--- /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 000000000..05ae74f87
--- /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 000000000..0a5091ac2
--- /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 000000000..baf20f520
--- /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 000000000..e91424492
--- /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 000000000..ef9f7b351
--- /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 000000000..d0510d609
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20090914-2_0.c
@@ -0,0 +1,13 @@
+/* { dg-lto-do run } */
+/* { dg-skip-if "x86 only" { ! { x86_64-*-* i?86-*-* } } { "*" } { "" } } */
+/* { dg-skip-if "no .type" { *-*-darwin* } { "*" } { "" } } */
+
+/* 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 000000000..f4316efbc
--- /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 000000000..52eb8e78b
--- /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 000000000..d1485d671
--- /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 000000000..9b4356edc
--- /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 000000000..f82f82700
--- /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 000000000..abe12c40c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091006-2_0.c
@@ -0,0 +1,5 @@
+/* { dg-lto-do link } */
+/* { dg-extra-ld-options "-w" } */
+
+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 000000000..581839344
--- /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 000000000..a610b2b12
--- /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 000000000..0fecce04f
--- /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 000000000..68294fa62
--- /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 000000000..55f8ca1b4
--- /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 000000000..975214e04
--- /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 000000000..1cc4b78b3
--- /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 -flto -flto-partition=1to1}} } */
+
+#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 000000000..c000518f4
--- /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 000000000..fd1068086
--- /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 000000000..61e56c9a9
--- /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 000000000..881390274
--- /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 000000000..39a04b950
--- /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 000000000..06389b8e3
--- /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 000000000..8eefed5cf
--- /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 000000000..ec4c62e4d
--- /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 000000000..23e5992bd
--- /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 000000000..c9bcb565d
--- /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 000000000..899183a24
--- /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 000000000..fb1a82bb8
--- /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 000000000..9174f26c3
--- /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 000000000..441a7b91a
--- /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 000000000..f2669fe0f
--- /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 000000000..d92394cc5
--- /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/20091209-1_0.c b/gcc/testsuite/gcc.dg/lto/20091209-1_0.c
new file mode 100644
index 000000000..5aa2fe0b0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091209-1_0.c
@@ -0,0 +1,23 @@
+/* Stream an indirect edge in and out. */
+
+/* { dg-lto-do link } */
+/* { dg-lto-options {{ -O3 -fno-early-inlining -flto }} } */
+
+volatile int something;
+
+static void hooray ()
+{
+ something = 1;
+}
+
+static void hiphip (void (*f)())
+{
+ something = 2;
+ f ();
+}
+
+int main (int argc, int *argv[])
+{
+ hiphip (hooray);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20091216-1_0.c b/gcc/testsuite/gcc.dg/lto/20091216-1_0.c
new file mode 100644
index 000000000..7bcf1f38d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20091216-1_0.c
@@ -0,0 +1,11 @@
+/* { dg-lto-do run } */
+
+#include "../nop.h"
+
+asm (".globl start_\nstart_: " NOP);
+
+int
+main ()
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100103-1_0.c b/gcc/testsuite/gcc.dg/lto/20100103-1_0.c
new file mode 100644
index 000000000..8e1b48417
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100103-1_0.c
@@ -0,0 +1,8 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-funsigned-char -flto} {-fsigned-char -flto}} } */
+
+char *foo;
+int main()
+{
+ foo = "bar";
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100103-2_0.c b/gcc/testsuite/gcc.dg/lto/20100103-2_0.c
new file mode 100644
index 000000000..1fb6a7b3e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100103-2_0.c
@@ -0,0 +1,12 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-O -flto -funsigned-char} {-O -flto -fsigned-char}} } */
+
+char p[32] = "";
+int main ()
+{
+ if (__builtin___strcpy_chk (p + 1, "vwxyz",
+ __builtin_object_size (p + 1, 0)) != p + 1)
+ __builtin_abort ();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20100104_0.c b/gcc/testsuite/gcc.dg/lto/20100104_0.c
new file mode 100644
index 000000000..c17e7682f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100104_0.c
@@ -0,0 +1,8 @@
+/* { dg-lto-do assemble } */
+/* The problem with this testcase is that we were missing an undefined
+ reference to c_common_attribute_table. This can be tested with
+ GNUTARGET=plugin nm --plugin liblto_plugin.so 20100104_0.o
+ but we don't have support in the testsuite for doing it. */
+
+extern int c_common_attribute_table[];
+void *foobar = c_common_attribute_table;
diff --git a/gcc/testsuite/gcc.dg/lto/20100108_0.c b/gcc/testsuite/gcc.dg/lto/20100108_0.c
new file mode 100644
index 000000000..73f44ec05
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100108_0.c
@@ -0,0 +1,9 @@
+/* { dg-lto-do assemble } */
+/* The problem with this testcase is that we were missing an undefined
+ reference to flag_exceptions. This can be tested with
+ GNUTARGET=plugin nm --plugin liblto_plugin.so 20100108_0.o
+ but we don't have support in the testsuite for doing it. */
+
+extern int flag_exceptions;
+static int *foo = &flag_exceptions;
+int **bar = &foo;
diff --git a/gcc/testsuite/gcc.dg/lto/20100227-1_0.c b/gcc/testsuite/gcc.dg/lto/20100227-1_0.c
new file mode 100644
index 000000000..4145c7001
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100227-1_0.c
@@ -0,0 +1,14 @@
+/* { dg-lto-do link } */
+/* { dg-extra-ld-options "-w" } */
+
+/* Make sure we do not ICE on the invalid re-declaration of s. */
+
+extern void f(void);
+const char *s = "Hello, world!";
+
+int main(void)
+{
+ f();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20100227-1_1.c b/gcc/testsuite/gcc.dg/lto/20100227-1_1.c
new file mode 100644
index 000000000..a10ba0259
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100227-1_1.c
@@ -0,0 +1,8 @@
+extern int puts(const char *);
+extern const char s[];
+
+void f(void)
+{
+ puts(s);
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20100423-1_0.c b/gcc/testsuite/gcc.dg/lto/20100423-1_0.c
new file mode 100644
index 000000000..1963c1fee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100423-1_0.c
@@ -0,0 +1,10 @@
+/* { dg-lto-do run } */
+
+struct bar {int x;};
+extern struct bar foo(void);
+int main()
+{
+ struct bar x=foo();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20100423-1_1.c b/gcc/testsuite/gcc.dg/lto/20100423-1_1.c
new file mode 100644
index 000000000..8b159d2cb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100423-1_1.c
@@ -0,0 +1,7 @@
+typedef struct{int x;} bar;
+bar foo (void)
+{
+ bar x;
+ return x;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20100423-2_0.c b/gcc/testsuite/gcc.dg/lto/20100423-2_0.c
new file mode 100644
index 000000000..f546757c2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100423-2_0.c
@@ -0,0 +1,25 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-O2 -flto -flto-partition=none} {-O2 -flto -flto-partition=1to1} {-O3 -flto -flto-partition=none} {-O3 -flto -flto-partition=1to1}} } */
+
+#include <stdio.h>
+
+typedef unsigned char uch;
+extern uch inbuf[];
+unsigned insize;
+char *progname;
+extern void read_error (void);
+int fill_inbuf(int eof_ok)
+{
+ if (insize == 0)
+ {
+ if (eof_ok)
+ return -1;
+ read_error();
+ }
+ return inbuf[0];
+}
+void read_error(void)
+{
+ fprintf(stderr, "\n%s: ", progname);
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20100423-2_1.c b/gcc/testsuite/gcc.dg/lto/20100423-2_1.c
new file mode 100644
index 000000000..546de6573
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100423-2_1.c
@@ -0,0 +1,20 @@
+typedef unsigned char uch;
+uch inbuf[8];
+extern unsigned insize;
+unsigned inptr;
+int to_stdout = 0;
+int force = 0;
+extern int fill_inbuf (int);
+int get_method(int in)
+{
+ char magic[2];
+ if (force && to_stdout)
+ magic[0] = (char)(inptr < insize ? inbuf[inptr++] : fill_inbuf(1));
+ else
+ magic[1] = (char)(inptr < insize ? inbuf[inptr++] : fill_inbuf(0));
+}
+int main()
+{
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20100426_0.c b/gcc/testsuite/gcc.dg/lto/20100426_0.c
new file mode 100644
index 000000000..e1dc06f96
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100426_0.c
@@ -0,0 +1,7 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-r -nostdlib -flto -g}} } */
+
+long Perl_my_htonl (long l)
+{
+ union { } u;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100430-1_0.c b/gcc/testsuite/gcc.dg/lto/20100430-1_0.c
new file mode 100644
index 000000000..d2e79c629
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100430-1_0.c
@@ -0,0 +1,14 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-O2 -fprofile-arcs -flto -r -nostdlib}} } */
+
+void
+expand_stmt_with_iterators_1 (void)
+{
+ extern void expand_expr_stmt (void);
+ expand_expr_stmt ();
+}
+void
+iterator_expand (void)
+{
+ expand_stmt_with_iterators_1 ();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100518_0.c b/gcc/testsuite/gcc.dg/lto/20100518_0.c
new file mode 100644
index 000000000..c0e9c8be2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100518_0.c
@@ -0,0 +1,14 @@
+/* { dg-lto-do link } */
+/* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } { "*" } { "" } } */
+/* Forgot to steam in/out the number of labels for asm goto. PR44184. */
+
+extern int printf (__const char *__restrict __format, ...);
+
+int x = 1;
+int main ()
+{
+ asm goto ("decl %0; jnz %l[a]" :: "m"(x) : "memory" : a);
+ printf ("Hello world\n");
+a:
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100603-1_0.c b/gcc/testsuite/gcc.dg/lto/20100603-1_0.c
new file mode 100644
index 000000000..cc35c78cf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100603-1_0.c
@@ -0,0 +1,4 @@
+/* { dg-lto-do link } */
+/* { dg-extra-ld-options {-r -nostdlib} } */
+
+/* This file intentionally left empty. */
diff --git a/gcc/testsuite/gcc.dg/lto/20100603-2_0.c b/gcc/testsuite/gcc.dg/lto/20100603-2_0.c
new file mode 100644
index 000000000..11bee496d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100603-2_0.c
@@ -0,0 +1,5 @@
+/* { dg-lto-do link } */
+/* { dg-extra-ld-options {-r -nostdlib} } */
+
+int foo;
+int *i = &foo;
diff --git a/gcc/testsuite/gcc.dg/lto/20100603-3_0.c b/gcc/testsuite/gcc.dg/lto/20100603-3_0.c
new file mode 100644
index 000000000..3fc08fdbf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100603-3_0.c
@@ -0,0 +1,4 @@
+/* { dg-lto-do link } */
+/* { dg-extra-ld-options {-r -nostdlib} } */
+
+int i = 42;
diff --git a/gcc/testsuite/gcc.dg/lto/20100709-1_0.c b/gcc/testsuite/gcc.dg/lto/20100709-1_0.c
new file mode 100644
index 000000000..33f38f6c2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100709-1_0.c
@@ -0,0 +1,7 @@
+/* { dg-lto-do link } */
+
+struct X;
+struct Y {
+ struct X (*fnptr)(struct X);
+};
+struct Y foo;
diff --git a/gcc/testsuite/gcc.dg/lto/20100709-1_1.c b/gcc/testsuite/gcc.dg/lto/20100709-1_1.c
new file mode 100644
index 000000000..b970795c6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100709-1_1.c
@@ -0,0 +1,11 @@
+struct X { int i; };
+struct Y {
+ struct X (*fnptr)(struct X);
+};
+extern struct Y foo;
+int main()
+{
+ struct X x;
+ foo.fnptr(x);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100720-1_0.c b/gcc/testsuite/gcc.dg/lto/20100720-1_0.c
new file mode 100644
index 000000000..ca9366f62
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100720-1_0.c
@@ -0,0 +1,22 @@
+/* { dg-lto-do run } */
+
+struct X {
+ int a;
+};
+
+typedef struct list_node *list;
+
+struct list_node {
+ list next;
+ struct X *value;
+};
+
+list f(void)
+{
+ return 0;
+}
+
+int main(void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100720-1_1.c b/gcc/testsuite/gcc.dg/lto/20100720-1_1.c
new file mode 100644
index 000000000..789e88e7d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100720-1_1.c
@@ -0,0 +1,15 @@
+struct X {
+ int b;
+};
+
+typedef struct list_node *list;
+
+struct list_node {
+ list next;
+ struct X *value;
+};
+
+list g(void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100720-2_0.c b/gcc/testsuite/gcc.dg/lto/20100720-2_0.c
new file mode 100644
index 000000000..87b13b0de
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100720-2_0.c
@@ -0,0 +1,23 @@
+/* { dg-lto-do run } */
+
+struct X {
+ int a;
+};
+
+typedef struct list_node *list;
+
+struct list_node {
+ list next;
+ list *ptr;
+ struct X *value;
+};
+
+list f(list lst)
+{
+ return lst->next;
+}
+
+int main(void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100720-2_1.c b/gcc/testsuite/gcc.dg/lto/20100720-2_1.c
new file mode 100644
index 000000000..b3a2cd06e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100720-2_1.c
@@ -0,0 +1,16 @@
+struct X {
+ int b;
+};
+
+typedef struct list_node *list;
+
+struct list_node {
+ list next;
+ list *ptr;
+ struct X *value;
+};
+
+list *g(list *ptr)
+{
+ return ptr;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100720-3_0.c b/gcc/testsuite/gcc.dg/lto/20100720-3_0.c
new file mode 100644
index 000000000..99c89ebd7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100720-3_0.c
@@ -0,0 +1,24 @@
+/* { dg-lto-do run } */
+
+struct X {
+ int a;
+};
+
+struct link {
+ struct list_node *next;
+};
+
+struct list_node {
+ struct link lnk;
+ struct X *value;
+};
+
+void f(struct list_node *lst)
+{
+ lst->lnk.next = 0;
+}
+
+int main(void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100720-3_1.c b/gcc/testsuite/gcc.dg/lto/20100720-3_1.c
new file mode 100644
index 000000000..3d323813e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100720-3_1.c
@@ -0,0 +1,17 @@
+struct X {
+ int b;
+};
+
+struct link {
+ struct list_node *next;
+};
+
+struct list_node {
+ struct link lnk;
+ struct X *value;
+};
+
+void g(struct list_node *lst)
+{
+ lst->lnk.next = 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100720-4_0.c b/gcc/testsuite/gcc.dg/lto/20100720-4_0.c
new file mode 100644
index 000000000..e7669552f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100720-4_0.c
@@ -0,0 +1,15 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-flto -fsigned-char} {-flto -funsigned-char}} } */
+
+char *a;
+int f;
+
+void
+foo (void)
+{
+ f = (*a != '-');
+}
+int main()
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100722-1_0.c b/gcc/testsuite/gcc.dg/lto/20100722-1_0.c
new file mode 100644
index 000000000..275a03c25
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100722-1_0.c
@@ -0,0 +1,6 @@
+/* { dg-lto-do run } */
+/* { dg-require-linker-plugin "" } */
+/* { dg-extra-ld-options "-fuse-linker-plugin" } */
+
+int main() { return 0; }
+
diff --git a/gcc/testsuite/gcc.dg/lto/20100724-1_0.c b/gcc/testsuite/gcc.dg/lto/20100724-1_0.c
new file mode 100644
index 000000000..9651242ed
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100724-1_0.c
@@ -0,0 +1,11 @@
+/* { dg-lto-do link } */
+
+void baz(void)
+{
+ __builtin_abort ();
+}
+void foo(void)
+{
+ baz();
+}
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/20100724-1_1.c b/gcc/testsuite/gcc.dg/lto/20100724-1_1.c
new file mode 100644
index 000000000..dc101e60c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100724-1_1.c
@@ -0,0 +1,5 @@
+extern __attribute__((__noreturn__)) void baz(void);
+void bar(void)
+{
+ baz();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20100825-1_0.c b/gcc/testsuite/gcc.dg/lto/20100825-1_0.c
new file mode 100644
index 000000000..67b5ce035
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100825-1_0.c
@@ -0,0 +1,57 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options { { -O3 -flto } } } */
+
+typedef unsigned int UINT32;
+typedef unsigned long long UINT64;
+typedef struct { UINT64 w[2]; } UINT128;
+void _bid_to_dpd128 (UINT128 *, UINT128 *);
+static const int short_recip_scale[] = {
+ 1,
+ 65 - 64,
+ 69 - 64,
+ 71 - 64,
+ 75 - 64,
+ 78 - 64,
+ 81 - 64,
+ 85 - 64,
+ 88 - 64,
+ 91 - 64,
+ 95 - 64,
+ 98 - 64,
+ 101 - 64,
+ 105 - 64,
+ 108 - 64,
+ 111 - 64,
+ 115 - 64,
+ 118 - 64
+};
+
+void _bid_to_dpd128 (UINT128 *, UINT128 *);
+
+void
+_bid_to_dpd128 (UINT128 *pres, UINT128 *px) {
+ UINT128 res;
+ unsigned int comb;
+ UINT128 bcoeff;
+ UINT128 BH;
+ UINT64 BL, d109;
+ unsigned int amount;
+ UINT128 x = *px;
+
+ comb = (x.w[1] ) >> 46;
+ if ((comb & 0x1e000) == 0x1e000) {
+ res = x;
+ } else {
+ bcoeff.w[1] = (x.w[1] & 0x0001ffffffffffffull);
+ bcoeff.w[0] = x.w[0];
+ amount = 9;
+ BH.w[0] = (BH.w[0] >> amount) | (BH.w[1] << (64 - amount));
+ BL = bcoeff.w[0] - BH.w[0] * 1000000000000000000ull;
+ d109 = 0x3333333333333334ull;
+ { UINT64 CXH, CXL, CYH,CYL,PL,PH,PM,PM2; CXH = (BH.w[0]) >> 32; CXL = (UINT32)(BH.w[0]); CYH = (d109) >> 32; CYL = (UINT32)(d109); PM = CXH*CYL; PH = CXH*CYH; PL = CXL*CYL; PM2 = CXL*CYH; PH += (PM>>32); PM = (UINT64)((UINT32)PM)+PM2+(PL>>32); };
+ { UINT64 CXH, CXL, CYH,CYL,PL,PH,PM,PM2; CXH = (BL) >> 32; CXL = (UINT32)(BL); CYH = (d109) >> 32; CYL = (UINT32)(d109); PM = CXH*CYL; PH = CXH*CYH; PL = CXL*CYL; PM2 = CXL*CYH; PH += (PM>>32); PM = (UINT64)((UINT32)PM)+PM2+(PL>>32); };
+ }
+ *pres = res;
+}
+
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/20101009-1_0.c b/gcc/testsuite/gcc.dg/lto/20101009-1_0.c
new file mode 100644
index 000000000..bad180b0b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20101009-1_0.c
@@ -0,0 +1,16 @@
+/* { dg-lto-do link } */
+
+static inline void
+bar (unsigned *u)
+{
+ __asm__ ("":"=r" (*u));
+}
+
+void
+foo (void)
+{
+ int i;
+ bar (&i);
+}
+
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/20101009-2_0.c b/gcc/testsuite/gcc.dg/lto/20101009-2_0.c
new file mode 100644
index 000000000..249d0e079
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20101009-2_0.c
@@ -0,0 +1,3 @@
+/* { dg-lto-do link } */
+
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/20101009-2_1.c b/gcc/testsuite/gcc.dg/lto/20101009-2_1.c
new file mode 100644
index 000000000..887057db7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20101009-2_1.c
@@ -0,0 +1,5 @@
+int foo (void)
+{
+ static int i;
+ return ++i;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20101009-2_2.c b/gcc/testsuite/gcc.dg/lto/20101009-2_2.c
new file mode 100644
index 000000000..4a97fe806
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20101009-2_2.c
@@ -0,0 +1,5 @@
+int bar (void)
+{
+ static int i;
+ return ++i;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20101125-1_0.c b/gcc/testsuite/gcc.dg/lto/20101125-1_0.c
new file mode 100644
index 000000000..662dd243d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20101125-1_0.c
@@ -0,0 +1,24 @@
+/* { dg-lto-do link } */
+
+struct X {
+ int i;
+};
+
+struct W {
+ struct U *p;
+ struct X *q;
+};
+
+struct U {
+ struct W a[1];
+};
+
+void foo(struct U *ptr)
+{
+ ptr->a[0].p = 0;
+}
+
+int main(void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20101125-1_1.c b/gcc/testsuite/gcc.dg/lto/20101125-1_1.c
new file mode 100644
index 000000000..2924e3f26
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20101125-1_1.c
@@ -0,0 +1,17 @@
+struct X {
+ char i;
+};
+
+struct W {
+ struct U *p;
+ struct X *q;
+};
+
+struct U {
+ struct W a[1];
+};
+
+void bar(struct U *ptr)
+{
+ ptr->a[0].p = 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/20110201-1_0.c b/gcc/testsuite/gcc.dg/lto/20110201-1_0.c
new file mode 100644
index 000000000..f5d335572
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20110201-1_0.c
@@ -0,0 +1,19 @@
+/* { dg-lto-do run } */
+/* { dg-lto-options { { -O0 -flto } } } */
+/* { dg-extra-ld-options "-O2 -ffast-math -fuse-linker-plugin" } */
+/* { dg-require-linker-plugin "" } */
+
+/* We require a linker plugin because otherwise we'd need to link
+ against libm which we are not sure here has cabs on all targets.
+ This is because collect2 invokes ld on the -O0 object code
+ which does not have folded cabs. */
+
+double cabs(_Complex double);
+double __attribute__((used))
+foo (_Complex double x, int b)
+{
+ if (b)
+ x = 0;
+ return cabs(x);
+}
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/README b/gcc/testsuite/gcc.dg/lto/README
new file mode 100644
index 000000000..1a13dd92c
--- /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/const-uniq_0.c b/gcc/testsuite/gcc.dg/lto/const-uniq_0.c
new file mode 100644
index 000000000..1bbc7f45f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/const-uniq_0.c
@@ -0,0 +1,16 @@
+/* The 3 constant initializers should be uniquized. */
+
+/* { dg-lto-do run } */
+/* { dg-lto-options {{-Os -flto -flto-partition=none} {-Os -flto -flto-partition=1to1} } } */
+
+int lookup1 (int i)
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+ return a[i];
+}
+
+int lookup2 (int i)
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+ return a[i+1];
+}
diff --git a/gcc/testsuite/gcc.dg/lto/const-uniq_1.c b/gcc/testsuite/gcc.dg/lto/const-uniq_1.c
new file mode 100644
index 000000000..ee1505cc9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/const-uniq_1.c
@@ -0,0 +1,23 @@
+extern int lookup1 (int i);
+extern int lookup2 (int i);
+extern void abort (void);
+
+int lookup3 (int i)
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+ return a[i+2];
+}
+
+int main (void)
+{
+ if (lookup1(2) != 2)
+ abort ();
+
+ if (lookup2(2) != 3)
+ abort ();
+
+ if (lookup3(2) != 4)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/ipacp_0.c b/gcc/testsuite/gcc.dg/lto/ipacp_0.c
new file mode 100644
index 000000000..097c1c253
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/ipacp_0.c
@@ -0,0 +1,15 @@
+/* { dg-lto-options {{ -O1 -flto -flto-partition=1to1 -fipa-cp -fipa-cp-clone}} } */
+/* { dg-lto-do run } */
+
+/* Test that clonning happens and we unify declarations of a from both units. */
+const int a = 5;
+extern void clone_me (int *);
+
+int
+main(void)
+{
+ int i;
+ for (i=0;i<100;i++)
+ clone_me ((int *)&a);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/ipacp_1.c b/gcc/testsuite/gcc.dg/lto/ipacp_1.c
new file mode 100644
index 000000000..69c1ec6e9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/ipacp_1.c
@@ -0,0 +1,12 @@
+void abort (void);
+extern int a;
+
+__attribute__ ((noinline))
+void
+clone_me (int *ptr)
+{
+ if (ptr != &a)
+ abort ();
+ if (!__builtin_constant_p (ptr != &a))
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/ipareference2_0.c b/gcc/testsuite/gcc.dg/lto/ipareference2_0.c
new file mode 100644
index 000000000..f7ae0b4e3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/ipareference2_0.c
@@ -0,0 +1,16 @@
+/* { dg-lto-options {{ -O1 -flto -flto-partition=1to1 -fwhole-program}} } */
+/* { dg-lto-do run } */
+
+/* Verify that ipa-reference marks A as constant and we fold references
+ to a[1] and a[2] to &c and that we promote C to hidden vars shared across ltrans units. */
+void abort (void);
+int b,c,d,e,f;
+int *a[5]={&b,&c,&c,&e};
+void other_ltrans (void);
+main()
+{
+ other_ltrans ();
+ if (*(a[1])!=11)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/ipareference2_1.c b/gcc/testsuite/gcc.dg/lto/ipareference2_1.c
new file mode 100644
index 000000000..c7653b080
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/ipareference2_1.c
@@ -0,0 +1,13 @@
+void abort (void);
+extern int *a[5];
+extern int b,c,d,e,f;
+__attribute__ ((noinline, noclone))
+void
+other_ltrans (void)
+{
+ if (!__builtin_constant_p (a[1]==a[2]))
+ abort ();
+ if (a[1]!=a[2])
+ abort ();
+ *(a[1])=11;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/ipareference_0.c b/gcc/testsuite/gcc.dg/lto/ipareference_0.c
new file mode 100644
index 000000000..f8970f0e9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/ipareference_0.c
@@ -0,0 +1,26 @@
+/* { dg-lto-options {{ -O1 -flto -flto-partition=1to1 }} } */
+/* { dg-lto-do run } */
+
+/* Test that ipa-reference notice that get_val will not change since do_nothing does not
+ modify anything. This needs streaming cross file boundary summaries. */
+extern int get_val (void);
+extern int set_val (void);
+extern do_nothing (void);
+void abort (void);
+main()
+{
+ int a;
+ int b;
+ set_val ();
+ a = get_val ();
+ do_nothing();
+ b = get_val ();
+ if (a==b)
+ {
+ if (!__builtin_constant_p (a==b))
+ abort ();
+ return 0;
+ }
+ else
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/ipareference_1.c b/gcc/testsuite/gcc.dg/lto/ipareference_1.c
new file mode 100644
index 000000000..c5d72faaf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/ipareference_1.c
@@ -0,0 +1,14 @@
+static int val;
+int set_val (void)
+{
+ val = 5;
+}
+int get_val (void)
+{
+ return val;
+}
+__attribute__ ((__noinline__))
+do_nothing ()
+{
+ asm volatile ("":::"memory");
+}
diff --git a/gcc/testsuite/gcc.dg/lto/lto.exp b/gcc/testsuite/gcc.dg/lto/lto.exp
new file mode 100644
index 000000000..48b597c70
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/lto.exp
@@ -0,0 +1,59 @@
+# 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
+
+# If LTO has not been enabled, bail.
+if { ![check_effective_target_lto] } {
+ return
+}
+
+gcc_init
+lto_init no-mathlib
+
+# 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"
+
+# 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
+}
+
+lto_finish
diff --git a/gcc/testsuite/gcc.dg/lto/materialize-1_0.c b/gcc/testsuite/gcc.dg/lto/materialize-1_0.c
new file mode 100644
index 000000000..1751d65d2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/materialize-1_0.c
@@ -0,0 +1,8 @@
+/* { dg-lto-options {{ -O3 -flto -flto-partition=1to1}} } */
+/* { dg-lto-do run } */
+extern void clone_me (int, int);
+int a=15;
+inline int inline_me ()
+{
+ clone_me (0,a);
+}
diff --git a/gcc/testsuite/gcc.dg/lto/materialize-1_1.c b/gcc/testsuite/gcc.dg/lto/materialize-1_1.c
new file mode 100644
index 000000000..ca080579f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/materialize-1_1.c
@@ -0,0 +1,22 @@
+int inline_me (void);
+extern int a;
+void abort (void);
+
+__attribute__ ((noinline))
+void
+clone_me (int c, int d)
+{
+ if (!c)
+ {
+ if (d!=a)
+ abort ();
+ }
+}
+int
+main(void)
+{
+ int i;
+ for (i=0;i<a;i++)
+ inline_me ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/noreturn-1_0.c b/gcc/testsuite/gcc.dg/lto/noreturn-1_0.c
new file mode 100644
index 000000000..7f493cd9f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/noreturn-1_0.c
@@ -0,0 +1,10 @@
+/* { dg-lto-do run } */
+/* { dg-lto-options {{-O2 -flto -flto-partition=1to1} } } */
+
+void exit (int);
+__attribute__ ((noreturn))
+int
+call_me (void)
+{
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/lto/noreturn-1_1.c b/gcc/testsuite/gcc.dg/lto/noreturn-1_1.c
new file mode 100644
index 000000000..cc2bcf8dc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/noreturn-1_1.c
@@ -0,0 +1,6 @@
+int call_me (void);
+int
+main(void)
+{
+ return call_me ();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr27898_0.c b/gcc/testsuite/gcc.dg/lto/pr27898_0.c
new file mode 100644
index 000000000..c7e23f35e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr27898_0.c
@@ -0,0 +1,8 @@
+/* PR c/27898 */
+/* { dg-lto-do link } */
+
+union u { struct { int i; }; };
+
+extern int foo (union u *);
+
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/pr27898_1.c b/gcc/testsuite/gcc.dg/lto/pr27898_1.c
new file mode 100644
index 000000000..110e0d9df
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr27898_1.c
@@ -0,0 +1,3 @@
+union u { struct { int i; }; };
+
+extern int foo (union u *);
diff --git a/gcc/testsuite/gcc.dg/lto/pr28706_0.c b/gcc/testsuite/gcc.dg/lto/pr28706_0.c
new file mode 100644
index 000000000..aaa8940eb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr28706_0.c
@@ -0,0 +1,12 @@
+/* PR c/28706 */
+/* { dg-lto-do link } */
+
+struct A
+{
+ int i;
+} __attribute__((aligned (sizeof (long int))));
+
+extern void foo (struct A *);
+extern void foo (struct A *);
+
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/pr28706_1.c b/gcc/testsuite/gcc.dg/lto/pr28706_1.c
new file mode 100644
index 000000000..4550b6374
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr28706_1.c
@@ -0,0 +1,9 @@
+/* PR c/28706 */
+
+struct A
+{
+ int i;
+} __attribute__((aligned (sizeof (long int))));
+
+extern void foo (struct A *);
+extern void foo (struct A *);
diff --git a/gcc/testsuite/gcc.dg/lto/pr28712_0.c b/gcc/testsuite/gcc.dg/lto/pr28712_0.c
new file mode 100644
index 000000000..dff029cad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr28712_0.c
@@ -0,0 +1,16 @@
+/* PR c/28712 */
+/* { dg-lto-do link } */
+
+struct A;
+
+extern struct A *a;
+
+struct A { } __attribute__((packed));
+
+struct B __attribute__((aligned (sizeof (int))));
+
+extern struct B *b;
+
+struct B { int i; } __attribute__((packed));
+
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/pr28712_1.c b/gcc/testsuite/gcc.dg/lto/pr28712_1.c
new file mode 100644
index 000000000..8a322457f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr28712_1.c
@@ -0,0 +1,12 @@
+/* PR c/28712 */
+struct A;
+
+extern struct A *a;
+
+struct A { } __attribute__((packed));
+
+struct B __attribute__((aligned (sizeof (int))));
+
+extern struct B *b;
+
+struct B { int i; } __attribute__((packed));
diff --git a/gcc/testsuite/gcc.dg/lto/pr28712_2.c b/gcc/testsuite/gcc.dg/lto/pr28712_2.c
new file mode 100644
index 000000000..1937e88b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr28712_2.c
@@ -0,0 +1,13 @@
+/* PR c/28712 */
+
+struct A;
+
+extern struct A *a;
+
+struct A { } __attribute__((packed));
+
+struct B __attribute__((aligned (sizeof (int))));
+
+extern struct B *b;
+
+struct B { int i; } __attribute__((packed));
diff --git a/gcc/testsuite/gcc.dg/lto/pr34989-1_0.c b/gcc/testsuite/gcc.dg/lto/pr34989-1_0.c
new file mode 100644
index 000000000..245486b6e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr34989-1_0.c
@@ -0,0 +1,10 @@
+/* { dg-lto-do link } */
+
+extern struct globals *const ptr_to_globals;
+struct globals { };
+int syslogd_main(int argc, char **argv)
+{
+ (*(struct globals**)&ptr_to_globals) = 0;
+}
+
+int main() { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/pr34989-1_1.c b/gcc/testsuite/gcc.dg/lto/pr34989-1_1.c
new file mode 100644
index 000000000..59604b6e4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr34989-1_1.c
@@ -0,0 +1 @@
+struct globals *const ptr_to_globals;
diff --git a/gcc/testsuite/gcc.dg/lto/pr45721_0.c b/gcc/testsuite/gcc.dg/lto/pr45721_0.c
new file mode 100644
index 000000000..8c5c05204
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr45721_0.c
@@ -0,0 +1,4 @@
+/* { dg-lto-do assemble } */
+void baz(void) {}
+void *y = (void *)baz;
+int main () { return 0; }
diff --git a/gcc/testsuite/gcc.dg/lto/pr45721_1.c b/gcc/testsuite/gcc.dg/lto/pr45721_1.c
new file mode 100644
index 000000000..05d854f9f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr45721_1.c
@@ -0,0 +1,2 @@
+static void bar(void) __attribute__ ((weakref("baz")));
+void *x = (void *)bar;
diff --git a/gcc/testsuite/gcc.dg/lto/pr45736_0.c b/gcc/testsuite/gcc.dg/lto/pr45736_0.c
new file mode 100644
index 000000000..860e239b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr45736_0.c
@@ -0,0 +1,16 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-flto -r -nostdlib -O}} } */
+
+extern void baz (void);
+
+static void __attribute__ ((constructor))
+bar (void)
+{
+ baz ();
+}
+
+void
+foo (void)
+{
+ bar ();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr46940_0.c b/gcc/testsuite/gcc.dg/lto/pr46940_0.c
new file mode 100644
index 000000000..5283495e8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr46940_0.c
@@ -0,0 +1,11 @@
+/* { dg-require-linker-plugin "" } */
+/* { dg-extra-ld-options "-fuse-linker-plugin" } */
+#include <stdio.h>
+
+extern __attribute__((visibility("hidden"))) void _moz_foo (void);
+extern __typeof (_moz_foo) _moz_foo __asm__ ("" "INT__foo") __attribute__((__visibility__("hidden"))) ;
+void _moz_foo(void)
+{
+ printf ("blah\n");
+}
+extern __typeof (_moz_foo) EXT__foo __asm__("" "_moz_foo") __attribute__((__alias__("" "INT__foo")));
diff --git a/gcc/testsuite/gcc.dg/lto/pr46940_1.c b/gcc/testsuite/gcc.dg/lto/pr46940_1.c
new file mode 100644
index 000000000..924a09b7c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr46940_1.c
@@ -0,0 +1,7 @@
+extern void _moz_foo (void);
+int
+main()
+{
+ _moz_foo ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr47188_0.c b/gcc/testsuite/gcc.dg/lto/pr47188_0.c
new file mode 100644
index 000000000..ac9e03167
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr47188_0.c
@@ -0,0 +1,7 @@
+/* { dg-lto-do assemble } */
+/* { dg-require-linker-plugin "" } */
+/* { dg-extra-ld-options "-fuse-linker-plugin -fwhole-program" } */
+int foo(void)
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr47188_1.c b/gcc/testsuite/gcc.dg/lto/pr47188_1.c
new file mode 100644
index 000000000..f18f4db38
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr47188_1.c
@@ -0,0 +1,8 @@
+/* { dg-options "-fno-lto" } */
+
+extern int foo(void);
+
+int main(void)
+{
+ return foo();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr47259_0.c b/gcc/testsuite/gcc.dg/lto/pr47259_0.c
new file mode 100644
index 000000000..b95947887
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr47259_0.c
@@ -0,0 +1,13 @@
+/* { dg-lto-do link } */
+/* { dg-skip-if "" { ! { x86_64-*-* } } { "*" } { "" } } */
+/* { dg-lto-options { { -O2 -flto -w } } } */
+/* { dg-require-effective-target lp64 } */
+
+register int r asm("esi");
+
+void foo(void)
+{
+ if (r)
+ __asm__("sar\t%0" : "+r" (r));
+ __asm__("sar\t%0" : "+r" (r));
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr47259_1.c b/gcc/testsuite/gcc.dg/lto/pr47259_1.c
new file mode 100644
index 000000000..03bf89475
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr47259_1.c
@@ -0,0 +1,9 @@
+/* { dg-options "-fno-lto" } */
+
+extern void foo(void);
+
+int main(void)
+{
+ foo();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr47924_0.c b/gcc/testsuite/gcc.dg/lto/pr47924_0.c
new file mode 100644
index 000000000..f7fdb44b0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr47924_0.c
@@ -0,0 +1,19 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options {{-O2 -flto}} } */
+
+extern void link_error (void);
+short *p __attribute__((used));
+int i __attribute__((used));
+
+int main()
+{
+ if (i == 0)
+ return;
+
+ *p = 0;
+
+ if (i == 0)
+ link_error ();
+
+ return 0;
+}