A IR property that requires:
- Each variable/register be alloted a value only once
- Every variable/register is defined before its use
Implications
No Recursive Definitions - Use Versioning Instead
You cannot mutate a variable in terms of itself.
%i = add i32 %i, 1
is an illegal operation. it is a recursive definition
Instead, SSA requires you to do something like this pseudocode:
%i.version2 = add i32 %i.version1, 1
Clang’s Solution to this Problem (clang -O2
)
All variables are turned to LLVM alloca. They are stored on the stack where they can be freely manipulated with:
- LLVM load
- LLVM store Example of initializaing:
Example of reading and modifying: