# Definition-use graph

Ir para: navegação, pesquisa

## Facts

• The definition-use graph is called of DUG. <bib>vincenzi-etal:slides:2007</bib>, <bib>vincenzi-maldonado:slides:2007</bib>
• The definition-use graph can be static or dynamically analyzed: statically to examine the diagram (formally through inspections or informally through look-sees); dynamically to construct and execute test cases. <bib>vincenzi-maldonado:slides:2007</bib>

## Procedures

• Definition-use graph construction <bib>mathur:2008, 458</bib>
1. Consider a control-flow graph G = (N, E) of a program P, where N is the set of nodes and E the set of edges. Each node in G corresponds to a code block in P: those blocks are denoted as [itex]b_{1}, b_{2}, ..., b_{k}[/itex], assuming that P contains k > 0 code blocks.
2. Let [itex]def_{i}[/itex] denote the set of variables defined in code block i.
3. Let [itex]c-use_{i}[/itex] denote the set of variables that have a computational use in code block i.
4. Let [itex]p-use_{i}[/itex] denote the set of variables that have a predicative use in code block i.
5. Compute [itex]def_{i}[/itex], [itex]c-use_{i}[/itex], and [itex]p-use_{i}[/itex] for each code block i in P.
6. Associate each node i in N with [itex]def_{i}[/itex], [itex]c-use_{i}[/itex], and [itex]p-use_{i}[/itex].
7. For each node i that as a nonempty predicative use sets and ends in condition C, associate edges (i, j) and (i, k) with C and !C, respectively, given that edge (i, j) is taken when the condition is true and (i, k) is taken when the condition is false.