https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93583

--- Comment #16 from Martin Liška <marxin at gcc dot gnu.org> ---
> 
> I do:
> 
> __attribute__((noinline, malloc))
> foo.isra (const char * p)
> {
>   <bb 2> [local count: 1073741824]:
>   bar (p_1(D)); [tail call]
>   return;
> 
> }
> 
> main (int argc, char * * argv)
> {
>   char * _1;
> 
>   <bb 2> [local count: 1073741824]:
>   _1 = *argv_3(D);
>   foo.isra (_1);
>   return 0;
> 
> }

My bad, I used GCC 9.2 that does not have IPA SRA pass.

With my checking code:

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 294b2d392fd..6e99fbb45f4 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -3374,6 +3374,12 @@ cgraph_node::verify_node (void)
       error ("calls_comdat_local is set outside of a comdat group");
       error_found = true;
     }
+  if (DECL_IS_MALLOC (decl)
+      && VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
+    {
+      error ("MALLOC attribute set on a void function");
+      error_found = true;
+    }
   for (e = indirect_calls; e; e = e->next_callee)
     {
       if (e->aux)

I see:

$ gcc malloc.c -c -O2 -fdump-tree-optimized=/dev/stdout
malloc.c:11:1: error: MALLOC attribute set on a void function
   11 | }
      | ^
foo.isra.0/3 (foo.isra) @0x7ffff77c7438
  Type: function definition analyzed
  Visibility:
  References: 
  Referring: 
  Clone of foo/0
  Availability: local
  Function flags: count:1073741824 (estimated locally) local executed_once
  Called by: main/1 (1073741824 (estimated locally),1.00 per call) 
  Calls: bar/2 (1073741824 (estimated locally),1.00 per call) 
during IPA pass: sra

Reply via email to