[PATCH] Dump functions for verification failures

Richard Biener richard.guenther@gmail.com
Wed May 17 08:45:00 GMT 2017


On Wed, May 17, 2017 at 4:12 AM, Andi Kleen <andi@firstfloor.org> wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> When a verification check fails it is useful to dump the current
> function to the dump file, so it's easier to figure out what
> actually went wrong.
>
> Add function dumps for gimple or SSA verification failures.
>
> Suggested by Jakub.
>
> Passes bootstrap and testing on x86_64-linux
>
> gcc/:
>
> 2017-05-16  Andi Kleen  <ak@linux.intel.com>
>
>         * tree-cfg.c (verify_gimple_in_cfg): Dump function.

At this point the dump is probably redundant, there are also many
other verify places.

>         * tree-into-ssa.c (update_ssa): Dump function.
>         * tree-outof-ssa.c (eliminate_useless_phis): Dump function.
>         (rewrite_trees): Dump function.
> ---
>  gcc/tree-cfg.c       | 6 +++++-
>  gcc/tree-into-ssa.c  | 2 ++
>  gcc/tree-outof-ssa.c | 4 ++++
>  3 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
> index 7dbd0a8c247..05073906fbd 100644
> --- a/gcc/tree-cfg.c
> +++ b/gcc/tree-cfg.c
> @@ -5279,7 +5279,11 @@ verify_gimple_in_cfg (struct function *fn, bool verify_nothrow)
>        (&visited_stmts);
>
>    if (err || eh_error_found)
> -    internal_error ("verify_gimple failed");
> +    {
> +      if (dump_file)
> +       dump_function_to_file (fn->decl, dump_file, dump_flags);
> +      internal_error ("verify_gimple failed");
> +    }
>
>    verify_histograms ();
>    timevar_pop (TV_TREE_STMT_VERIFY);
> diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
> index d4056373f31..de150b8e917 100644
> --- a/gcc/tree-into-ssa.c
> +++ b/gcc/tree-into-ssa.c
> @@ -3387,6 +3387,8 @@ update_ssa (unsigned update_flags)
>                          "renaming: ");
>                 print_generic_expr (stderr, name, TDF_SLIM);
>                 fprintf (stderr, "\n");
> +               if (dump_file)
> +                 dump_function_to_file (cfun->decl, dump_file, dump_flags);

So you still have to look what dump-file there is.

>                 internal_error ("SSA corruption");
>               }
>           }
> diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
> index 0ce6c155bd3..8be0b1088df 100644
> --- a/gcc/tree-outof-ssa.c
> +++ b/gcc/tree-outof-ssa.c
> @@ -821,6 +821,8 @@ eliminate_useless_phis (void)
>                         print_generic_expr (stderr, arg, TDF_SLIM);
>                         fprintf (stderr, "), but the result is :");
>                         print_gimple_stmt (stderr, phi, 0, TDF_SLIM);
> +                       if (dump_file)
> +                         dump_function_to_file (cfun->decl, dump_file, dump_flags);
>                         internal_error ("SSA corruption");
>                       }
>                   }
> @@ -880,6 +882,8 @@ rewrite_trees (var_map map)
>                       print_generic_expr (stderr, arg, TDF_SLIM);
>                       fprintf (stderr, "), but the result is not :");
>                       print_gimple_stmt (stderr, phi, 0, TDF_SLIM);
> +                     if (dump_file)
> +                       dump_function_to_file (cfun->decl, dump_file, dump_flags);

Maybe we can instead hook into internal_error and

 a) report the pass (and dump_file)
 b) dump the actual error and a disclaimer
 c) dump the function

?  That also catches all the places you forgot.

>                       internal_error ("SSA corruption");
>                     }
>                 }
> --
> 2.12.2
>



More information about the Gcc-patches mailing list