diff mbox series

[v8,11/12] Dump reason for missing tail call into dump file

Message ID 20240622185557.1589179-12-ak@linux.intel.com
State New
Headers show
Series [v8,01/12] Improve must tail in RTL backend | expand

Commit Message

Andi Kleen June 22, 2024, 6:54 p.m. UTC
gcc/ChangeLog:

	* tree-tailcall.cc (maybe_error_musttail): Print reason to
        dump_file.
	(find_tail_calls): Print gimple stmt or other reasons that stop
        the search for tail calls into dump file.
---
 gcc/tree-tailcall.cc | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Richard Biener July 5, 2024, 11:47 a.m. UTC | #1
On Sat, Jun 22, 2024 at 9:01 PM Andi Kleen <ak@linux.intel.com> wrote:
>
> gcc/ChangeLog:

OK.  Btw, I wonder if you can squash all error/dump related patches to
tree-tailcall.cc

>         * tree-tailcall.cc (maybe_error_musttail): Print reason to
>         dump_file.
>         (find_tail_calls): Print gimple stmt or other reasons that stop
>         the search for tail calls into dump file.
> ---
>  gcc/tree-tailcall.cc | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/tree-tailcall.cc b/gcc/tree-tailcall.cc
> index a77fa1511415..f69a9ad40bda 100644
> --- a/gcc/tree-tailcall.cc
> +++ b/gcc/tree-tailcall.cc
> @@ -442,6 +442,11 @@ maybe_error_musttail (gcall *call, const char *err)
>        gimple_call_set_must_tail (call, false); /* Avoid another error.  */
>        gimple_call_set_tail (call, false);
>      }
> +  if (dump_file)
> +    {
> +      print_gimple_stmt (dump_file, call, 0, TDF_SLIM);
> +      fprintf (dump_file, "Cannot convert: %s\n", err);
> +    }
>  }
>
>  /* Count succ edges for BB and return in NUM_OTHER and NUM_EH.  */
> @@ -492,7 +497,12 @@ find_tail_calls (basic_block bb, struct tailcall **ret, bool only_musttail,
>        /* Allow EH edges so that we can give a better
>          error message later.  */
>        if (num_other != 1)
> -       return;
> +       {
> +         if (dump_file)
> +           fprintf (dump_file, "Basic block %d has %d eh / %d other edges\n",
> +                          bb->index, num_eh, num_other);
> +         return;
> +       }
>      }
>
>    bool bad_stmt = false;
> @@ -537,6 +547,11 @@ find_tail_calls (basic_block bb, struct tailcall **ret, bool only_musttail,
>        if (gimple_references_memory_p (stmt)
>           || gimple_has_volatile_ops (stmt))
>         {
> +         if (dump_file)
> +           {
> +             fprintf (dump_file, "Cannot handle ");
> +             print_gimple_stmt (dump_file, stmt, 0);
> +           }
>           bad_stmt = true;
>         }
>      }
> --
> 2.45.2
>
diff mbox series

Patch

diff --git a/gcc/tree-tailcall.cc b/gcc/tree-tailcall.cc
index a77fa1511415..f69a9ad40bda 100644
--- a/gcc/tree-tailcall.cc
+++ b/gcc/tree-tailcall.cc
@@ -442,6 +442,11 @@  maybe_error_musttail (gcall *call, const char *err)
       gimple_call_set_must_tail (call, false); /* Avoid another error.  */
       gimple_call_set_tail (call, false);
     }
+  if (dump_file)
+    {
+      print_gimple_stmt (dump_file, call, 0, TDF_SLIM);
+      fprintf (dump_file, "Cannot convert: %s\n", err);
+    }
 }
 
 /* Count succ edges for BB and return in NUM_OTHER and NUM_EH.  */
@@ -492,7 +497,12 @@  find_tail_calls (basic_block bb, struct tailcall **ret, bool only_musttail,
       /* Allow EH edges so that we can give a better
 	 error message later.  */
       if (num_other != 1)
-	return;
+	{
+	  if (dump_file)
+	    fprintf (dump_file, "Basic block %d has %d eh / %d other edges\n",
+			   bb->index, num_eh, num_other);
+	  return;
+	}
     }
 
   bool bad_stmt = false;
@@ -537,6 +547,11 @@  find_tail_calls (basic_block bb, struct tailcall **ret, bool only_musttail,
       if (gimple_references_memory_p (stmt)
 	  || gimple_has_volatile_ops (stmt))
 	{
+	  if (dump_file)
+	    {
+	      fprintf (dump_file, "Cannot handle ");
+	      print_gimple_stmt (dump_file, stmt, 0);
+	    }
 	  bad_stmt = true;
 	}
     }