* [PATCH] Dump functions for verification failures
@ 2017-05-17 2:14 Andi Kleen
2017-05-17 8:45 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Andi Kleen @ 2017-05-17 2:14 UTC (permalink / raw)
To: gcc-patches; +Cc: Andi Kleen
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.
* 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);
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);
internal_error ("SSA corruption");
}
}
--
2.12.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Dump functions for verification failures
2017-05-17 2:14 [PATCH] Dump functions for verification failures Andi Kleen
@ 2017-05-17 8:45 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-05-17 8:45 UTC (permalink / raw)
To: Andi Kleen; +Cc: GCC Patches, Andi Kleen
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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-17 7:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17 2:14 [PATCH] Dump functions for verification failures Andi Kleen
2017-05-17 8:45 ` 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).