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