Add code to remove dup + pop

This commit is contained in:
de4dot 2011-10-20 12:29:19 +02:00
parent d76afbf8a1
commit 58af131485

View File

@ -53,6 +53,16 @@ namespace de4dot.blocks.cflow {
allDeadInstructions.Add(i); allDeadInstructions.Add(i);
break; break;
case Code.Dup:
if (i + 1 >= instructions.Count)
break;
if (instructions[i + 1].OpCode.Code != Code.Pop)
break;
allDeadInstructions.Add(i);
allDeadInstructions.Add(i + 1);
i++;
break;
case Code.Leave: case Code.Leave:
case Code.Leave_S: case Code.Leave_S:
case Code.Endfinally: case Code.Endfinally:
@ -69,9 +79,11 @@ namespace de4dot.blocks.cflow {
break; break;
} }
} }
if (allDeadInstructions.Count == 0)
return false;
block.remove(allDeadInstructions); block.remove(allDeadInstructions);
return allDeadInstructions.Count > 0; return true;
} }
bool okInstructions(Block block, IEnumerable<int> indexes) { bool okInstructions(Block block, IEnumerable<int> indexes) {