PandA-2024.02
Dominance.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
62 #ifndef DOMINANCE_HPP
63 #define DOMINANCE_HPP
64 
66 #include "Parameter.hpp"
67 
69 #include "custom_map.hpp"
70 #include "custom_set.hpp"
71 #include <vector>
72 
74 #include "dbgPrintHelper.hpp" // for DEBUG_LEVEL_NONE
75 #include "exceptions.hpp"
76 #include "string_manipulation.hpp" // for GET_CLASS
77 #include <boost/graph/adjacency_list.hpp>
78 #include <boost/graph/graph_utility.hpp>
79 #include <boost/graph/reverse_graph.hpp>
80 #include <boost/version.hpp>
81 
83 using TBB = unsigned long;
84 
90 template <typename GraphObj>
91 class dom_info
92 {
95  private:
97  using Vertex = typename boost::graph_traits<const GraphObj>::vertex_descriptor;
99  using in_edge_iterator = typename boost::graph_traits<const GraphObj>::in_edge_iterator;
101  using out_edge_iterator = typename boost::graph_traits<const GraphObj>::out_edge_iterator;
103  using edge = typename boost::graph_traits<const GraphObj>::edge_descriptor;
105  using Vertex_iterator = typename boost::graph_traits<const GraphObj>::vertex_iterator;
106 
108  std::vector<TBB> dfs_parent;
109 
115  std::vector<TBB> key;
116 
119  std::vector<TBB> path_min;
120 
122  std::vector<TBB> bucket;
123 
125  std::vector<TBB> next_bucket;
126 
132  std::vector<TBB> set_chain;
133 
135  std::vector<unsigned int> set_size;
140  std::vector<TBB> set_child;
141 
143  unsigned int dfsnum;
144 
146  unsigned int nodes;
147 
153 
155  const unsigned long int last_basic_block;
156 
158  const Vertex& en_block;
159 
161  const Vertex& ex_block;
162 
164  const GraphObj& g;
165 
167  std::vector<TBB> dom;
168 
174  std::vector<TBB> dfs_order;
181  std::vector<Vertex> dfs_to_bb;
182 
184  std::map<Vertex, size_t> index_map;
185 
188 
196  {
198  "-->Computing dfs tree starting from v_" + std::to_string(index_map[bb]));
199  // bb is the parent Vertex
200  /* We call this _only_ if bb is not already visited. */
201  edge e;
202  TBB child_i, my_i = 0;
203  typename boost::graph_traits<GraphObj>::out_edge_iterator ei, ei_end;
204 
205  for(boost::tie(ei, ei_end) = boost::out_edges(bb, g); ei != ei_end; ei++)
206  {
207  // bn is the child Vertex
208  Vertex bn = boost::target(*ei, g);
209  // if it has yet been visited we skip it
210  if(dfs_order[index_map[bn]])
211  {
212  continue;
213  }
214 
215  /* Fill the DFS tree info calculatable _before_ recursing. */
216  if(bb != en_block)
217  {
218  my_i = dfs_order[index_map[bb]];
219  }
220  else
221  {
222  // In this way dfs_parent of entry is itself
223  my_i = dfs_order[last_basic_block];
224  }
225  // Computed a new dfs index for this Vertex
226  child_i = dfs_order[index_map[bn]] = dfsnum++;
227  dfs_to_bb[child_i] = bn;
228  dfs_parent[child_i] = my_i;
229  // recursive call
230  calc_dfs_tree_rec(bn);
231  }
233  "<--Computed dfs tree starting from v_" + std::to_string(index_map[bb]));
234  }
242  void compress(TBB v)
243  {
244  /* Btw. It's not worth to unrecurse compress() as the depth is usually not
245  greater than 5 even for huge graphs (I've not seen call depth > 4).
246  Also performance wise compress() ranges _far_ behind eval(). */
247  TBB parent = set_chain[v];
248  if(set_chain[parent])
249  {
250  compress(parent);
251  if(key[path_min[parent]] < key[path_min[v]])
252  {
253  path_min[v] = path_min[parent];
254  }
255  set_chain[v] = set_chain[parent];
256  }
257  }
258 
266  {
267  /* The representant of the set V is in, also called root (as the set
268  representation is a tree). */
269  TBB rep = set_chain[v];
270  /* V itself is the root. */
271  if(!rep)
272  {
273  return path_min[v];
274  }
275 
276  /* Compress only if necessary. */
277  if(set_chain[rep])
278  {
279  compress(v);
280  rep = set_chain[v];
281  }
282 
283  if(key[path_min[rep]] >= key[path_min[v]])
284  {
285  return path_min[v];
286  }
287  else
288  {
289  return path_min[rep];
290  }
291  }
292 
299  void link_roots(TBB v, TBB w)
300  {
301  TBB s = w;
302  /* Rebalance the tree. */
303  while(key[path_min[w]] < key[path_min[set_child[s]]])
304  {
305  if(set_size[s] + set_size[set_child[set_child[s]]] >= 2 * set_size[set_child[s]])
306  {
307  set_chain[set_child[s]] = s;
308  set_child[s] = set_child[set_child[s]];
309  }
310  else
311  {
312  set_size[set_child[s]] = set_size[s];
313  s = set_chain[s] = set_child[s];
314  }
315  }
316  path_min[s] = path_min[w];
317  set_size[v] += set_size[w];
318  if(set_size[v] < 2 * set_size[w])
319  {
320  TBB tmp = s;
321  s = set_child[v];
322  set_child[v] = tmp;
323  }
324  /* Merge all subtrees. */
325  while(s)
326  {
327  set_chain[s] = v;
328  s = set_child[s];
329  }
330  }
331 
332  public:
340  dom_info(const GraphObj& _g, const Vertex& _en_block, const Vertex& _ex_block, const ParameterConstRef param)
341  : dfs_parent(boost::num_vertices(_g) + 1, 0),
342  key(boost::num_vertices(_g) + 1, 0),
343  path_min(boost::num_vertices(_g) + 1, 0),
344  bucket(boost::num_vertices(_g) + 1, 0),
345  next_bucket(boost::num_vertices(_g) + 1, 0),
346  set_chain(boost::num_vertices(_g) + 1, 0),
347  set_size(boost::num_vertices(_g) + 1, 1),
348  set_child(boost::num_vertices(_g) + 1, 0),
349  dfsnum(1),
350  nodes(0),
351  last_basic_block(boost::num_vertices(_g)),
352  en_block(_en_block),
353  ex_block(_ex_block),
354  g(_g),
355  dom(boost::num_vertices(_g) + 1, 0),
356  dfs_order(boost::num_vertices(_g) + 1, 0),
357  dfs_to_bb(boost::num_vertices(_g) + 1, boost::graph_traits<GraphObj>::null_vertex()),
358  debug_level(param->get_class_debug_level(GET_CLASS(*this), DEBUG_LEVEL_NONE))
359  {
360  size_t index_counter = 0;
361  Vertex_iterator v, v_end;
362  for(boost::tie(v, v_end) = boost::vertices(g); v != v_end; v++, index_counter++)
363  {
364  index_map[*v] = index_counter;
365  }
366  for(unsigned int i = 0; i < boost::num_vertices(_g) + 1; i++)
367  {
368  path_min[i] = i;
369  key[i] = i;
370  }
371  }
372 
381  void calc_dfs_tree(bool reverse)
382  {
383  Vertex begin = en_block;
384  dfs_order[last_basic_block] = dfsnum;
385  dfs_to_bb[dfsnum] = begin;
386  dfsnum++;
387  calc_dfs_tree_rec(begin);
388  if(reverse)
389  {
390  /* In the post-dom case we may have nodes without a path to EXIT_BLOCK.
391  They are reverse-unreachable. In the dom-case we disallow such
392  nodes, but in post-dom we have to deal with them.
393 
394  There are two situations in which this occurs. First, noreturn
395  functions. Second, infinite loops. In the first case we need to
396  pretend that there is an edge to the exit block. In the second
397  case, we wind up with a forest. We need to process all noreturn
398  blocks before we know if we've got any infinite loops. */
399 
400  Vertex b;
401  bool saw_unconnected = false;
402 
403  Vertex_iterator vi, vi_end;
404  for(boost::tie(vi, vi_end) = boost::vertices(g); vi != vi_end; vi++)
405  {
406  b = *vi;
407  // skip entry
408  if(en_block == b)
409  {
410  continue;
411  }
412  if(boost::in_degree(b, g) > 0)
413  {
414  if(dfs_order[index_map[b]] == 0)
415  {
416  saw_unconnected = true;
417  }
418  continue;
419  }
420  fake_exit_edge.insert(index_map[b]);
421  dfs_order[index_map[b]] = dfsnum;
422  dfs_to_bb[dfsnum] = b;
423  dfs_parent[dfsnum] = dfs_order[last_basic_block];
424  dfsnum++;
426  }
427 
428  if(saw_unconnected)
429  {
430  for(boost::tie(vi, vi_end) = boost::vertices(g); vi != vi_end; vi++)
431  {
432  b = *vi;
433  // skip entry
434  if(en_block == b)
435  {
436  continue;
437  }
438  if(dfs_order[index_map[b]])
439  {
440  continue;
441  }
442  fake_exit_edge.insert(index_map[b]);
443  dfs_order[index_map[b]] = dfsnum;
444  dfs_to_bb[dfsnum] = b;
445  dfs_parent[dfsnum] = dfs_order[last_basic_block];
446  dfsnum++;
448  }
449  }
450  }
451 
452  nodes = dfsnum - 1;
453 
454  Vertex_iterator i, i_end;
455 #if HAVE_ASSERTS
456  unsigned int counter = 0;
457  for(boost::tie(i, i_end) = boost::vertices(g); i != i_end; i++)
458  {
459  ++counter;
460  }
461 #endif
462  /* This aborts e.g. when there is _no_ path from ENTRY to EXIT at all. */
463  THROW_ASSERT(nodes == counter, "there is _no_ path from ENTRY to EXIT at all. Number of vertices in the graph: " +
464  std::to_string(num_vertices(g)) + " Number of reachable from entry vertices " +
465  std::to_string(nodes));
466 #ifndef NDEBUG
467  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Vertices in dfs order");
468  for(size_t index = 0; index < dfs_to_bb.size(); index++)
469  {
471  "---" + std::to_string(index) + " v_" + std::to_string(index_map[dfs_to_bb[index]]));
472  }
473  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--");
474 #endif
475  }
476 
482  void calc_idoms(bool reverse)
483  {
484  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Computing immediate dominators");
485  TBB v, w;
486  typename boost::graph_traits<GraphObj>::in_edge_iterator ei, einext, ei_end, einext_end;
487 
488  /* Go backwards in DFS order, to first look at the leafs. */
489  v = nodes;
490  while(v > 1)
491  {
493  "-->Analyzing node in position " + std::to_string(v) + " v_" +
494  std::to_string(index_map[dfs_to_bb[v]]));
495  Vertex bb = dfs_to_bb[v];
496  edge e;
497  bool do_fake_exit_edge = false;
498 
499  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Parent is " + std::to_string(dfs_parent[v]));
500  TBB par = dfs_parent[v];
501  TBB k = v;
502 
503  boost::tie(ei, ei_end) = boost::in_edges(bb, g);
504 
505  if(reverse)
506  {
507  /* If this block has a fake edge to exit, process that first. */
508  if(fake_exit_edge.find(index_map[bb]) != fake_exit_edge.end())
509  {
510  einext = ei;
511  do_fake_exit_edge = true;
512  }
513  }
514 
515  /* Search all direct predecessors for the smallest node with a path
516  to them. That way we have the smallest node with also a path to
517  us only over nodes behind us. In effect we search for our
518  semidominator. */
519  while(do_fake_exit_edge || ei != ei_end)
520  {
521  TBB k1;
522  Vertex b;
523  if(do_fake_exit_edge)
524  {
525  k1 = dfs_order[last_basic_block];
526  do_fake_exit_edge = false;
527  }
528  else
529  {
530  e = *ei;
531  b = boost::source(e, g);
532  einext = ei;
533  einext++;
534 
535  if(b == en_block)
536  {
537  k1 = dfs_order[last_basic_block];
538  }
539  else
540  {
541  k1 = dfs_order[index_map[b]];
542  }
543  }
545  "---Predecessor is " + std::to_string(k1) + " v_" + std::to_string(index_map[b]));
546  /* Call eval() only if really needed. If k1 is above V in DFS tree,
547  then we know, that eval(k1) == k1 and key[k1] == k1. */
548  // k1 is the dfs index of the predecessor, v is the dfs of this Vertex
549  if(k1 > v)
550  {
551  k1 = key[eval(k1)];
552  }
553  if(k1 < k)
554  {
555  k = k1;
556  }
557 
558  ei = einext;
559  }
560 
561  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Key is " + std::to_string(k));
562 
563  // k becomes the key for v, so we have to add v to the bucket of k. It becomes the first element because we are
564  // reverse counting v
565  key[v] = k;
566  link_roots(par, v);
567  next_bucket[v] = bucket[k];
568  bucket[k] = v;
569 
570  /* Transform semidominators into dominators. */
571  for(w = bucket[par]; w; w = next_bucket[w])
572  {
573  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---w is " + std::to_string(w));
574  k = eval(w);
575  if(key[k] < key[w])
576  {
577  dom[w] = k;
578  }
579  else
580  {
581  dom[w] = par;
582  }
583  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---dom[w] is " + std::to_string(dom[w]));
584  }
585  /* We don't need to cleanup next_bucket[]. */
586  bucket[par] = 0;
587  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Analyzed node in position " + std::to_string(v));
588  v--;
589  }
590 
591  /* Explicitly define the dominators. */
592  for(v = 1; v <= nodes; v++)
593  {
594  if(dom[v] != key[v])
595  {
596  dom[v] = dom[dom[v]];
597  }
598  }
599  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Computed immediate dominators");
600  }
601 
607  {
608  Vertex_iterator vi, vi_end;
609  dom_map[en_block] = en_block;
610  for(boost::tie(vi, vi_end) = boost::vertices(g); vi != vi_end; vi++)
611  {
612  TBB d = dom[dfs_order[index_map[*vi]]];
613  if(dfs_to_bb[d] != boost::graph_traits<GraphObj>::null_vertex())
614  {
616  "---dom is " + std::to_string(index_map[dfs_to_bb[d]]));
617  dom_map[*vi] = dfs_to_bb[d];
618  }
619  }
620  }
621 };
622 
626 template <typename GraphObj>
628 {
629  public:
634  {
637  CDI_NONE
638  };
641  {
644  DOM_OK
645  };
646 
647  private:
652  friend class loop_regions_computation;
653  friend class add_loop_nop;
655 
657  using Vertex = typename boost::graph_traits<const GraphObj>::vertex_descriptor;
658 
660  using Vertex_iterator = typename boost::graph_traits<const GraphObj>::vertex_iterator;
661 
665  enum cdi_direction dom_dir;
666 
668  enum dom_state dom_computed;
669 
671  const GraphObj& g;
672 
677 
680 
683 
686 
687  public:
691  dominance(const dominance<GraphObj>&) = delete;
692 
696  dominance<GraphObj> operator=(const dominance<GraphObj>&) = delete;
702  {
703  if(dom_computed == DOM_OK)
704  {
705  return;
706  }
707  if(dom_computed == DOM_NONE)
708  {
709  bool reverse = (dir == CDI_POST_DOMINATORS) ? true : false;
710  if(reverse)
711  {
712  boost::reverse_graph<GraphObj, GraphObj> Rcfg(g);
714  dom_info<boost::reverse_graph<GraphObj, GraphObj>> di(Rcfg, ex_block, en_block, param);
715  di.calc_dfs_tree(reverse);
716  di.calc_idoms(reverse);
717  di.fill_dom_map(dom);
718  }
719  else
720  {
722  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Computing dominators");
723  dom_info<GraphObj> di(g, en_block, ex_block, param);
724  di.calc_dfs_tree(reverse);
725  di.calc_idoms(reverse);
726  di.fill_dom_map(dom);
727  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Computed dominators");
728  }
729  dom_computed = DOM_NO_FAST_QUERY;
730  }
732  // compute_dom_fast_query (dir);
733  }
741  dominance(const GraphObj& _g, const Vertex _en_block, const Vertex _ex_block, const ParameterConstRef _param)
742  : dom_dir(CDI_NONE),
743  dom_computed(DOM_NONE),
744  g(_g),
745  en_block(_en_block),
746  ex_block(_ex_block),
747  param(_param),
748  debug_level(_param->get_class_debug_level(GET_CLASS(*this), DEBUG_LEVEL_NONE))
749  {
750  THROW_ASSERT(_en_block != _ex_block, "incorrect entry and exit basic blocks");
751  }
758  {
759  return dom.find(v)->second;
760  }
761 
768  {
770  // These are the immediate dominated nodes
771  auto dom_it_end = dom.end();
772  for(auto dom_it = dom.begin(); dom_it != dom_it_end; ++dom_it)
773  {
774  dominated[dom_it->second].insert(dom_it->first);
775  dominated[dom_it->first].insert(dom_it->first);
776  }
777 
778  // Now I have to consider also the non immediate dominators
779  bool changed = false;
780  do
781  {
782  changed = false;
783  // for(domBeg = this->dom.begin(), domEnd = this->dom.end(); domBeg != domEnd; domBeg++)
784  for(auto dom_it = dom.begin(); dom_it != dom_it_end; ++dom_it)
785  {
786  using mSetIter = typename CustomUnorderedMapStable<Vertex, CustomOrderedSet<Vertex>>::iterator;
787  mSetIter mSetBeg, mSetEnd;
788  for(mSetBeg = dominated.begin(), mSetEnd = dominated.end(); mSetBeg != mSetEnd; ++mSetBeg)
789  {
790  if((mSetBeg->second).find(dom_it->second) != (mSetBeg->second).end() &&
791  (mSetBeg->second).find(dom_it->first) == (mSetBeg->second).end())
792  {
793  dominated[mSetBeg->first].insert(dom_it->first);
794  changed = true;
795  }
796  }
797  }
798  } while(changed);
799 
800  return dominated;
801  }
802 
807  {
808  return dom;
809  }
810 };
811 #endif
typename boost::graph_traits< const GraphObj >::in_edge_iterator in_edge_iterator
edge_iterator definition.
Definition: Dominance.hpp:99
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
Vertex get_immediate_dominator(Vertex v) const
Return the immediate dominator of a Vertex.
Definition: Dominance.hpp:757
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
TBB eval(TBB v)
Compress the path from V to the set root of V if needed (when the root has changed since the last cal...
Definition: Dominance.hpp:265
TVMValue param[3]
Dominator o post-dominator data structure.
Definition: Dominance.hpp:627
File containing functions and utilities to support the printing of debug messagges.
std::vector< Vertex > dfs_to_bb
If x is the DFS-index of a node which corresponds with a basic block, dfs_to_bb[x] is that basic bloc...
Definition: Dominance.hpp:181
This algorithm is to find coloring of a graph Algorithm: Let G = (V,E) be a graph with vertices v_1...
string target
Definition: lenet_tvm.py:16
#define GET_CLASS(obj)
Macro returning the actual type of an object.
const CustomUnorderedMapStable< Vertex, Vertex > & get_dominator_map() const
Return the dominators tree as a map between Vertex and its immediate dominator.
Definition: Dominance.hpp:806
typename boost::graph_traits< const GraphObj >::vertex_iterator Vertex_iterator
Vertex iterator definition.
Definition: Dominance.hpp:105
unsigned int nodes
The number of nodes in the DFS tree (==dfsnum-1).
Definition: Dominance.hpp:146
const CustomUnorderedMapStable< Vertex, CustomOrderedSet< Vertex > > getAllDominated() const
Returns a map containing, for each Vertex, a set formed by all the vertices dominated by it (all the ...
Definition: Dominance.hpp:767
exceptions managed by PandA
std::map< Vertex, size_t > index_map
index map putting into relation vertices and arbitrary indexes.
Definition: Dominance.hpp:184
dom_info(const GraphObj &_g, const Vertex &_en_block, const Vertex &_ex_block, const ParameterConstRef param)
Constructor.
Definition: Dominance.hpp:340
Not computed at all.
Definition: Dominance.hpp:642
void calc_dfs_tree_rec(Vertex bb)
The recursive variant of creating a DFS tree.
Definition: Dominance.hpp:195
void calc_idoms(bool reverse)
This calculates the immediate dominators (or post-dominators if REVERSE is true). ...
Definition: Dominance.hpp:482
std::vector< unsigned int > set_size
set_size[x] is the number of elements in the set named by x.
Definition: Dominance.hpp:135
std::vector< TBB > path_min
The value in path_min[x] is the node y on the path from x to the root of the tree x is in with the sm...
Definition: Dominance.hpp:119
const GraphObj & g
Flow graph reference.
Definition: Dominance.hpp:164
void link_roots(TBB v, TBB w)
This essentially merges the two sets of V and W, giving a single set with the new root V...
Definition: Dominance.hpp:299
std::vector< TBB > set_child
set_child[x] is used for balancing the tree representing a set.
Definition: Dominance.hpp:140
dom_state
type of information stored in dom_info data structure
Definition: Dominance.hpp:640
redefinition of map to manage ordered/unordered structures
typename boost::graph_traits< const GraphObj >::edge_descriptor edge
edge definition.
Definition: Dominance.hpp:103
const Vertex en_block
Start block (ENTRY_BLOCK_PTR for forward problem, EXIT_BLOCK for backward problem).
Definition: Dominance.hpp:674
Auxiliary methods for manipulating string.
std::vector< TBB > dom
After the algorithm is done, dom[x] contains the immediate dominator of x.
Definition: Dominance.hpp:167
cdi_direction
type of computation.
Definition: Dominance.hpp:633
CustomUnorderedMapStable< Vertex, Vertex > dom
After the algorithm is done, dom[x] contains the immediate dominator of x.
Definition: Dominance.hpp:679
unsigned long TBB
Parameter include.
Definition: Dominance.hpp:83
static const uint32_t k[]
Definition: sha-256.c:22
#define index(x, y)
Definition: Keccak.c:74
redefinition of set to manage ordered/unordered structures
typename boost::graph_traits< const GraphObj >::vertex_descriptor Vertex
The algorithm uses two different indices for each Vertex: a generic index given by boost and the inde...
Definition: Dominance.hpp:97
const GraphObj & g
Flow graph reference.
Definition: Dominance.hpp:671
void calculate_dominance_info(enum dominance::cdi_direction dir)
The main entry point into this module.
Definition: Dominance.hpp:701
#define DEBUG_LEVEL_NONE
no debugging print is performed.
int debug_level
Debug level.
Definition: Dominance.hpp:685
Store the intermediate information used to compute dominator or post dominator information.
Definition: Dominance.hpp:91
const ParameterConstRef param
The set of input parameters.
Definition: Dominance.hpp:682
void calc_dfs_tree(bool reverse)
The main entry for calculating the DFS tree or forest.
Definition: Dominance.hpp:381
std::vector< TBB > dfs_parent
The parent of a node in the DFS tree.
Definition: Dominance.hpp:108
unsigned int dfsnum
This is the next free DFS number when creating the DFS tree.
Definition: Dominance.hpp:143
int debug_level
debug_level
Definition: Dominance.hpp:187
CustomOrderedSet< TBB > fake_exit_edge
Blocks with bits set here have a fake edge to EXIT.
Definition: Dominance.hpp:152
const Vertex & en_block
Start block (ENTRY_BLOCK_PTR for forward problem, EXIT_BLOCK for backward problem).
Definition: Dominance.hpp:158
std::vector< TBB > set_chain
set_chain[x] is the next node on the path from x to the representant of the set containing x...
Definition: Dominance.hpp:132
const Vertex ex_block
Ending block.
Definition: Dominance.hpp:676
std::vector< TBB > bucket
bucket[x] points to the first node of the set of nodes having x as key.
Definition: Dominance.hpp:122
void fill_dom_map(CustomUnorderedMapStable< Vertex, Vertex > &dom_map)
fill the dominator map after its computation
Definition: Dominance.hpp:606
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
std::vector< TBB > next_bucket
And next_bucket[x] points to the next node.
Definition: Dominance.hpp:125
dominance(const GraphObj &_g, const Vertex _en_block, const Vertex _ex_block, const ParameterConstRef _param)
Constructor for the dominance class.
Definition: Dominance.hpp:741
this class is used to manage the command-line or XML options.
const Vertex & ex_block
Ending block.
Definition: Dominance.hpp:161
typename boost::graph_traits< const BBGraph >::vertex_iterator Vertex_iterator
Vertex_iterator definition.
Definition: Dominance.hpp:660
The data is OK, but the fast query data are not usable.
Definition: Dominance.hpp:643
unsigned counter[N_THREADS]
Definition: data.c:3
std::vector< TBB > dfs_order
If b is the number of a basic block (index_map[bb_Vertex]), dfs_order[b] is the number of that node i...
Definition: Dominance.hpp:174
absl::node_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMapStable
Definition: custom_map.hpp:152
const unsigned long int last_basic_block
index of the last basic block
Definition: Dominance.hpp:155
std::vector< TBB > key
For a node x key[x] is roughly the node nearest to the root from which exists a way to x only over no...
Definition: Dominance.hpp:115
typename boost::graph_traits< const GraphObj >::out_edge_iterator out_edge_iterator
edge_iterator definition.
Definition: Dominance.hpp:101
void compress(TBB v)
Compress the path from V to the root of its set and update path_min at the same time.
Definition: Dominance.hpp:242
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Definition: exceptions.hpp:289

Generated on Mon Feb 12 2024 13:02:50 for PandA-2024.02 by doxygen 1.8.13