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.
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
Migrate some passes to Mini passes #11191
Migrate some passes to Mini passes #11191
Changes from 6 commits
c9ef2c3
43eafae
4a0fd85
1bbf991
70f0a1a
808dbd8
1abc70d
cdf1d87
d7b6016
1bd2b40
61fed92
40252a2
76dbc23
4a66460
be2724d
fd3a727
8a5c435
995dea5
985b8c2
28edccb
6121750
54e5bd0
6b4c6b3
01561a1
dd42554
f85f017
a4aaf8e
836c4c2
079543a
5d19be4
a369ed8
487003f
b2f7053
edec03b
67ff454
547e9e6
925a2de
dc6e7f3
c56c2be
ea1462a
18f4cea
e2fc538
a58ecc8
1aaa589
8604acb
0ddb96b
a85679d
80c4545
9a5dfea
d5c6983
89cde89
7c9f370
92ae4fe
65560c4
dfc54db
8771d58
bdff605
ce56abb
d42d3e9
ba7ab9d
90139e7
8558d5b
05fd38a
367fc9a
36ebf2b
0a02563
83f4a57
69b3274
dea6dd6
6c2b51d
f27ce6f
f4077de
1b021c2
8ce42e0
64b013f
f54ba6d
40ef345
8124e1e
668fdfd
2af068f
95b1756
c84e881
0964711
ffd27df
924e404
2736a76
762045a
ef3450c
248c0f4
befef0c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 was looking at ForkJoinPool. They claim the best way to split the work is
Maybe we should really be traversing only
ir.Expression
. Maybe the other elements likeCallArgument
are too small to be processed by own tasks.If we traversed only
ir.Expression
, then the problem ofwithNewChildren
not being 1:1 withmapExpressions
(as pointed out here) would be solved ;-)Even better way to be 1:1
This is 100% guaranteed to be 1:1 with
mapExpressions
implementations:Using
ir.mapExpressions
is necessary to get thru CallArgument.Specified in Application.By using
mapExpressions
to collect the children to process and also to replace the children with new ones, we reuse existing infrastructure. Moreover we get better mapping of currentIRPass
implementations (that usemapExpressions
to traverse) to their new mini passes reimplementation.Benefit
We don't need these decomposition methods that disassemble
List<IR>
pieces trying to find constructor to call.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 really believe we can achieve our performance/memory goals with
IR.mapExpression
. Here is a tag jtulach/MiniPassTraverserWithMapChildren that demonstrates it. I'll put the commit e2fc538 into this branch as well - but feel free to remove it, if we decide we desperately needwithNewChildren
for some pass.Tests seem to work. Prior to my commit there were some failures in
org.enso.compiler.test.pass.analyse.TailCallTest
- after my commit there are also only failures inTailCallTest
. Thus I assume all the other mini passes are working fine with themapExpressions
approach.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 am struggling with implementing
TailCall
mini pass with this pattern.TailCall
is a pass that traverses the whole IR tree and attaches to every node eitherTAIL
orNOT_TAIL
.Following is a picture of IR tree with numbered
prepare
andtransform
steps ofMiniIRPassTraverser
(implemented withmapExpressions
as contributed by @JaroslavTulach on revision ce56abb):As you can see, the
MiniIRPassTraverser
basically ignores the wholebindings[1]
andbindings[2]
subtrees, because they are not Expressions. How am I supposed to transform those? Should I manually recursively traverse all the children of Expression and look for IR elements that are not Expressions and do my transformation of those? If yes, then this is would not be a mini pass at all, it would be a weird monstrosity somewhere between a mega pass and mini pass. I am not even mentioning how ugly (difficult to maintain) and non-intuitive it is to work with this.In my opinion, this is a proof that the solution with traversing only Expressions with
mapExpressions
is not sustainable, and we should not continue in this direction.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.
Last Friday we agreed to disagree. This PR is going to work with
mapExpressions
and the fact it is green is a proof it can work that way.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.
On the other hand, while implementing the
TailCall
pass, I came to an agreement that theprepare
method shall get an edge in theIR
tree - e.g. its signature should beMiniIRPass prepare(IR parent, IR child)
. Traversing by edges is however orthogonal to usingmapExpressions
orwithNewChildren
question.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.
Isn't
TailCall
pass now simplified (d9b3c75) and therefore not a representative case for this problem? Meaning we will likely encounter it in other passes? Note: unlike both of you, I haven't attempted the transformation into mini passes myself so I have an incomplete picture, clearly.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.
No, that change has no effect on the traversal.
TailCall
is as representative as it was and is the main reason why I see that edge traversal as advocated by Pavel is more meaningful than vertex traversal.It remains to be seen what we will encounter in other passes. However I'd like to highlight following quote: "by using
mapExpressions
... we get better mapping of currentIRPass
implementations" that are already usingmapExpressions
to traverse!