public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/33763] [4.4/4.5/4.6/4.7 Regression] Bogus inlining failed in call to `xxx': redefined extern inline functions are not considered for inlining
Date: Fri, 13 Jan 2012 09:31:00 -0000	[thread overview]
Message-ID: <bug-33763-4-PspeoHEXUa@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-33763-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33763

--- Comment #31 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-13 09:26:45 UTC ---
Ok, so the following patch makes

extern __inline __attribute__ ((__always_inline__))
void open ()
{
}
void bar ()
{
  open ();
}
void open ()
{
  open ();
}

"work" as in the extern inline variant is used for the callin bar()
and the call in open () is recursive and all following calls would
refer to it.  That means, we end up with two cgraph nodes (but do
not magically use one for inlining and one for the offline copy - that
would need to be fixed in the C frontend by _not_ changing name-lookup
to lookup the 2nd version, but I'm not sure that is desired).

At least you can say the behavior makes sense and it avoids the ICEs, too.

I'm going to test this.

Index: gcc/c-decl.c
===================================================================
--- gcc/c-decl.c        (revision 183121)
+++ gcc/c-decl.c        (working copy)
@@ -2513,6 +2513,24 @@ duplicate_decls (tree newdecl, tree oldd
       return false;
     }

+  /* If we have a redeclared extern inline function simply drop olddecl
+     on the floor instead of merging it with newdecl.  */
+  if (TREE_CODE (newdecl) == FUNCTION_DECL
+      && DECL_INITIAL (newdecl)
+      && DECL_INITIAL (olddecl)
+      && !(!(DECL_DECLARED_INLINE_P (olddecl)
+            && DECL_EXTERNAL (olddecl))
+          || (DECL_DECLARED_INLINE_P (newdecl)
+              && DECL_EXTERNAL (newdecl))
+          || (!flag_gnu89_inline
+              && (!DECL_DECLARED_INLINE_P (olddecl)
+                  || !lookup_attribute ("gnu_inline",
+                                        DECL_ATTRIBUTES (olddecl)))
+              && (!DECL_DECLARED_INLINE_P (newdecl)
+                  || !lookup_attribute ("gnu_inline",
+                                        DECL_ATTRIBUTES (newdecl))))))
+    return false;
+
   merge_decls (newdecl, olddecl, newtype, oldtype);
   return true;
 }


  parent reply	other threads:[~2012-01-13  9:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-33763-4@http.gcc.gnu.org/bugzilla/>
2011-03-04 12:37 ` [Bug tree-optimization/33763] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu.org
2011-03-05 12:45 ` hubicka at ucw dot cz
2011-03-11 22:16 ` pthaugen at gcc dot gnu.org
2011-06-27 14:51 ` [Bug tree-optimization/33763] [4.3/4.4/4.5/4.6/4.7 " rguenth at gcc dot gnu.org
2012-01-12 13:44 ` [Bug c/33763] [4.4/4.5/4.6/4.7 " rguenth at gcc dot gnu.org
2012-01-12 14:24 ` hubicka at ucw dot cz
2012-01-12 14:28 ` rguenther at suse dot de
2012-01-12 14:33 ` rguenth at gcc dot gnu.org
2012-01-12 14:33 ` rguenth at gcc dot gnu.org
2012-01-12 14:38 ` joseph at codesourcery dot com
2012-01-12 14:51 ` rguenth at gcc dot gnu.org
2012-01-12 14:54 ` rguenth at gcc dot gnu.org
2012-01-13  9:31 ` rguenth at gcc dot gnu.org [this message]
2012-03-13 15:27 ` [Bug c/33763] [4.5/4.6/4.7/4.8 " jakub at gcc dot gnu.org
2012-07-02 11:52 ` rguenth at gcc dot gnu.org
2012-07-09 15:04 ` [Bug c/33763] [4.6/4.7/4.8 " dschepler at gmail dot com
2012-07-09 15:41 ` rguenth at gcc dot gnu.org
2012-10-05 11:44 ` jakub at gcc dot gnu.org
2012-10-05 11:59 ` jakub at gcc dot gnu.org
2012-10-05 12:02 ` jakub at gcc dot gnu.org
2012-11-11 21:27 ` steven at gcc dot gnu.org
2012-11-11 21:29 ` jakub at gcc dot gnu.org
2013-09-20 22:15 ` kaltsi+gnu at gmail dot com
2013-09-20 22:21 ` jakub at gcc dot gnu.org
2013-09-20 22:25 ` kaltsi+gnu at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-33763-4-PspeoHEXUa@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).