Mercurial > hg > CbC > CbC_gcc
diff gcc/domwalk.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
line wrap: on
line diff
--- a/gcc/domwalk.c Sun Feb 07 18:28:00 2010 +0900 +++ b/gcc/domwalk.c Fri Feb 12 23:39:51 2010 +0900 @@ -23,13 +23,11 @@ #include "system.h" #include "coretypes.h" #include "tm.h" -#include "tree.h" #include "basic-block.h" -#include "tree-flow.h" #include "domwalk.h" #include "ggc.h" -/* This file implements a generic walker for dominator trees. +/* This file implements a generic walker for dominator trees. To understand the dominator walker one must first have a grasp of dominators, immediate dominators and the dominator tree. @@ -71,8 +69,8 @@ | +--9 11 | / | +--- 10 ---> 12 - - + + We have a dominator tree which looks like 1 @@ -90,34 +88,34 @@ 9 | 10 - - - + + + The dominator tree is the basis for a number of analysis, transformation and optimization algorithms that operate on a semi-global basis. - + The dominator walker is a generic routine which visits blocks in the CFG via a depth first search of the dominator tree. In the example above the dominator walker might visit blocks in the following order 1, 2, 3, 4, 5, 8, 9, 10, 6, 7, 11, 12. - + The dominator walker has a number of callbacks to perform actions during the walk of the dominator tree. There are two callbacks which walk statements, one before visiting the dominator children, - one after visiting the dominator children. There is a callback + one after visiting the dominator children. There is a callback before and after each statement walk callback. In addition, the dominator walker manages allocation/deallocation of data structures which are local to each block visited. - + The dominator walker is meant to provide a generic means to build a pass which can analyze or transform/optimize a function based on walking the dominator tree. One simply fills in the dominator walker data structure with the appropriate callbacks and calls the walker. - + We currently use the dominator walker to prune the set of variables which might need PHI nodes (which can greatly improve compile-time performance in some cases). - + We also use the dominator walker to rewrite the function into SSA form which reduces code duplication since the rewriting phase is inherently a walk of the dominator tree. @@ -144,8 +142,6 @@ { void *bd = NULL; basic_block dest; - gimple_stmt_iterator gsi; - bool is_interesting; basic_block *worklist = XNEWVEC (basic_block, n_basic_blocks * 2); int sp = 0; @@ -156,13 +152,6 @@ || bb == ENTRY_BLOCK_PTR || bb == EXIT_BLOCK_PTR) { - /* If block BB is not interesting to the caller, then none of the - callbacks that walk the statements in BB are going to be - executed. */ - is_interesting = walk_data->interesting_blocks == NULL - || TEST_BIT (walk_data->interesting_blocks, - bb->index); - /* Callback to initialize the local data structure. */ if (walk_data->initialize_block_local_data) { @@ -192,27 +181,8 @@ /* Callback for operations to execute before we have walked the dominator children, but before we walk statements. */ - if (walk_data->before_dom_children_before_stmts) - (*walk_data->before_dom_children_before_stmts) (walk_data, bb); - - /* Statement walk before walking dominator children. */ - if (is_interesting && walk_data->before_dom_children_walk_stmts) - { - if (walk_data->walk_stmts_backward) - for (gsi = gsi_last (bb_seq (bb)); !gsi_end_p (gsi); - gsi_prev (&gsi)) - (*walk_data->before_dom_children_walk_stmts) (walk_data, bb, - gsi); - else - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - (*walk_data->before_dom_children_walk_stmts) (walk_data, bb, - gsi); - } - - /* Callback for operations to execute before we have walked the - dominator children, and after we walk statements. */ - if (walk_data->before_dom_children_after_stmts) - (*walk_data->before_dom_children_after_stmts) (walk_data, bb); + if (walk_data->before_dom_children) + (*walk_data->before_dom_children) (walk_data, bb); /* Mark the current BB to be popped out of the recursion stack once children are processed. */ @@ -223,37 +193,16 @@ dest; dest = next_dom_son (walk_data->dom_direction, dest)) worklist[sp++] = dest; } - /* NULL is used to signalize pop operation in recursion stack. */ + /* NULL is used to mark pop operations in the recursion stack. */ while (sp > 0 && !worklist[sp - 1]) { --sp; bb = worklist[--sp]; - is_interesting = walk_data->interesting_blocks == NULL - || TEST_BIT (walk_data->interesting_blocks, - bb->index); + /* Callback for operations to execute after we have walked the dominator children, but before we walk statements. */ - if (walk_data->after_dom_children_before_stmts) - (*walk_data->after_dom_children_before_stmts) (walk_data, bb); - - /* Statement walk after walking dominator children. */ - if (is_interesting && walk_data->after_dom_children_walk_stmts) - { - if (walk_data->walk_stmts_backward) - for (gsi = gsi_last (bb_seq (bb)); !gsi_end_p (gsi); - gsi_prev (&gsi)) - (*walk_data->after_dom_children_walk_stmts) (walk_data, bb, - gsi); - else - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - (*walk_data->after_dom_children_walk_stmts) (walk_data, bb, - gsi); - } - - /* Callback for operations to execute after we have walked the - dominator children and after we have walked statements. */ - if (walk_data->after_dom_children_after_stmts) - (*walk_data->after_dom_children_after_stmts) (walk_data, bb); + if (walk_data->after_dom_children) + (*walk_data->after_dom_children) (walk_data, bb); if (walk_data->initialize_block_local_data) {