-
Notifications
You must be signed in to change notification settings - Fork 636
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
DYN-6527: Fix graph update for primitive input nodes that are first initialized to null #14703
Merged
aparajit-pratap
merged 41 commits into
DynamoDS:master
from
aparajit-pratap:testDropdown
Dec 8, 2023
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
64b4706
remove coreclr-ncalc references
aparajit-pratap 4a82ae7
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap dbc3e12
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 81ace20
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap a7cafdc
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 55c654d
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 7ede2a4
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap c43a02d
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 1951d1a
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap cd100b1
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap c04c193
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 35edbdb
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 5c6a4a3
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 1641149
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap eff8d9b
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 8415e17
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 8a3368b
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 3350614
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap be0a127
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap a3d62e9
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap a3c806e
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap e93499d
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap a551e0e
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 1889a02
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap f3a7315
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 06e96a0
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 823d317
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap f411221
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 7c590f3
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 02e4acf
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap d9358e0
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 1d41e40
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 12c7dc1
Merge branch 'master' of github.com:DynamoDS/Dynamo
aparajit-pratap 816dccf
add failing test for dropdown node
aparajit-pratap fa51c82
cleanup
aparajit-pratap c48f42a
update tests
aparajit-pratap 76b04a4
attempt initial fix
aparajit-pratap 33c071b
cleanup
aparajit-pratap 600fea5
update test
aparajit-pratap d688294
review comments
aparajit-pratap ba8f011
add code comments
aparajit-pratap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using ProtoCore.AST.AssociativeAST; | ||
using ProtoCore.AST.AssociativeAST; | ||
using ProtoCore.DSASM; | ||
using ProtoCore.Utils; | ||
using System.Collections.Generic; | ||
|
@@ -275,7 +275,11 @@ private List<AssociativeNode> BuildSSA(List<AssociativeNode> astList, ProtoCore. | |
BinaryExpressionNode bnode = (node as BinaryExpressionNode); | ||
int generatedUID = ProtoCore.DSASM.Constants.kInvalidIndex; | ||
|
||
if (context.applySSATransform && core.Options.GenerateSSA) | ||
// Skip SSA for input ASTs that are first assigned null such as this: | ||
// a = null; (update "a") => a = <some primitive>; | ||
// SSA would break up the null AST into two assignments, which then breaks update: | ||
// a = null; (SSA) => temp = null; a = temp; | ||
if (context.applySSATransform && core.Options.GenerateSSA && !bnode.IsInputExpression) | ||
{ | ||
int ssaID = ProtoCore.DSASM.Constants.kInvalidIndex; | ||
string name = ProtoCore.Utils.CoreUtils.GenerateIdentListNameString(bnode.LeftNode); | ||
|
@@ -382,53 +386,6 @@ private List<AssociativeNode> BuildSSA(List<AssociativeNode> astList, ProtoCore. | |
return astList; | ||
} | ||
|
||
private void DfsSSAIeentList(AssociativeNode node, ref Stack<AssociativeNode> ssaStack, ref List<AssociativeNode> astlist) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused |
||
if (node is IdentifierListNode) | ||
{ | ||
IdentifierListNode listNode = node as IdentifierListNode; | ||
|
||
bool isSingleDot = !(listNode.LeftNode is IdentifierListNode) && !(listNode.RightNode is IdentifierListNode); | ||
if (isSingleDot) | ||
{ | ||
BinaryExpressionNode bnode = BuildSSAIdentListAssignmentNode(listNode); | ||
astlist.Add(bnode); | ||
ssaStack.Push(bnode); | ||
} | ||
else | ||
{ | ||
DfsSSAIeentList(listNode.LeftNode, ref ssaStack, ref astlist); | ||
|
||
IdentifierListNode newListNode = node as IdentifierListNode; | ||
newListNode.Optr = Operator.dot; | ||
|
||
AssociativeNode leftnode = ssaStack.Pop(); | ||
Validity.Assert(leftnode is BinaryExpressionNode); | ||
|
||
newListNode.LeftNode = (leftnode as BinaryExpressionNode).LeftNode; | ||
newListNode.RightNode = listNode.RightNode; | ||
|
||
BinaryExpressionNode bnode = BuildSSAIdentListAssignmentNode(newListNode); | ||
astlist.Add(bnode); | ||
ssaStack.Push(bnode); | ||
|
||
} | ||
} | ||
else if (node is FunctionCallNode) | ||
{ | ||
FunctionCallNode fcNode = node as FunctionCallNode; | ||
for (int idx = 0; idx < fcNode.FormalArguments.Count; idx++) | ||
{ | ||
AssociativeNode arg = fcNode.FormalArguments[idx]; | ||
|
||
Stack<AssociativeNode> ssaStack1 = new Stack<AssociativeNode>(); | ||
DFSEmitSSA_AST(arg, ssaStack1, ref astlist); | ||
AssociativeNode argNode = ssaStack.Pop(); | ||
fcNode.FormalArguments[idx] = argNode is BinaryExpressionNode ? (argNode as BinaryExpressionNode).LeftNode : argNode; | ||
} | ||
} | ||
} | ||
|
||
private void DFSEmitSSA_AST(AssociativeNode node, Stack<AssociativeNode> ssaStack, ref List<AssociativeNode> astlist) | ||
{ | ||
Validity.Assert(null != astlist && null != ssaStack); | ||
|
@@ -488,7 +445,8 @@ private void DFSEmitSSA_AST(AssociativeNode node, Stack<AssociativeNode> ssaStac | |
|
||
var bnode = AstFactory.BuildAssignment(leftNode, rightNode); | ||
bnode.isSSAAssignment = isSSAAssignment; | ||
bnode.IsInputExpression = astBNode.IsInputExpression; | ||
// TODO: SSA is not called for ASTs that are input expressions. Revisit this if there are any issues. | ||
aparajit-pratap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// bnode.IsInputExpression = astBNode.IsInputExpression; | ||
|
||
astlist.Add(bnode); | ||
ssaStack.Push(bnode); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using System; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skip SSA for cases such as this:
which would after SSA turn into this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think this is a good constraint to have on SSA, or should we mark this as a temporary workaround and file a task to fix the optimization in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see any reason why we need to SSA a simple expression like
a = null;
in the first place, which essentially states that each variable should be assigned exactly once.