public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: gcc-patches@gcc.gnu.org
Cc: Andi Kleen <ak@linux.intel.com>
Subject: [PATCH] Dump functions for verification failures
Date: Wed, 17 May 2017 02:14:00 -0000	[thread overview]
Message-ID: <20170517021216.8236-1-andi@firstfloor.org> (raw)

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

             reply	other threads:[~2017-05-17  2:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17  2:14 Andi Kleen [this message]
2017-05-17  8:45 ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170517021216.8236-1-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=ak@linux.intel.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).