diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs b/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs index 5b5e3f5e9..d17151b01 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs @@ -47,7 +47,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow ILVariable v; ILInstruction inst; if (ret.ReturnValue != null && ret.ReturnValue.MatchLdLoc(out v) - && v.IsSingleUse && block.Instructions[0].MatchStLoc(v, out inst)) + && v.IsSingleDefinition && v.LoadCount == 1 && block.Instructions[0].MatchStLoc(v, out inst)) { inst.AddILRange(ret.ReturnValue.ILRange); inst.AddILRange(block.Instructions[0].ILRange); diff --git a/ICSharpCode.Decompiler/IL/ILVariable.cs b/ICSharpCode.Decompiler/IL/ILVariable.cs index 129c55ea2..c65f9427b 100644 --- a/ICSharpCode.Decompiler/IL/ILVariable.cs +++ b/ICSharpCode.Decompiler/IL/ILVariable.cs @@ -84,9 +84,9 @@ namespace ICSharpCode.Decompiler.IL /// public int AddressCount; - public bool IsSingleUse { + public bool IsSingleDefinition { get { - return LoadCount == 1 && StoreCount == 1 && AddressCount == 0; + return StoreCount == 1 && AddressCount == 0; } } diff --git a/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs b/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs index 087fcd4b1..6d93a4e07 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs @@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.IL ILVariable v; ILInstruction copiedExpr; if (block.Instructions[i].MatchStLoc(out v, out copiedExpr)) { - if (v.StoreCount == 1 && v.AddressCount == 0 && v.Kind != VariableKind.Parameter && CanPerformCopyPropagation(v, copiedExpr)) { + if (v.IsSingleDefinition && v.Kind != VariableKind.Parameter && CanPerformCopyPropagation(v, copiedExpr)) { // un-inline the arguments of the ldArg instruction ILVariable[] uninlinedArgs = new ILVariable[copiedExpr.Children.Count]; for (int j = 0; j < uninlinedArgs.Length; j++) { @@ -85,11 +85,11 @@ namespace ICSharpCode.Decompiler.IL case VariableKind.Parameter: // Parameters can be copied only if they aren't assigned to (directly or indirectly via ldarga) // note: the initialization by the caller is the first store -> StoreCount must be 1 - return v.StoreCount == 1 && v.AddressCount == 0; + return v.IsSingleDefinition; case VariableKind.StackSlot: // Variables are be copied only if both they and the target copy variable are generated, // and if the variable has only a single assignment - return v.StoreCount == 1 && v.AddressCount == 0 && v.Kind == VariableKind.StackSlot && target.Kind == VariableKind.StackSlot; + return v.IsSingleDefinition && v.Kind == VariableKind.StackSlot && target.Kind == VariableKind.StackSlot; default: return false; }