diff options
author | rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-05-24 14:02:12 +0000 |
---|---|---|
committer | rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-05-24 14:02:12 +0000 |
commit | 96c90e5e0abd447bdcf81f5bcfe76a2a59a9b4dd (patch) | |
tree | 9bb72d30323dfced6a574b1c6fc4064792090034 /gcc/cfg.c | |
parent | 7ed90ee0f408293bdd383a39c89af3d26b1bc50c (diff) | |
download | gcc-96c90e5e0abd447bdcf81f5bcfe76a2a59a9b4dd.tar.gz |
PR middle-end/32018
* tree-ssa-threadupdate.c (thread_through_loop_header): Use
set_loop_copy.
(thread_through_all_blocks): Call initialize_original_copy_tables
and free_original_copy_tables.
* cfgloopmanip.c (duplicate_loop, duplicate_loop_to_header_edge):
Use set_loop_copy.
* tree-cfg.c (tree_duplicate_sese_region): Ditto.
* cfghooks.c (duplicate_block): Use get_loop_copy.
* cfg.c: Include cfgloop.h.
(loop_copy): New hash table.
(initialize_original_copy_tables): Initialize loop_copy table.
(free_original_copy_tables): Free loop_copy table.
(copy_original_table_clear, copy_original_table_set,
set_loop_copy, get_loop_copy): New functions.
(set_bb_original, set_bb_copy): Use copy_original_table_set.
* cfgloop.h (struct loop): Remove copy field.
* Makefile.in (cfg.o): Add CFGLOOP_H dependency.
* basic-block.h (set_loop_copy, get_loop_copy): Declare.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@125024 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfg.c')
-rw-r--r-- | gcc/cfg.c | 119 |
1 files changed, 83 insertions, 36 deletions
diff --git a/gcc/cfg.c b/gcc/cfg.c index 9f5da32bfe8..63d053067fd 100644 --- a/gcc/cfg.c +++ b/gcc/cfg.c @@ -66,6 +66,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "ggc.h" #include "hashtab.h" #include "alloc-pool.h" +#include "cfgloop.h" /* The obstack on which the flow graph components are allocated. */ @@ -1027,6 +1028,9 @@ scale_bbs_frequencies_gcov_type (basic_block *bbs, int nbbs, gcov_type num, copies. */ static htab_t bb_original; static htab_t bb_copy; + +/* And between loops and copies. */ +static htab_t loop_copy; static alloc_pool original_copy_bb_pool; struct htab_bb_copy_original_entry @@ -1068,6 +1072,7 @@ initialize_original_copy_tables (void) bb_original = htab_create (10, bb_copy_original_hash, bb_copy_original_eq, NULL); bb_copy = htab_create (10, bb_copy_original_hash, bb_copy_original_eq, NULL); + loop_copy = htab_create (10, bb_copy_original_hash, bb_copy_original_eq, NULL); } /* Free the data structures to maintain mapping between blocks and @@ -1078,35 +1083,64 @@ free_original_copy_tables (void) gcc_assert (original_copy_bb_pool); htab_delete (bb_copy); htab_delete (bb_original); + htab_delete (loop_copy); free_alloc_pool (original_copy_bb_pool); bb_copy = NULL; bb_original = NULL; + loop_copy = NULL; original_copy_bb_pool = NULL; } +/* Removes the value associated with OBJ from table TAB. */ + +static void +copy_original_table_clear (htab_t tab, unsigned obj) +{ + void **slot; + struct htab_bb_copy_original_entry key, *elt; + + if (!original_copy_bb_pool) + return; + + key.index1 = obj; + slot = htab_find_slot (tab, &key, NO_INSERT); + if (!slot) + return; + + elt = *slot; + htab_clear_slot (tab, slot); + pool_free (original_copy_bb_pool, elt); +} + +/* Sets the value associated with OBJ in table TAB to VAL. + Do nothing when data structures are not initialized. */ + +static void +copy_original_table_set (htab_t tab, unsigned obj, unsigned val) +{ + struct htab_bb_copy_original_entry **slot; + struct htab_bb_copy_original_entry key; + + if (!original_copy_bb_pool) + return; + + key.index1 = obj; + slot = (struct htab_bb_copy_original_entry **) + htab_find_slot (tab, &key, INSERT); + if (!*slot) + { + *slot = pool_alloc (original_copy_bb_pool); + (*slot)->index1 = obj; + } + (*slot)->index2 = val; +} + /* Set original for basic block. Do nothing when data structures are not initialized so passes not needing this don't need to care. */ void set_bb_original (basic_block bb, basic_block original) { - if (original_copy_bb_pool) - { - struct htab_bb_copy_original_entry **slot; - struct htab_bb_copy_original_entry key; - - key.index1 = bb->index; - slot = - (struct htab_bb_copy_original_entry **) htab_find_slot (bb_original, - &key, INSERT); - if (*slot) - (*slot)->index2 = original->index; - else - { - *slot = pool_alloc (original_copy_bb_pool); - (*slot)->index1 = bb->index; - (*slot)->index2 = original->index; - } - } + copy_original_table_set (bb_original, bb->index, original->index); } /* Get the original basic block. */ @@ -1131,24 +1165,7 @@ get_bb_original (basic_block bb) void set_bb_copy (basic_block bb, basic_block copy) { - if (original_copy_bb_pool) - { - struct htab_bb_copy_original_entry **slot; - struct htab_bb_copy_original_entry key; - - key.index1 = bb->index; - slot = - (struct htab_bb_copy_original_entry **) htab_find_slot (bb_copy, - &key, INSERT); - if (*slot) - (*slot)->index2 = copy->index; - else - { - *slot = pool_alloc (original_copy_bb_pool); - (*slot)->index1 = bb->index; - (*slot)->index2 = copy->index; - } - } + copy_original_table_set (bb_copy, bb->index, copy->index); } /* Get the copy of basic block. */ @@ -1167,3 +1184,33 @@ get_bb_copy (basic_block bb) else return NULL; } + +/* Set copy for LOOP to COPY. Do nothing when data structures are not + initialized so passes not needing this don't need to care. */ + +void +set_loop_copy (struct loop *loop, struct loop *copy) +{ + if (!copy) + copy_original_table_clear (loop_copy, loop->num); + else + copy_original_table_set (loop_copy, loop->num, copy->num); +} + +/* Get the copy of LOOP. */ + +struct loop * +get_loop_copy (struct loop *loop) +{ + struct htab_bb_copy_original_entry *entry; + struct htab_bb_copy_original_entry key; + + gcc_assert (original_copy_bb_pool); + + key.index1 = loop->num; + entry = (struct htab_bb_copy_original_entry *) htab_find (loop_copy, &key); + if (entry) + return get_loop (entry->index2); + else + return NULL; +} |