Question

In compiler data flow analysis, what is the difference between a live range of a variable and it's reaching definition? Both seem to refer to the same thing...

Was it helpful?

Solution

They’re very different things, and I suggest that you go back and reread whichever definitions confused you. A reaching definition of a variable for a point which uses the given variable must be, among other things, a definition of that variable. The lifetime of a variable is the portion of the program in which it can be used, which includes things other than definitions, e.g., reading it.

See, for instance, the 1986 Dragon Book, pages 534 (perhaps too general to be helpful) and 610.

OTHER TIPS

Reaching definitions are defined with respect to a particular place in a program. For example, in line 10, with code "a = b + c" it is useful for the compiler to know what the reaching definition of "c" is, or in other words answer the question "in what statement did variable c acquire a value that can reach line 10?".

Live range is defined with respect to a variable. The live range of variable c starts from a definition of variable c and goes until the next definition of the variable (in which place the variable gets killed, or defined as a different variable, if you are using SSA), or the end of the scope (block, function or program) that variable c exists.

The two concepts are similar, but they are not the same thing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top