8000 [IMDCE] Remove dead hierpath and annotations in IMDCE by uenoku · Pull Request #5226 · llvm/circt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[IMDCE] Remove dead hierpath and annotations in IMDCE #5226

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

Merged
merged 4 commits into from
May 25, 2023

Conversation

uenoku
Copy link
Member
@uenoku uenoku commented May 18, 2023

This PR adds functionality to find and remove dead hierpath in IMDCE. There are discardable annotations (e.g. OMTracker) which use hierpath and prevent IMDCE from deleting instances with inner symbols. This PR imports some of InnerSymbolDCE logic into IMDCE.

Copy link
Contributor
@mikeurbach mikeurbach left a comment

Choose a reason for hiding this comment

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

Nice, I am not super familiar with this pass, but I think it looks good to me. Just left some minor feedback.

Copy link
Contributor
@prithayan prithayan left a comment

Choose a reason for hiding this comment

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

High level comments, what's the performance implication of computing the innerRefNamespace

@uenoku uenoku marked this pull request as ready for review May 23, 2023 16:00
@uenoku uenoku force-pushed the dev/uenoku/imdce-symboldce-2 branch 2 times, most recently from 7b891c1 to 242c536 Compare May 23, 2023 16:06
@uenoku
Copy link
Member Author
uenoku commented May 23, 2023

High level comments, what's the performance implication of computing the innerRefNamespace

I tesed large cores, but it increases 1% of entire execution time, so I'd consider acceptable.

@uenoku uenoku force-pushed the dev/uenoku/imdce-symboldce-2 branch from 242c536 to fddfd88 Compare May 23, 2023 16:29
@uenoku uenoku changed the title [IMDCE] Remove dead hierpath in IMDCE [IMDCE] Remove dead hierpath and annotations in IMDCE May 23, 2023
Copy link
Contributor
@prithayan prithayan left a comment

Choose a reason for hiding this comment

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

Thanks @uenoku , this looks good.

uenoku added 2 commits May 24, 2023 07:46
As it will require more discussion, this comit should not introduce
the concept of discrdable annotation. For now, just add `type` field to
OMIRTracker and hard code the logic into IMDCE so that we don't have to
worry about other than IMDCE
@uenoku
Copy link
Member Author
uenoku commented May 24, 2023

I updated the PR not to introduce the notion of "discardable/weak/value tap annotation" which requires more discussion (#5240). Instead, I modified OMIRTracker annotations to contain tracker types and IMDCE pass will determine whether it's valid to drop the tracker annotations. Eventually the logic should be replaced with "circt.discardbale" whatever.

@dtzSiFive
Copy link
Contributor

Computing IRN should be fairly fast, esp if there are many cores available, but good question. We presently compute it as part of verification between passes (that don't preserve everything), although there's no re-use from the verifier-computed version.

@uenoku uenoku merged commit 3093438 into main May 25, 2023
@uenoku uenoku deleted the dev/uenoku/imdce-symboldce-2 branch May 25, 2023 11:23
@@ -117,7 +117,7 @@ def RemoveUnusedPorts : Pass<"firrtl-remove-unused-ports", "firrtl::CircuitOp">
];
}

def IMDeadCodeElim : Pass<"firrtl-imdeadcodeelim", "firrtl::CircuitOp"> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think hierpath are now in the circuit namespace.

Copy link
Member Author

Choose a reason for hiding this comment

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

I followed the implementation of InnerSymbolDCE that checks all uses of inner symbols not only within circuit op.

// Run on the top-level ModuleOp to include any VerbatimOps that aren't
// wrapped in a CircuitOp.
ModuleOp topModule = getOperation();

If it's assumed that there is no user of inner symbol outer circuit op, it makes sense to me to make these passes circuit op.

if (!anno.isClass(omirTrackerAnnoClass))
return false;

auto tpe = anno.getMember<StringAttr>("type");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is NOT acceptable. No pass should be interpreting annotations except passes explicitly dealing with those annotations.

Copy link
Member Author
@uenoku uenoku May 26, 2023

Choose a reason for hiding this comment

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

Yes, I intended this to be very short term implementation until #5240 is merged (#5226 (comment)). Originally I implemented by adding "circt.discardable" attribute to annotation to indicate the annotation has weak reference, but I separated the PR into #5240.

uenoku added a commit that referenced this pull request Jun 6, 2023
This PR adds functionality to find and remove dead hierpaths and weak referencing annotations in IMDCE.
Even though it's not explicitly defined yet, some annotations (for example OMIRTracker)
are expected to be removed when annotation targets are dead. In many cases OMIRTracker
is represented as non-local annotations associated with hierpaths which are users of inner symbols.
So this PR imports some of InnerSymbolDCE  logic into IMDCE and aggressively removes inner symbols.
uenoku added a commit that referenced this pull request Jun 7, 2023
This PR adds functionality to find and remove dead hierpaths and weak referencing annotations in IMDCE.
Even though it's not explicitly defined yet, some annotations (for example OMIRTracker)
are expected to be removed when annotation targets are dead. In many cases OMIRTracker
is represented as non-local annotations associated with hierpaths which are users of inner symbols.
So this PR imports some of InnerSymbolDCE  logic into IMDCE and aggressively removes inner symbols.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0