Hi all, I've just joined the group as I've trying out mono-Cecil for a few weeks now. I have to say I'm finding it a very useful tool and easy to use.
I'm currently using it to add instrumentation code to my XNA project and trying to do some code optimisations as running XNA on a XBOX 360 is slow. I haven't as yet got anything up and running on the 360 but the PC version seems OK. However I'm a little stuck at the moment. I've done some basic analysis on the code, creating Basic Blocks and doing some liveness variable analysis. This has allowed me to remove redundant variables etc. Also I've done some simple code elimination by looking for load instructions followed by store instruction which operate on the same variable as this is a bit pointless. However these are some more complex situations which I would like to fix. My question is 'Does Mono-Cecil have any way of linking instructions that pop data to the instruction(s) that pushed it?'. I found in the Cecil code some stack code which is used to calculate the maximum size of the stack. I noticed that the Cecil stack code resets the stack size to 0 after a branch instruction. Is this actually what happens or is that only relevant as far as calculating the maxstack size? I would like to be able to take an instruction that pops something and maps it back to the instruction has pushed the item onto the stack. I'm having trouble sorting this out when branches are involved. Does anyone know what sort of algorithm is used to find matching push and pop instructions. I assume that an instruction that pops something off the stack can have many instructions that could have pushed it when a loop is involved. My vocabulary doesn't stretch to this kind of algorithm so I'm not sure what to look for. I've tried out 'Static code path analysis' but not sure if this is what I need. So far I have a stack of instructions and I was through each instruction. If it pops something I pop the instruction from the top of the stack. If it pushes something onto the stack I push the instruction. This way when an instruction pops something I get the instruction that pushed the data but as I say this gets complicated when branches occur. Any advice would be appreciated. Cheers Mort -- -- mono-cecil
