Skip to content
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

[FIRRTL] Donot rename InstanceOp #5352

Merged
merged 5 commits into from
Jun 9, 2023
Merged

Conversation

prithayan
Copy link
Contributor

Fix for #5351

@prithayan prithayan changed the title [FIRRTL]Donot rename InstanceOp [FIRRTL] Donot rename InstanceOp Jun 9, 2023
lib/Dialect/FIRRTL/FIRRTLFolds.cpp Outdated Show resolved Hide resolved
test/Dialect/FIRRTL/canonicalization.mlir Outdated Show resolved Hide resolved
test/Dialect/FIRRTL/canonicalization.mlir Outdated Show resolved Hide resolved
Copy link
Contributor

@dtzSiFive dtzSiFive left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@@ -115,6 +115,8 @@ static StringRef chooseName(StringRef a, StringRef b) {
/// the name passed in.
static void updateName(PatternRewriter &rewriter, Operation *op,
StringAttr name) {
// Should never rename InstanceOp
assert(!isa<InstanceOp>(op));
Copy link
Contributor

Choose a reason for hiding this comment

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

This method looks like it only replaces the name if the old one is "less good" (including shorter, as in the lit test).

Anyway naming a likely-to-have-multiple-results instance op with name of a node consuming its result does seem unlikely to do what we want (maybe the length comparison should compare against the full asm result name?).

If the instance has no name (or it's useless or droppable), in some sense it may be good to keep the name of the node around for readability but not sure worth trying to handle that (sanely).

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, maybe this can just return early on instance op instead of assert, and less checking on caller-side?

If you want to be sure any misuse (user calling this on an instanceop that may expect it to do something) the assert sounds good to me, just a thought. Yay asserts! 👍

prithayan and others added 3 commits June 9, 2023 11:03
Co-authored-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Co-authored-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Co-authored-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@prithayan prithayan merged commit 7d84be4 into main Jun 9, 2023
5 checks passed
@prithayan prithayan deleted the dev/pbarua/donot_rename_instance branch June 9, 2023 19:18
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.

None yet

4 participants