public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Check no unreachable blocks in inverted_post_order_compute
@ 2015-10-12 13:11 Tom de Vries
  2015-10-12 20:34 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2015-10-12 13:11 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 383 bytes --]

Hi,

in the header comment of function inverted_post_order_compute in 
cfganal.c we find:
...
    This function assumes that all blocks in the CFG are reachable
    from the ENTRY (but not necessarily from EXIT).
...

This patch checks that there are indeed no unreachable blocks when 
calling inverted_post_order_compute.

OK for trunk if bootstrap/regtest succeeds?

Thanks,
- Tom

[-- Attachment #2: 0001-Check-no-unreachable-blocks-in-inverted_post_order_c.patch --]
[-- Type: text/x-patch, Size: 1736 bytes --]

Check no unreachable blocks in inverted_post_order_compute

2015-10-12  Tom de Vries  <tom@codesourcery.com>

	* cfganal.c (verify_no_unreachable_blocks): New function.
	(inverted_post_order_compute) [ENABLE_CHECKING]: Call
	verify_no_unreachable_blocks.
	cfganal.h (verify_no_unreachable_blocks): Declare.
---
 gcc/cfganal.c | 17 +++++++++++++++++
 gcc/cfganal.h |  1 +
 2 files changed, 18 insertions(+)

diff --git a/gcc/cfganal.c b/gcc/cfganal.c
index 279c3b5..1f935eb 100644
--- a/gcc/cfganal.c
+++ b/gcc/cfganal.c
@@ -193,6 +193,19 @@ find_unreachable_blocks (void)
 
   free (worklist);
 }
+
+/* Verify that there are no unreachable blocks in the current function.  */
+
+void
+verify_no_unreachable_blocks (void)
+{
+  find_unreachable_blocks ();
+
+  basic_block bb;
+  FOR_EACH_BB_FN (bb, cfun)
+    gcc_assert ((bb->flags & BB_REACHABLE) != 0);
+}
+
 \f
 /* Functions to access an edge list with a vector representation.
    Enough data is kept such that given an index number, the
@@ -772,6 +785,10 @@ inverted_post_order_compute (int *post_order)
   int post_order_num = 0;
   sbitmap visited;
 
+#if ENABLE_CHECKING
+  verify_no_unreachable_blocks ();
+#endif
+
   /* Allocate stack for back-tracking up CFG.  */
   stack = XNEWVEC (edge_iterator, n_basic_blocks_for_fn (cfun) + 1);
   sp = 0;
diff --git a/gcc/cfganal.h b/gcc/cfganal.h
index 3eb4764..2ad00c0 100644
--- a/gcc/cfganal.h
+++ b/gcc/cfganal.h
@@ -49,6 +49,7 @@ private:
 
 extern bool mark_dfs_back_edges (void);
 extern void find_unreachable_blocks (void);
+extern void verify_no_unreachable_blocks (void);
 struct edge_list * create_edge_list (void);
 void free_edge_list (struct edge_list *);
 void print_edge_list (FILE *, struct edge_list *);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Check no unreachable blocks in inverted_post_order_compute
  2015-10-12 13:11 [PATCH] Check no unreachable blocks in inverted_post_order_compute Tom de Vries
@ 2015-10-12 20:34 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2015-10-12 20:34 UTC (permalink / raw)
  To: Tom de Vries, gcc-patches

On 10/12/2015 07:10 AM, Tom de Vries wrote:
> Hi,
>
> in the header comment of function inverted_post_order_compute in
> cfganal.c we find:
> ...
>     This function assumes that all blocks in the CFG are reachable
>     from the ENTRY (but not necessarily from EXIT).
> ...
>
> This patch checks that there are indeed no unreachable blocks when
> calling inverted_post_order_compute.
>
> OK for trunk if bootstrap/regtest succeeds?
Yes.  I won't queue it behind Mikhail's changes.  Consider yourself 
lucky :-)

jeff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-12 20:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-12 13:11 [PATCH] Check no unreachable blocks in inverted_post_order_compute Tom de Vries
2015-10-12 20:34 ` Jeff Law

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).