/* Calculate (post)dominators in slightly super-linear time.
- Copyright (C) 2000-2013 Free Software Foundation, Inc.
+ Copyright (C) 2000-2015 Free Software Foundation, Inc.
Contributed by Michael Matz (matz@ifh.de).
This file is part of GCC.
#include "rtl.h"
#include "hard-reg-set.h"
#include "obstack.h"
+#include "predict.h"
+#include "function.h"
+#include "dominance.h"
+#include "cfg.h"
+#include "cfganal.h"
#include "basic-block.h"
#include "diagnostic-core.h"
+#include "alloc-pool.h"
#include "et-forest.h"
#include "timevar.h"
-#include "pointer-set.h"
#include "graphds.h"
#include "bitmap.h"
di->path_min[s] = di->path_min[w];
di->set_size[v] += di->set_size[w];
if (di->set_size[v] < 2 * di->set_size[w])
- {
- TBB tmp = s;
- s = di->set_child[v];
- di->set_child[v] = tmp;
- }
+ std::swap (di->set_child[v], s);
/* Merge all subtrees. */
while (s)
bool reverse = (dir == CDI_POST_DOMINATORS) ? true : false;
if (dom_computed[dir_index] == DOM_OK)
- return;
+ {
+#if ENABLE_CHECKING
+ verify_dominators (dir);
+#endif
+ return;
+ }
timevar_push (TV_DOMINANCE);
if (!dom_info_available_p (dir))
free_dom_info (&di);
dom_computed[dir_index] = DOM_NO_FAST_QUERY;
}
+ else
+ {
+#if ENABLE_CHECKING
+ verify_dominators (dir);
+#endif
+ }
compute_dom_fast_query (dir);
/* Free dominance information for direction DIR. */
void
-free_dominance_info (enum cdi_direction dir)
+free_dominance_info (function *fn, enum cdi_direction dir)
{
basic_block bb;
unsigned int dir_index = dom_convert_dir_to_idx (dir);
- if (!dom_info_available_p (dir))
+ if (!dom_info_available_p (fn, dir))
return;
- FOR_ALL_BB_FN (bb, cfun)
+ FOR_ALL_BB_FN (bb, fn)
{
et_free_tree_force (bb->dom[dir_index]);
bb->dom[dir_index] = NULL;
}
et_free_pools ();
- n_bbs_in_dom_tree[dir_index] = 0;
+ fn->cfg->x_n_bbs_in_dom_tree[dir_index] = 0;
- dom_computed[dir_index] = DOM_NONE;
+ fn->cfg->x_dom_computed[dir_index] = DOM_NONE;
+}
+
+void
+free_dominance_info (enum cdi_direction dir)
+{
+ free_dominance_info (cfun, dir);
}
/* Return the immediate dominator of basic block BB. */
A_Dominated_by_B (node A, node B)
{
- return DFS_Number_In(A) >= DFS_Number_In(A)
+ return DFS_Number_In(A) >= DFS_Number_In(B)
&& DFS_Number_Out (A) <= DFS_Number_Out(B);
} */
size_t dom_i;
edge e;
edge_iterator ei;
- pointer_map<int> *map;
int *parent, *son, *brother;
unsigned int dir_index = dom_convert_dir_to_idx (dir);
}
/* Construct the graph G. */
- map = new pointer_map<int>;
+ hash_map<basic_block, int> map (251);
FOR_EACH_VEC_ELT (bbs, i, bb)
{
/* If the dominance tree is conservatively correct, split it now. */
if (conservative)
set_immediate_dominator (CDI_DOMINATORS, bb, NULL);
- *map->insert (bb) = i;
+ map.put (bb, i);
}
- *map->insert (ENTRY_BLOCK_PTR_FOR_FN (cfun)) = n;
+ map.put (ENTRY_BLOCK_PTR_FOR_FN (cfun), n);
g = new_graph (n + 1);
for (y = 0; y < g->n_vertices; y++)
if (dom == bb)
continue;
- dom_i = *map->contains (dom);
+ dom_i = *map.get (dom);
/* Do not include parallel edges to G. */
if (!bitmap_set_bit ((bitmap) g->vertices[dom_i].data, i))
}
for (y = 0; y < g->n_vertices; y++)
BITMAP_FREE (g->vertices[y].data);
- delete map;
/* Find the dominator tree of G. */
son = XNEWVEC (int, n + 1);
/* Return dominance availability for dominance info DIR. */
enum dom_state
-dom_info_state (enum cdi_direction dir)
+dom_info_state (function *fn, enum cdi_direction dir)
{
+ if (!fn->cfg)
+ return DOM_NONE;
+
unsigned int dir_index = dom_convert_dir_to_idx (dir);
+ return fn->cfg->x_dom_computed[dir_index];
+}
- return dom_computed[dir_index];
+enum dom_state
+dom_info_state (enum cdi_direction dir)
+{
+ return dom_info_state (cfun, dir);
}
/* Set the dominance availability for dominance info DIR to NEW_STATE. */
/* Returns true if dominance information for direction DIR is available. */
bool
-dom_info_available_p (enum cdi_direction dir)
+dom_info_available_p (function *fn, enum cdi_direction dir)
{
- unsigned int dir_index = dom_convert_dir_to_idx (dir);
+ return dom_info_state (fn, dir) != DOM_NONE;
+}
- return dom_computed[dir_index] != DOM_NONE;
+bool
+dom_info_available_p (enum cdi_direction dir)
+{
+ return dom_info_available_p (cfun, dir);
}
DEBUG_FUNCTION void