Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-safar committed May 19, 2022
1 parent 6021e00 commit 138ec39
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/linker/Linker.Steps/UnreachableBlocksOptimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,16 @@ static bool IsComparisonAlwaysTrue (OpCode opCode, int left, int right)
return null;

var analyzer = new ConstantExpressionMethodAnalyzer (this);
if (analyzer.Analyze (callee, callStack)) {
return new MethodResult (analyzer.Result, analyzer.SideEffectFreeResult && !HasSideEffects (method));
}
if (analyzer.Analyze (callee, callStack))
return new MethodResult (analyzer.Result, analyzer.SideEffectFreeResult);

return null;

static bool HasSideEffects (MethodDefinition method)
{
return !method.DeclaringType.IsBeforeFieldInit;
}
}

static bool HasSideEffects (MethodDefinition method)
{
return !method.DeclaringType.IsBeforeFieldInit;
}

//
// Return expression with a value when method implementation can be
Expand Down Expand Up @@ -1399,6 +1397,8 @@ public bool Analyze (in CalleePayload callee, Stack<MethodDefinition> callStack)
Instruction? linstr;
object? left, right, operand;

SideEffectFreeResult = !HasSideEffects (method);

//
// We could implement a full-blown interpreter here but for now, it handles
// cases used in runtime libraries
Expand Down

0 comments on commit 138ec39

Please sign in to comment.