From 07e249364568a9bfbe529aedb3363e0aefa7018f Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 10 Jul 2016 15:44:15 +0200 Subject: [PATCH] Keep copy propagation enabled --- ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs | 2 +- ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index a36e2a3a9..87d273b5e 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -60,7 +60,7 @@ namespace ICSharpCode.Decompiler.CSharp new ConditionDetection(), new ILInlining(), new TransformInlineAssignment(), -// new CopyPropagation(), + new CopyPropagation(), new InlineCompilerGeneratedVariables(), new ExpressionTransforms(), // must run once before "the loop" to allow RemoveDeadVariablesInit new RemoveDeadVariableInit(), // must run after ExpressionTransforms because it does not handle stobj(ldloca V, ...) diff --git a/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs b/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs index 3e1a66b58..80c1d67d1 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs @@ -78,6 +78,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms case OpCode.LdsFlda: // All address-loading instructions always return the same value for a given operand/argument combination, // so they can be safely copied. + // ... except for LdElema and LdFlda, because those might throw an exception, and we don't want to + // change the place where the exception is thrown. return true; case OpCode.LdLoc: var v = ((LdLoc)value).Variable;