Blame SOURCES/gcc44-pr33763.patch

dc1507
2007-11-06  Jakub Jelinek  <jakub@redhat.com>
dc1507
dc1507
	PR tree-optimization/33763
dc1507
	* gcc.dg/pr33763.c: New test.
dc1507
	* g++.dg/opt/inline13.C: New test.
dc1507
dc1507
2007-11-06  Jan Hubicka  <jh@suse.cz>
dc1507
dc1507
	PR tree-optimization/33763
dc1507
	* tree-inline.c (expand_call_inline): Silently ignore always_inline
dc1507
	attribute for redefined extern inline functions.
dc1507
dc1507
--- gcc/tree-inline.c.jj	2007-11-06 09:29:04.000000000 +0100
dc1507
+++ gcc/tree-inline.c	2007-11-06 16:19:12.000000000 +0100
dc1507
@@ -3157,6 +3157,12 @@ expand_call_inline (basic_block bb, gimp
dc1507
 	goto egress;
dc1507
 
dc1507
       if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn))
dc1507
+	/* For extern inline functions that get redefined we always
dc1507
+	   silently ignored alway_inline flag. Better behaviour would
dc1507
+	   be to be able to keep both bodies and use extern inline body
dc1507
+	   for inlining, but we can't do that because frontends overwrite
dc1507
+	   the body.  */
dc1507
+	  && !cg_edge->callee->local.redefined_extern_inline
dc1507
 	  /* Avoid warnings during early inline pass. */
dc1507
 	  && cgraph_global_info_ready)
dc1507
 	{
dc1507
--- gcc/testsuite/gcc.dg/pr33763.c.jj	2007-11-06 16:19:12.000000000 +0100
dc1507
+++ gcc/testsuite/gcc.dg/pr33763.c	2007-11-06 16:19:12.000000000 +0100
dc1507
@@ -0,0 +1,60 @@
dc1507
+/* PR tree-optimization/33763 */
dc1507
+/* { dg-do compile } */
dc1507
+/* { dg-options "-O2" } */
dc1507
+
dc1507
+typedef struct
dc1507
+{
dc1507
+  void *a;
dc1507
+  void *b;
dc1507
+} T;
dc1507
+extern void *foo (const char *, const char *);
dc1507
+extern void *bar (void *, const char *, T);
dc1507
+extern int baz (const char *, int);
dc1507
+
dc1507
+extern inline __attribute__ ((always_inline, gnu_inline)) int
dc1507
+baz (const char *x, int y)
dc1507
+{
dc1507
+  return 2;
dc1507
+}
dc1507
+
dc1507
+int
dc1507
+baz (const char *x, int y)
dc1507
+{
dc1507
+  return 1;
dc1507
+}
dc1507
+
dc1507
+int xa, xb;
dc1507
+
dc1507
+static void *
dc1507
+inl (const char *x, const char *y)
dc1507
+{
dc1507
+  T t = { &xa, &xb };
dc1507
+  int *f = (int *) __builtin_malloc (sizeof (int));
dc1507
+  const char *z;
dc1507
+  int o = 0;
dc1507
+  void *r = 0;
dc1507
+
dc1507
+  for (z = y; *z; z++)
dc1507
+    {
dc1507
+      if (*z == 'r')
dc1507
+	o |= 1;
dc1507
+      if (*z == 'w')
dc1507
+	o |= 2;
dc1507
+    }
dc1507
+  if (o == 1)
dc1507
+    *f = baz (x, 0);
dc1507
+  if (o == 2)
dc1507
+    *f = baz (x, 1);
dc1507
+  if (o == 3)
dc1507
+    *f = baz (x, 2);
dc1507
+
dc1507
+  if (o && *f > 0)
dc1507
+    r = bar (f, "w", t);
dc1507
+  return r;
dc1507
+}
dc1507
+
dc1507
+void *
dc1507
+foo (const char *x, const char *y)
dc1507
+{
dc1507
+  return inl (x, y);
dc1507
+}
dc1507
--- gcc/testsuite/g++.dg/opt/inline13.C.jj	2007-11-06 16:20:20.000000000 +0100
dc1507
+++ gcc/testsuite/g++.dg/opt/inline13.C	2007-11-06 16:21:30.000000000 +0100
dc1507
@@ -0,0 +1,60 @@
dc1507
+// PR tree-optimization/33763
dc1507
+// { dg-do compile }
dc1507
+// { dg-options "-O2" }
dc1507
+
dc1507
+typedef struct
dc1507
+{
dc1507
+  void *a;
dc1507
+  void *b;
dc1507
+} T;
dc1507
+extern void *foo (const char *, const char *);
dc1507
+extern void *bar (void *, const char *, T);
dc1507
+extern int baz (const char *, int);
dc1507
+
dc1507
+extern inline __attribute__ ((always_inline, gnu_inline)) int
dc1507
+baz (const char *x, int y)
dc1507
+{
dc1507
+  return 2;
dc1507
+}
dc1507
+
dc1507
+int
dc1507
+baz (const char *x, int y)
dc1507
+{
dc1507
+  return 1;
dc1507
+}
dc1507
+
dc1507
+int xa, xb;
dc1507
+
dc1507
+static void *
dc1507
+inl (const char *x, const char *y)
dc1507
+{
dc1507
+  T t = { &xa, &xb };
dc1507
+  int *f = (int *) __builtin_malloc (sizeof (int));
dc1507
+  const char *z;
dc1507
+  int o = 0;
dc1507
+  void *r = 0;
dc1507
+
dc1507
+  for (z = y; *z; z++)
dc1507
+    {
dc1507
+      if (*z == 'r')
dc1507
+	o |= 1;
dc1507
+      if (*z == 'w')
dc1507
+	o |= 2;
dc1507
+    }
dc1507
+  if (o == 1)
dc1507
+    *f = baz (x, 0);
dc1507
+  if (o == 2)
dc1507
+    *f = baz (x, 1);
dc1507
+  if (o == 3)
dc1507
+    *f = baz (x, 2);
dc1507
+
dc1507
+  if (o && *f > 0)
dc1507
+    r = bar (f, "w", t);
dc1507
+  return r;
dc1507
+}
dc1507
+
dc1507
+void *
dc1507
+foo (const char *x, const char *y)
dc1507
+{
dc1507
+  return inl (x, y);
dc1507
+}