-
Notifications
You must be signed in to change notification settings - Fork 347
[FIRRTL] Introduce notation of discardable annotation #5240
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
Conversation
@@ -1495,6 +1495,14 @@ Example: | |||
} | |||
``` | |||
|
|||
## Discardable Annotaions | |||
|
|||
By default, annotations in the FIRRTL dialect prevent dead code elimination (DCE). |
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.
Nit: This is specific to dead-code elim in particular. Does this literally only impact whether a value is considered "live" (if the annotation pointing to it is also live)? That does seem more straightforward re:scope.
"Discardable" suggests that it could be dropped, perhaps for no reason (?), but certainly by various optimizations such as canonicalizers. Is this right?
Are there requirements to preserve this /if/ the target is preserved in some sense (something something notions of equality/identity)? For example, could we CSE a value with this annotation, or discard it during a transform if inconvenient to preserve? Where in the spectrum between "if this exists (asterisks on what precisely that means), the annotation will be on it I promise" vs "this is like a namehint, we do what we can but ultimately who can say and if you need this for correctness do it a different way"?
Targeting DCE specifically mostly avoids these questions, although it seems like defining the semantics this way is very specific to our implementation and notion of "DCE".
Do annotations block, e.g., IMCP, generally (if not, do discardable annotations block IMCP?)? Presumably if we can DCE this we can also constant-prop through it.
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.
"Discardable" suggests that it could be dropped, perhaps for no reason (?), but certainly by various optimizations such as canonicalizers. Is this right?
Yes, my intention was canonicalizer or folder can also drop the annotation if there is no user of the annotation target.\
For example, could we CSE a value with this annotation, or discard it during a transform if inconvenient to preserve?
I want to prohibit these operations.
Where in the spectrum between "if this exists (asterisks on what precisely that means), the annotation will be on it I promise" vs "this is like a namehint, we do what we can but ultimately who can say and if you need this for correctness do it a different way"?
The former semantics is exactly what I want to represent.
Do annotations block, e.g., IMCP, generally (if not, do discardable annotations block IMCP?)? Presumably if we can DCE this we can also constant-prop through it.
Annotations usually don't block IMCP. Only dontTouch annotation blocks the IMCP.
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, thanks for working to find good grounding for this behavior re:annotations!!
Little uncertain about this, or how it might extend beyond "how does this annotation impact our implementation of DCE" hopefully can sort that out.
This PR is separated from: #5226
By default, annotations in the FIRRTL dialect prevent dead code elimination.
However, certain annotations, like OMTracker created by OMReferenceTarget, are considered to have a "weak"
reference to their target. This means that the compiler has the option to delete
the target if it is determined to be dead. To indicate this property, we consider
an annotation with
circt.discardable
field as discardable, e.g:On top of this PR, #5226 changes IMDCE to remove non-local discardable annotations. We can also improve other passes by utilizing discardable annotations.