-
Notifications
You must be signed in to change notification settings - Fork 100
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
[CIR][CodeGen] Goto pass #562
Conversation
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.
Awesome, overall approach looks good. More inline questions/comments.
let assemblyFormat = [{ $label attr-dict }]; | ||
} | ||
|
||
def LabelOp : CIR_Op<"label"> { |
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.
Should this use Symbol
trait?
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.
Tagging as requested changes
@bcardosolopes So, Am I doing something wrong? Speaking about |
Tricky, I don't think you are doing anything wrong, it's just the way it works, looks like =(
Sounds like a good idea. Translating in practical terms:
This means the source of truth becomes the list (not allowing it to be innaccurate with the rest of usage) and make verifiers pretty straightforward:
Wdyt? |
Oh, and we should probably mark goto and label ops to have side-effects, so they don't get removed in the future when we start using the canonicalizer. |
It's doable! But I would preserve label names in the function body, it's more readable from my point of view. Well, custom printing will help us here, but I'm afraid we'll have a problem with parsing: no way to translate string into index - we need to get a parent operation somehow for the operation we're currently trying to create. Of course it's up to you :) just let me know how do you see it after all.
May I ask for a hint? ) Tried several traits with no luck. BTW, current |
Definitely more readable. But if we only use the index, we don't have the parsing problem and we don't even need custom print/parsing: the verifier is the one checking if the "access" makes sense, and at that point one can get the FuncOp to look into the list. (unless I'm missing something?)
I'm open, and I'm usually "all for" more readable. One possible (and nice) approach would be to introduce two new traits:
Which ones did you try? My suggestions would be to see users of Actually, we had a discussion about this in todays meeting, one good idea we got from @orbiri was to always add tests for new operations to make sure the canonicalizer won't remove them (similar to what we do with |
Btw, @lanza rebased over the weekend, sorry for the churn. Can you rebase this PR again? |
c4db6d0
to
e197d4e
Compare
while it still in progress (I tried a solution with indexes and didn't fix tests so far) we have something to discuss. speaking about
The problem is that
I have one more idea. What if we will use strings in label/goto operations and have a list of strings as
I will try to take a look at, but at the first glance it looks it will complicate all of this, or it's a wrong impression? Like So what do you think? I would do it in a more simple way, but if it's a wrong approach - let's try to go with the one you've suggested. |
Oh, that's really aggressive. Not sure I have a solution for that just yet, please add this information in one the existing issues so we can keep track of it. It also might be worth posting on discourse/MLIR and ask around if that's a known issue or if there's any trick we could do. Btw, I remember that some passes have a configuration struct you can pass in that diminishes the aggressiviness, have you look into that for the canonicalizer? Perhaps there's a mode that isn't that aggressive with unrecheable blocks.
I'd be fine with marking it with memory effect or something else that holds it down until we find a proper solution. We just need to make sure to document this enough so at some point we can work with MLIR upstream for a proper solution.
I'm a bit unconfortable to introduce the same string 3 times, seems a bit odd - 2 times is probably enough (if we have to do it in label and goto).
Why
Simple is fine, goto/label have each one StringRef, no FuncOp level lists. Perhaps the verification should be done in FuncOp, so you can collect labels for all cir.gotos and cir.labels and make sure they match in one place. Let's keep this simple until its proven that this is actually affecting compile times. |
Looks like some stuff is still failing, I tried to solve the merge conflict myself, perhaps it was that. Let me know once you update it and I'll land it |
@bcardosolopes
Speaking about unreachable blocks removal, I didn't understand how to feed command line parameters to the
This runs the |
Thank you!
I saw that and thought it was pretty clever haha, I didn't know how to achieve that. I believe it's the best we can do right now. Can you update one of the issues and mention how you applied the workaround? Might be useful information to share. I also noticed you broke it down into Thanks for working on this, it's a very important piece of missing codegen, I'm very happy to see this landing. |
@bcardosolopes Speaking about the |
Yep, I got that and it's all good.
I was just curious about the specifics of what you were expecting to be tested by the canonicalizer, hence my comment about adding a comment in the test file. Not really necessary, but could be good in case we need to rewrite it or delete it at some point |
- Add new operations: `GotoOp` and `LabelOp` and inserts them in the codegen - Adds a pass that replaces `goto` operations with branches to the corresponded blocks (and erases `LabelOp` from CIR) - Update verifiers and tests
- Add new operations: `GotoOp` and `LabelOp` and inserts them in the codegen - Adds a pass that replaces `goto` operations with branches to the corresponded blocks (and erases `LabelOp` from CIR) - Update verifiers and tests
- Add new operations: `GotoOp` and `LabelOp` and inserts them in the codegen - Adds a pass that replaces `goto` operations with branches to the corresponded blocks (and erases `LabelOp` from CIR) - Update verifiers and tests
- Add new operations: `GotoOp` and `LabelOp` and inserts them in the codegen - Adds a pass that replaces `goto` operations with branches to the corresponded blocks (and erases `LabelOp` from CIR) - Update verifiers and tests
This PR:
GotoOp
andLabelOp
and inserts them in the codegengoto
operations with branches to the corresponded blocks (and erasesLabelOp
from CIR)FuncOp
to track which functions should be processed by the pass