From: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
To: Richard Biener <rguenther@suse.de>
Cc: gcc Patches <gcc-patches@gcc.gnu.org>, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: PR85734
Date: Mon, 14 May 2018 09:36:00 -0000 [thread overview]
Message-ID: <CAAgBjMmiswzFOcPwFdu+PyhhwggnEwPiZ9oemSqsQPTqNjWMCA@mail.gmail.com> (raw)
In-Reply-To: <alpine.LSU.2.20.1805141114240.24704@zhemvz.fhfr.qr>
[-- Attachment #1: Type: text/plain, Size: 832 bytes --]
On 14 May 2018 at 14:46, Richard Biener <rguenther@suse.de> wrote:
> On Mon, 14 May 2018, Prathamesh Kulkarni wrote:
>
>> Hi,
>> The attached patch tries to fix PR85734, by gating on
>> !function_always_visible_to_compiler_p.
>> Bootstrap+test in progress on x86_64.
>> OK to commit if passes ?
>
> This looks redundant - suggest_attribute does that very same check
> but warn_function_malloc passes it 'false' as known_finite
> (warn_function_noreturn passes it true for example).
Indeed, thanks for pointing it out.
>
> So I suggest to simply pass true as that arg.
Is the attached version OK to commit after bootstrap+test ?
Thanks,
Prathamesh
>
> Richard
>
>> Thanks,
>> Prathamesh
>>
>
> --
> Richard Biener <rguenther@suse.de>
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
[-- Attachment #2: pr85734-3.txt --]
[-- Type: text/plain, Size: 1463 bytes --]
2018-05-14 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR ipa/85734
* ipa-pure-const.c (warn_function_malloc): Pass value of known_finite param
as true in call to suggest_attribute.
testsuite/
* gcc.dg/ipa/pr85734.c: New test.
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index a80b6845633..7665358a9a5 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -249,7 +249,7 @@ warn_function_malloc (tree decl)
static hash_set<tree> *warned_about;
warned_about
= suggest_attribute (OPT_Wsuggest_attribute_malloc, decl,
- false, warned_about, "malloc");
+ true, warned_about, "malloc");
}
/* Emit suggestion about __attribute__((noreturn)) for DECL. */
diff --git a/gcc/testsuite/gcc.dg/ipa/pr85734.c b/gcc/testsuite/gcc.dg/ipa/pr85734.c
new file mode 100644
index 00000000000..e5fa21f0548
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr85734.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wsuggest-attribute=malloc" } */
+
+__attribute__((noinline))
+static void *f1(__SIZE_TYPE__ sz) /* { dg-bogus "function might be candidate for attribute 'malloc'" } */
+{
+ return __builtin_malloc (sz);
+}
+
+__attribute__((noinline))
+static void *f2(__SIZE_TYPE__ sz) /* { dg-bogus "function might be candidate for attribute 'malloc'" } */
+{
+ return f1 (sz);
+}
+
+void *f3(__SIZE_TYPE__ sz) /* { dg-warning "function might be candidate for attribute 'malloc'" } */
+{
+ return f2(sz);
+}
next prev parent reply other threads:[~2018-05-14 9:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-14 9:16 PR85734 Prathamesh Kulkarni
2018-05-14 9:33 ` PR85734 Richard Biener
2018-05-14 9:36 ` Prathamesh Kulkarni [this message]
2018-05-14 10:34 ` PR85734 Richard Biener
2018-05-14 12:41 ` PR85734 Prathamesh Kulkarni
2018-05-14 14:27 ` PR85734 Richard Biener
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=CAAgBjMmiswzFOcPwFdu+PyhhwggnEwPiZ9oemSqsQPTqNjWMCA@mail.gmail.com \
--to=prathamesh.kulkarni@linaro.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=rguenther@suse.de \
/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).