This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 9b] Don't assume that copy tables were initialized
- From: David Malcolm <dmalcolm at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Mon, 9 Jan 2017 21:38:16 -0500
- Subject: [PATCH 9b] Don't assume that copy tables were initialized
- Authentication-results: sourceware.org; auth=none
- References: <1484015904-32671-1-git-send-email-dmalcolm@redhat.com>
gcc/ChangeLog:
* cfg.c (original_copy_tables_initialized_p): New function.
* cfg.h (original_copy_tables_initialized_p): New decl.
* cfgrtl.c (relink_block_chain): Guard the call to
free_original_copy_tables with a call to
original_copy_tables_initialized_p.
---
gcc/cfg.c | 9 +++++++++
gcc/cfg.h | 1 +
gcc/cfgrtl.c | 3 ++-
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/gcc/cfg.c b/gcc/cfg.c
index 97cc755..f30b680 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -1094,6 +1094,15 @@ free_original_copy_tables (void)
original_copy_bb_pool = NULL;
}
+/* Return true iff we have had a call to initialize_original_copy_tables
+ without a corresponding call to free_original_copy_tables. */
+
+bool
+original_copy_tables_initialized_p (void)
+{
+ return original_copy_bb_pool != NULL;
+}
+
/* Removes the value associated with OBJ from table TAB. */
static void
diff --git a/gcc/cfg.h b/gcc/cfg.h
index d421d3b..b44f1e1 100644
--- a/gcc/cfg.h
+++ b/gcc/cfg.h
@@ -110,6 +110,7 @@ extern void scale_bbs_frequencies_gcov_type (basic_block *, int, gcov_type,
extern void initialize_original_copy_tables (void);
extern void reset_original_copy_tables (void);
extern void free_original_copy_tables (void);
+extern bool original_copy_tables_initialized_p (void);
extern void set_bb_original (basic_block, basic_block);
extern basic_block get_bb_original (basic_block);
extern void set_bb_copy (basic_block, basic_block);
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 7604346..b3b1146 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -3646,7 +3646,8 @@ relink_block_chain (bool stay_in_cfglayout_mode)
/* Maybe reset the original copy tables, they are not valid anymore
when we renumber the basic blocks in compact_blocks. If we are
are going out of cfglayout mode, don't re-allocate the tables. */
- free_original_copy_tables ();
+ if (original_copy_tables_initialized_p ())
+ free_original_copy_tables ();
if (stay_in_cfglayout_mode)
initialize_original_copy_tables ();
--
1.8.5.3