The concept of value
A value is an entity that bears a certain meaning at a given time. While this definition may be hard to grasp, you are likely already familiar with this concept with your background in computer science.
For instance, consider the following snippet:
a = b + c;
a = a + d;
The first statement assigns a value to a
(b + c
), and the next statement assigns a different value to a
(a
's previous value + d
).
This example highlights that values and variables are two different concepts.
The concept of value is interesting because if you can pin the value of a variable, it opens the door to many optimizations/analyses.
Consider the following example:
void foo(int a, int b) {
int var = a + b;
if (var == 0xFF) {
bar(var);
var = baz();
}
bar(var);
}
In this snippet, it is trivial to see that in the call to bar
in the first if
statement, it is possible to replace var
with the 0xFF
constant.
In general, this is not that...