]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/33763 (Bogus inlining failed in call to `xxx': redefined extern inline functi...
authorJakub Jelinek <jakub@gcc.gnu.org>
Fri, 5 Oct 2012 12:01:59 +0000 (14:01 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 5 Oct 2012 12:01:59 +0000 (14:01 +0200)
PR tree-optimization/33763
* tree-inline.c (expand_call_inline): Silently ignore always_inline
attribute for redefined extern inline functions.

* c-c++-common/pr33763.c: New test.

From-SVN: r192122

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr33763.c [new file with mode: 0644]
gcc/tree-inline.c

index 4c225797a598581f3774ef53f8f73e3610f6bef4..48d5aa6e04dca5ae8e4c535e092779bae8b94154 100644 (file)
@@ -1,3 +1,10 @@
+2012-10-05  Jan Hubicka  <jh@suse.cz>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/33763
+       * tree-inline.c (expand_call_inline): Silently ignore always_inline
+       attribute for redefined extern inline functions.
+
 2012-10-03  H.J. Lu  <hongjiu.lu@intel.com>
 
        Backported from mainline
index 4f237e237e50abdf3974d78404a72b30715eb758..5a725c9b67128b7e2931a4fe804990507e8cb029 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/33763
+       * c-c++-common/pr33763.c: New test.
+
 2012-09-20  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/addr1.ads: Move dg directive to...
diff --git a/gcc/testsuite/c-c++-common/pr33763.c b/gcc/testsuite/c-c++-common/pr33763.c
new file mode 100644 (file)
index 0000000..dbdfa77
--- /dev/null
@@ -0,0 +1,60 @@
+/* PR tree-optimization/33763 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef struct
+{
+  void *a;
+  void *b;
+} T;
+extern void *foo (const char *, const char *);
+extern void *bar (void *, const char *, T);
+extern int baz (const char *, int);
+
+extern inline __attribute__ ((always_inline, gnu_inline)) int
+baz (const char *x, int y)
+{
+  return 2;
+}
+
+int
+baz (const char *x, int y)
+{
+  return 1;
+}
+
+int xa, xb;
+
+static void *
+inl (const char *x, const char *y)
+{
+  T t = { &xa, &xb };
+  int *f = (int *) __builtin_malloc (sizeof (int));
+  const char *z;
+  int o = 0;
+  void *r = 0;
+
+  for (z = y; *z; z++)
+    {
+      if (*z == 'r')
+       o |= 1;
+      if (*z == 'w')
+       o |= 2;
+    }
+  if (o == 1)
+    *f = baz (x, 0);
+  if (o == 2)
+    *f = baz (x, 1);
+  if (o == 3)
+    *f = baz (x, 2);
+
+  if (o && *f > 0)
+    r = bar (f, "w", t);
+  return r;
+}
+
+void *
+foo (const char *x, const char *y)
+{
+  return inl (x, y);
+}
index 5933c32f032adda474cbef4dc6f8479b9346c408..ab9195b958e25bc0632ffb1ea974b0af44952060 100644 (file)
@@ -3809,6 +3809,12 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
        goto egress;
 
       if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn))
+          /* For extern inline functions that get redefined we always
+            silently ignored always_inline flag. Better behaviour would
+            be to be able to keep both bodies and use extern inline body
+            for inlining, but we can't do that because frontends overwrite
+            the body.  */
+         && !cg_edge->callee->local.redefined_extern_inline
          /* Avoid warnings during early inline pass. */
          && cgraph_global_info_ready)
        {