Browse Source

replace IsSingleUse with IsSingleDefinition

pull/728/head
Siegfried Pammer 9 years ago
parent
commit
f781c0335a
  1. 2
      ICSharpCode.Decompiler/IL/ControlFlow/ControlFlowSimplification.cs
  2. 4
      ICSharpCode.Decompiler/IL/ILVariable.cs
  3. 6
      ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs

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

@ -47,7 +47,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -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);

4
ICSharpCode.Decompiler/IL/ILVariable.cs

@ -84,9 +84,9 @@ namespace ICSharpCode.Decompiler.IL @@ -84,9 +84,9 @@ namespace ICSharpCode.Decompiler.IL
/// </remarks>
public int AddressCount;
public bool IsSingleUse {
public bool IsSingleDefinition {
get {
return LoadCount == 1 && StoreCount == 1 && AddressCount == 0;
return StoreCount == 1 && AddressCount == 0;
}
}

6
ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.Decompiler.IL @@ -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 @@ -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;
}

Loading…
Cancel
Save