Skip to content

Commit

Permalink
Improve control flow decompilation with some compilers
Browse files Browse the repository at this point in the history
Add a ControlFlowSimplification step after SplitVariables
Enable dead code removal in some unit tests
  • Loading branch information
Chicken-Bones committed Jun 12, 2018
1 parent 3fb7c71 commit 9937302
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public void ShortCircuit([ValueSource("defaultOptions")] CSharpCompilerOptions c
public void ExceptionHandling([ValueSource("defaultOptions")] CSharpCompilerOptions cscOptions)
{
RunForLibrary(cscOptions: cscOptions, decompilerSettings: new DecompilerSettings {
NullPropagation = false
NullPropagation = false,
RemoveDeadCode = !cscOptions.HasFlag(CSharpCompilerOptions.UseRoslyn)
});
}

Expand Down Expand Up @@ -161,7 +162,9 @@ public void Generics([ValueSource("defaultOptions")] CSharpCompilerOptions cscOp
[Test]
public void Loops([ValueSource("defaultOptionsWithMcs")] CSharpCompilerOptions cscOptions)
{
RunForLibrary(cscOptions: cscOptions);
RunForLibrary(cscOptions: cscOptions, decompilerSettings: new DecompilerSettings {
RemoveDeadCode = !cscOptions.HasFlag(CSharpCompilerOptions.Optimize)
});
}

[Test]
Expand Down
1 change: 1 addition & 0 deletions ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public static List<IILTransform> GetILTransforms()
// is already collapsed into stloc(V, ...).
new RemoveDeadVariableInit(),
new SplitVariables(), // split variables once again, because the stobj(ldloca V, ...) may open up new replacements
new ControlFlowSimplification(), //split variables may enable new branch to leave inlining
new DynamicCallSiteTransform(),
new SwitchDetection(),
new SwitchOnStringTransform(),
Expand Down

0 comments on commit 9937302

Please sign in to comment.