public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH C++] Fix c++/41536, always_inline does not work always  	with constructors
Date: Fri, 16 Oct 2009 19:05:00 -0000	[thread overview]
Message-ID: <de8d50360910161148p3dca7687of01d9ecd2de152e9@mail.gmail.com> (raw)
In-Reply-To: <de8d50360910021224s71f45d06v7dcb43923c7b2972@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 898 bytes --]

PING?

On Fri, Oct 2, 2009 at 12:24 PM, Andrew Pinski <pinskia@gmail.com> wrote:
> Hi,
>  The problem here is that for the cloned constructor DECLs, they
> don't have the attribute always_inline on them.  This is because we
> created the cloned decls after the struct was finished and then while
> doing duplicate_decls, the clones are not updated with the new
> attributes.  maybe_clone_body updates some of the cloned decl bits but
> it misses out on DECL_ATTRIBUTES and DECL_DISREGARD_INLINE_LIMITS.
>
> This patch adds the copying of DECL_ATTRIBUTES and
> DECL_DISREGARD_INLINE_LIMITS to maybe_clone_body.
>
> OK? Bootstrapped and tested on i386-darwin8.11 with no regressions.
>
> Thanks,
> Andrew Pinski
>
> ChangeLog:
> * optimize.c (maybe_clone_body): Copy DECL_ATTRIBUTES and
> DECL_DISREGARD_INLINE_LIMITS also.
>
> * g++.dg/ext/always_inline-5.C: New test.
>

[-- Attachment #2: fixpr41536.diff.txt --]
[-- Type: text/plain, Size: 1320 bytes --]

Index: testsuite/g++.dg/ext/always_inline-5.C
===================================================================
--- testsuite/g++.dg/ext/always_inline-5.C	(revision 0)
+++ testsuite/g++.dg/ext/always_inline-5.C	(revision 0)
@@ -0,0 +1,28 @@
+// { dg-do compile }
+struct f
+{
+  inline f(void);
+  inline void f1(void);
+  int a;
+};
+
+inline __attribute__((always_inline))  f::f(void)
+{
+  a++;
+}
+
+inline __attribute__((always_inline)) void  f::f1(void)
+{
+  a++;
+}
+
+void g(void)
+{
+  f a, b, c, d;
+  a.f1();
+}
+
+// f::f() should be inlined even at -O0
+// { dg-final { scan-assembler-not "_ZN1fC1Ev" } }
+// Likewise for f::f1()
+// { dg-final { scan-assembler-not "_ZN1f2f1Ev" } }
Index: cp/optimize.c
===================================================================
--- cp/optimize.c	(revision 152380)
+++ cp/optimize.c	(working copy)
@@ -199,6 +199,8 @@ maybe_clone_body (tree fn)
       DECL_VISIBILITY (clone) = DECL_VISIBILITY (fn);
       DECL_VISIBILITY_SPECIFIED (clone) = DECL_VISIBILITY_SPECIFIED (fn);
       DECL_DLLIMPORT_P (clone) = DECL_DLLIMPORT_P (fn);
+      DECL_ATTRIBUTES (clone) = DECL_ATTRIBUTES (fn);
+      DECL_DISREGARD_INLINE_LIMITS (clone) = DECL_DISREGARD_INLINE_LIMITS (fn);
 
       /* Adjust the parameter names and locations.  */
       parm = DECL_ARGUMENTS (fn);

  reply	other threads:[~2009-10-16 18:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-02 19:24 Andrew Pinski
2009-10-16 19:05 ` Andrew Pinski [this message]
2009-10-16 19:25   ` Jan Hubicka
2009-11-02 13:52     ` Jason Merrill

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=de8d50360910161148p3dca7687of01d9ecd2de152e9@mail.gmail.com \
    --to=pinskia@gmail.com \
    --cc=gcc-patches@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).