Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle IForToLoopOperation over numeric types in control flow graph #26734

Merged
merged 3 commits into from
May 10, 2018

Conversation

AlekseyTs
Copy link
Contributor

No description provided.

@AlekseyTs
Copy link
Contributor Author

AlekseyTs commented May 9, 2018

@333fred, @mavasani, @cston, @dotnet/roslyn-compiler, @dotnet/analyzer-ioperation Please review #Closed


namespace Microsoft.CodeAnalysis.Operations
{
internal class ForToLoopOperationUserDefinedInfo
Copy link
Member

@333fred 333fred May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this can't just be a struct? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this can't just be a struct?

It is not common to need this information. The intent is to save some memory for the common case.


In reply to: 187115823 [](ancestors = 187115823)

public ForToLoopStatement(ImmutableArray<ILocalSymbol> locals, ILabelSymbol continueLabel, ILabelSymbol exitLabel, IOperation loopControlVariable, IOperation initialValue, IOperation limitValue, IOperation stepValue, IOperation body, ImmutableArray<IOperation> nextVariables, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue, bool isImplicit) :
base(locals, continueLabel, exitLabel, semanticModel, syntax, type, constantValue, isImplicit)
public ForToLoopStatement(ImmutableArray<ILocalSymbol> locals, bool isChecked,
(ILocalSymbol LoopObject, ForToLoopOperationUserDefinedInfo UserDefinedInfo) info,
Copy link
Member

@333fred 333fred May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[](start = 116, length = 1)

Lots of trailing whitespace. #WontFix

}
}

public static int VBForToShiftBits(this SpecialType specialType)
Copy link
Member

@jaredpar jaredpar May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment on the intent of this method or update the name. Unsure exactly what this is for at a glance. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment on the intent of this method or update the name. Unsure exactly what this is for at a glance.

Will do


In reply to: 187118574 [](ancestors = 187118574)

@@ -2364,11 +2364,21 @@ internal sealed partial class LazyForLoopStatement : BaseForLoopStatement, IForL
/// </summary>
internal abstract partial class BaseForToLoopStatement : LoopStatement, IForToLoopOperation
Copy link
Member

@jaredpar jaredpar May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BaseForToLoopStatement [](start = 36, length = 22)

Which change is causing this generated file to get updated? Was expecting to see a change to on of our XML files or generators but not seeing that. #Resolved

Copy link
Contributor

@mavasani mavasani May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaredpar We have still not hooked up the generator to this file: #20204. We should probably rename this file to remove the .generated.cs suffix until that is implemented. #Resolved

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. Thanks for the explanation.

As for renaming. I'm ambivalent. I don't want to create unnecessary work here if there is an issue tracking it.


In reply to: 187120137 [](ancestors = 187120137)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning on addressing the issue during the hackathon.


In reply to: 187121166 [](ancestors = 187121166,187120137)

_ = userDefinedInfo.Subtraction.Value;
_ = userDefinedInfo.LessThanOrEqual.Value;
_ = userDefinedInfo.GreaterThanOrEqual.Value;
}
Copy link
Member

@jaredpar jaredpar May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a method to ForToLoopOperationUserDefinedInfo to force the evaluation of the lazies instances rather than enumerating the fields here. This would be more robust in the face of adding additional fields in the future. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a method to ForToLoopOperationUserDefinedInfo to force the evaluation of the lazies instances rather than enumerating the fields here. This would be more robust in the face of adding additional fields in the future.

I do not expect us to add anything else to that class in the future. I also think this method would look strange in the class because it is only useful as a test.


In reply to: 187120366 [](ancestors = 187120366)


Visit(operation.LoopControlVariable, "LoopControlVariable");
Visit(operation.InitialValue, "InitialValue");
Visit(operation.LimitValue, "LimitValue");
Visit(operation.StepValue, "StepValue");
Visit(operation.Body, "Body");
VisitArray(operation.NextVariables, "NextVariables", logElementCount: true);

(ILocalSymbol loopObject, ForToLoopOperationUserDefinedInfo userDefinedInfo) = ((BaseForToLoopStatement)operation).Info;
Copy link
Member

@jaredpar jaredpar May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopObject [](start = 26, length = 10)

The loopObject element could be a discard. #WontFix

@@ -255,6 +260,16 @@ public override void VisitForToLoop(IForToLoopOperation operation)
{
VisitLoop(operation);
Assert.Equal(LoopKind.ForTo, operation.LoopKind);
_ = operation.IsChecked;
(ILocalSymbol loopObject, ForToLoopOperationUserDefinedInfo userDefinedInfo) = ((BaseForToLoopStatement)operation).Info;
Copy link
Member

@jaredpar jaredpar May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loopObject element can be a discard. #WontFix

@@ -255,6 +260,16 @@ public override void VisitForToLoop(IForToLoopOperation operation)
{
VisitLoop(operation);
Assert.Equal(LoopKind.ForTo, operation.LoopKind);
_ = operation.IsChecked;
Copy link
Member

@jaredpar jaredpar May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line looks suspicious. It implies there is a property here which is side effecting that needs to be executed. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line looks suspicious. It implies there is a property here which is side effecting that needs to be executed.

The purpose of this line is to evaluate the property to make sure it doesn't crash. This is a test code.


In reply to: 187121790 [](ancestors = 187121790)

{
return new InvalidOperation(ImmutableArray.Create<IOperation>(child1, child2),
semanticModel: null, syntax, type,
constantValue: default, isImplicit: true);
Copy link
Member

@jaredpar jaredpar May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are invalid operations implicit? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are invalid operations implicit?

Usually, implicit operations are those that are synthesized. Like this one, for example. It is not a clone of a node present in the original tree.


In reply to: 187123049 [](ancestors = 187123049)

}
else
{
IOperation controlVariableReferenceforCondition = getLoopControlVariableRefernce(forceImplicit: true); // Yes we are going to reevaluate it again
Copy link
Member

@333fred 333fred May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getLoopControlVariableRefernce [](start = 70, length = 30)

typo: getLoopControlVariableRefernce -> getLoopControlVariableReference #Resolved

//RemovePlaceholderReplacement(forStatement.OperatorsOpt.LeftOperandPlaceholder)
//RemovePlaceholderReplacement(forStatement.OperatorsOpt.RightOperandPlaceholder)
}
else if (!operation.StepValue.ConstantValue.HasValue &&
Copy link
Contributor

@mavasani mavasani May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can StepValue be null? If not, we probably want to update the doc comment. #Resolved

Copy link
Contributor Author

@AlekseyTs AlekseyTs May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can StepValue be null? If not, we probably want to update the doc comment.

I don't think it can ever be null. I'll update the doc comment. I will also adjust VisitForToLoop in TestOperationVisitor accordingly.


In reply to: 187130267 [](ancestors = 187130267)

Copy link
Contributor

@mavasani mavasani May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably also want to replace the null check with an assert in TestOperationVisitor #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably also want to replace the null check with an assert in TestOperationVisitor

Yes, the null check should be removed there


In reply to: 187132438 [](ancestors = 187132438)

@333fred
Copy link
Member

333fred commented May 9, 2018

Tests look good.

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are OK to be addressed in a follow up PR.

@AlekseyTs
Copy link
Contributor Author

@333fred, @mavasani, @jaredpar In my responses I identified the issues I am going to address in the next PR. These are:

Please let me know if you consider this issues, or any other issues, blocking for this PR. Otherwise, could you please sign-off so that I can resolve merge conflicts and merge the PR, it is going to conflict with any other builder change merged into the branch.

@AlekseyTs
Copy link
Contributor Author

@cston, @dotnet/roslyn-compiler Please review, need a second review

Copy link
Member

@jaredpar jaredpar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@AlekseyTs AlekseyTs merged commit fe66c82 into dotnet:features/dataflow May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants