[interp] Propagate locals and kill dead ones afterwards (mono/mono#16791)
* [interp] Add flag for locals that have their address taken
The previous handling of LDLOCA was broken because if the address was taken before the instructions that would be optimized we would miss any potential changes to the local value. Right now we just skip optimizing locals that have their address taken. This is achieved simply by not pushing LDLOC on the evaluation stack, for those locals.
* [interp] Add separate counters for optimized instructions
To provide more insight.
* [interp] Propagate locals
Whenever we generate a movloc we remember what local was copied. When loading a local we check if it's currently storing the value of another local, in which case we load the original local instead.
* [interp] Kill instructions that write to dead locals
We track the liveness of a local by counting how many times the local is loaded using ldloc. When such instructions are optimized, the ldloc counter is updated accordingly.
* [interp] Don't optimize code if under debugger
Commit migrated from https://github.com/mono/mono/commit/
6908a1941b7278fe6711c75976f2434db55136f0