public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PR85734
@ 2018-05-14  9:16 Prathamesh Kulkarni
  2018-05-14  9:33 ` PR85734 Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: Prathamesh Kulkarni @ 2018-05-14  9:16 UTC (permalink / raw)
  To: gcc Patches, Jan Hubicka, Richard Biener

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

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 ?

Thanks,
Prathamesh

[-- Attachment #2: pr85734-2.txt --]
[-- Type: text/plain, Size: 1962 bytes --]

2018-05-14  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	PR ipa/85734
	* ipa-pure-const.c (propagate_malloc): Gate call towarn_function_malloc 
	on !funcion_always_visible_to_compiler_p.
	(pass_local_pure_const::execute): Likewise.

testsuite/
	* gcc.dg/ipa/pr85734.c: New test.

diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index a80b6845633..ce8028c1639 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -1987,7 +1987,8 @@ propagate_malloc (void)
 
 	    bool malloc_decl_p = DECL_IS_MALLOC (node->decl);
 	    node->set_malloc_flag (true);
-	    if (!malloc_decl_p && warn_suggest_attribute_malloc)
+	    if (!malloc_decl_p && !function_always_visible_to_compiler_p (node->decl)
+		&& warn_suggest_attribute_malloc)
 		warn_function_malloc (node->decl);
 	  }
       }
@@ -2221,7 +2222,8 @@ pass_local_pure_const::execute (function *fun)
       && !DECL_IS_MALLOC (current_function_decl))
     {
       node->set_malloc_flag (true);
-      if (warn_suggest_attribute_malloc)
+      if (warn_suggest_attribute_malloc
+	  && !function_always_visible_to_compiler_p (current_function_decl))
 	warn_function_malloc (node->decl);
       changed = true;
       if (dump_file)
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);
+}

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-14 14:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14  9:16 PR85734 Prathamesh Kulkarni
2018-05-14  9:33 ` PR85734 Richard Biener
2018-05-14  9:36   ` PR85734 Prathamesh Kulkarni
2018-05-14 10:34     ` PR85734 Richard Biener
2018-05-14 12:41       ` PR85734 Prathamesh Kulkarni
2018-05-14 14:27         ` PR85734 Richard Biener

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).