# What is live variable analysis (compilers)?

Data-flow analysis to understand which variables are live. This means they hold a value which may be needed e.g. reading the old value before writing a new value.

b = 3
>>>>>>>> Here the set of live variables is {b}
c = 5
>>>>>>>> Here the set of live variables is {b, c}
a = f(b * c)
>>>>>>>> a may be eliminated if it is not used later on.

It is done backwards via data dependency checks.

Formally the live variables can be represented as a set:

GEN[s] := Set of variables which are used by s before any assignment.
KILL[s] := Set of variables which are bound in declarations.