I frequently disassemble my rewritten assemblies (using ildasm) to compare the IL against the previous version as I work on my rewriter. I've noticed that the order of local variables is not deterministic, so if I rewrite the same input assembly more than
once, and disassemble each output, sometimes some of the locals are declared in a different order. This creates diffs throughout the affected functions.
Also, I noticed that sometimes conditional branches followed by an unconditional branch are inverted (into a single conditional branch), but sometimes not. Again, this is when executing the rewriter with the same inputs a second time.
Finally, sometimes the .maxstack declaration on a function can change from one run to another, with no other changes in the IL of the affected function.
Do you have any suggestions as to what might be causing this non-determinism? I suspect I can sort something to fix the order of the locals, but I don't have a clue where to start looking for the others.
It's not really a bug - just something I'd like to change to make debugging easier on myself.