public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mikpe at it dot uu.se" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/49243] attribute((returns_twice)) doesn't work
Date: Tue, 31 May 2011 22:58:00 -0000	[thread overview]
Message-ID: <bug-49243-4-R0nq2K5gHB@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-49243-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Mikael Pettersson <mikpe at it dot uu.se> 2011-05-31 22:49:36 UTC ---
Comparing tree dumps from gcc-4.7 on a reduced compile-only test case shows
that the code that calls _setjmp (a) and the code that calls my_setjmp (b)
start to differ after 019t.inline_param1:

--- a/pr49243.c.019t.inline_param1      2011-05-31 23:29:47.000000000 +0200
+++ b/pr49243.c.019t.inline_param1      2011-05-31 23:30:10.000000000 +0200
@@ -4,7 +4,7 @@

 Analyzing function body size: wrapper

-Inline summary for wrapper/0
+Inline summary for wrapper/0 inlinable
   self time:       33
   global time:     0
   self size:       16

Adding -Winline one finds that the code that calls _setjmp is marked
non-inlinable because setjmp_call_p says so in inline_forbidden_p_stmt,
however it doesn't say so for the code that calls my_setjmp.  setjmp_call_p
calls special_function_p, which only looks at the spelling of the function. 
The closely related flags_from_decl_or_type does look at both attributes and
spelling; the following crude patch to make setjmp_call_p call the latter
instead fixes the reduced test case for me:

--- gcc-4.7-20110528/gcc/calls.c.~1~    2011-05-25 13:00:14.000000000 +0200
+++ gcc-4.7-20110528/gcc/calls.c        2011-06-01 00:02:13.000000000 +0200
@@ -554,7 +554,7 @@ special_function_p (const_tree fndecl, i
 int
 setjmp_call_p (const_tree fndecl)
 {
-  return special_function_p (fndecl, 0) & ECF_RETURNS_TWICE;
+  return flags_from_decl_or_type (fndecl) & ECF_RETURNS_TWICE;
 }


(This is a tad expensive and can be optimized.)

The other calls to special_function_p () look safe though.


  parent reply	other threads:[~2011-05-31 22:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-31 16:28 [Bug c/49243] New: " mikpe at it dot uu.se
2011-05-31 18:07 ` [Bug c/49243] " mikpe at it dot uu.se
2011-05-31 22:58 ` mikpe at it dot uu.se [this message]
2011-06-01 10:31 ` [Bug tree-optimization/49243] " rguenth at gcc dot gnu.org
2011-06-02 15:35 ` mikpe at it dot uu.se
2011-06-06 11:44 ` rguenth at gcc dot gnu.org
2011-06-06 11:46 ` rguenth at gcc dot gnu.org
2011-06-06 13:34 ` mikpe at it dot uu.se
2011-06-06 15:04 ` rguenth at gcc dot gnu.org

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-49243-4-R0nq2K5gHB@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).