[FIRRTL] Remove class deduplication #9022
Closed
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.
The FIRRTL Dedup pass currently also deduplicates classes. This is problematic, since classes are nominally typed, which requires their names to be fixed and doesn't allow us to swap one class for another even if they are structurally equivalent. Downstream tools expect the classes to retain their names, which is problematic if they look for class "Foo", but "Foo" happened to be structurally equivalent to "Bar" and therefore got replaced with "Bar".
To fix this, remove any class handling from the dedup pass. It can no longer remove classes or change an object's class. As a result, we can now treat class types as opaque again, since the class name symbols they contain will not be changed by the pass.
An alternative approach would have been to remove the nominal typing property from classes. If names are not stable, the compiler would be free to arbitrarily deduplicate and rework classes. This would imply changes in downstream tools, and @mikeurbach pointed out that the intent behind FIRRTL's classes were for them to be nominally typed. This now puts the onus of not generating gratuitous class definitions on Chisel and other frontends that produce FIRRTL.