Use-define chain

Within computer science, a use-definition chain (or UD chain) is a data structure that consists of a use U, of a variable, and all the definitions D of that variable that can reach that use without any other intervening definitions.

[1][2] A UD Chain generally means the assignment of some value to a variable.

[3] Both UD and DU chains are created by using a form of static code analysis known as data flow analysis.

Knowing the use-def and def-use chains for a program or subprogram is a prerequisite for many compiler optimizations, including constant propagation and common subexpression elimination.

Making the use-define or define-use chains is a step in liveness analysis, so that logical representations of all the variables can be identified and tracked through the code.

Consider the following snippet of code: Notice that x is assigned a value at three points (marked A, B, and C).

Contrariwise, at the point marked "2", the use-def chain for x indicates that its current value must have come from line C. Since the value of the x in block 2 does not depend on any definitions in block 1 or earlier, x might as well be a different variable there; practically speaking, it is a different variable — call it x2.

⁠, and what can now be observed as the computation at statement, j: This example is based on a Java algorithm for finding the gcd.

To find out all def-use-chains for variable d, do the following steps: Repeat these steps in the following style: combine each write access with each read access (but NOT the other way round).

The result should be: You have to take care, if the variable is changed by the time.

The variable d1 would be replaced by b With this algorithm, two things are accomplished: