SlideServe
Menu
Préférences
© SlideServe · v2026

Dominators and CFGs

thi avatar
10 diapositives · 315 Views · Aug 21, 2014

Dominators and CFGs. Taken largely from University of Delaware Compiler Notes. Dominators. Node (basic block) D in a CFG dominates node N if every path from the start node to N goes through D. We say that node D is a dominator of node N.

Dominators and CFGs - slide 1
01 / 10Dominators and CFGs
1 / 17

Télécharger la présentation

Dominators and CFGs
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Dominators and CFGs Taken largely from University of Delaware Compiler Notes

  2. Dominators Node (basic block) D in a CFG dominatesnode N if every path from the start node to N goes through D. We say that node D is a dominator of node N. Define dom(N) = set of node N’s dominators, or the dominator set for node N. Note: by definition, each node dominates itself i.e., N  dom(N).

  3. An Example Domination relation: { (1, 1), (1, 2), (1, 3), (1, 4) … (2, 3), (2, 4), … (2, 10) } S 1 2 3 Direct domination: 4 1 <d 2, 2 <d 3, … 5 6 7 DOM: 8 DOM(1) = {1} DOM(2) = {1, 2} DOM(3) = {1, 2, 3} DOM(10) = {1, 2, 10) 9 10

  4. Node M is the immediate dominator of node N ==> Node M must be the last dominator of N on any path from the start node to N. Therefore, every node other than the start node must have a unique immediate dominator (the start node has no immediate dominator.) Immediate Dominators and Dominator Tree What does this mean ?

  5. S 1 2 1 3 2 4 10 3 5 4 6 7 5 9 8 7 8 6 9 10 Dominator Tree A flowgraph (left) and its dominator tree (right)

  6. Question Assume an immediate dominator n’ of a node n, is n’ necessarily an immediate predecessor in the flow graph? Answer: NO! Example: consider nodes 5 and 8.

  7. An Example (Dominators) 1 2 3 4 6 5 7 8 9 10

  8. Depth-First Search (DFS) • An “ordering” of nodes of CFG • BBs dfs_nums 1..N • Each BB dfs_num represents when that BB first encountered in DFS • Write dfs(BB root);

  9. DFS and Depth-First Order • CONFUSING: They are NOT the same • DFS as defined: order of first visitation during depth-first search • Depth-First Order • “The depth-first ordering of the nodes is the reverse of the order in which we last visit the nodes in a preorder traversal” (Aho-Sethi-Ullman) • Used (sometimes) to identify loops • Later …

  10. An Example DFS 1 2 3 4 6 5 7 8 9 10