Browse Source

Perform even less aggressive inlining of return blocks.

pull/832/head
Daniel Grunwald 8 years ago
parent
commit
3e8ab77d52
  1. 3
      ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs
  2. 11
      ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs

3
ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs

@ -134,8 +134,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -134,8 +134,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
var targetBlock = branch.TargetBlock;
if (targetBlock.Instructions.Count != 1 || targetBlock.FinalInstruction.OpCode != OpCode.Nop)
return false;
if (targetBlock.Parent == branch.Parent.Parent) {
// branch.Parent.Parent = container containing the branch
if (targetBlock.Parent == branch.Ancestors.OfType<BlockContainer>().FirstOrDefault()) {
// only simplify when jumping out of a try-finally
return false;
}

11
ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs

@ -415,6 +415,17 @@ namespace ICSharpCode.Decompiler.IL @@ -415,6 +415,17 @@ namespace ICSharpCode.Decompiler.IL
}
}
/// <summary>
/// Gets the ancestors of this node (including the node itself as first element).
/// </summary>
public IEnumerable<ILInstruction> Ancestors {
get {
for (ILInstruction node = this; node != null; node = node.Parent) {
yield return node;
}
}
}
/// <summary>
/// Number of parents that refer to this instruction and are connected to the root.
/// Usually is 0 for unconnected nodes and 1 for connected nodes, but may temporarily increase to 2

Loading…
Cancel
Save