[FIRRTL] Fix FModuleOp::erasePorts failing on empty attr arrays

As an optimization, we use empty array attributes on module-like ops
where none of the ports have an attribute set. The code in `erasePorts`
assumes that all arrays have the same number of entries as the module
has ports.

This adds a special case that just passes through empty arrays (the
optimized case).
This commit is contained in:
Fabian Schuiki 2021-11-04 13:38:53 +01:00
parent 3c98641554
commit fc15900656
No known key found for this signature in database
GPG Key ID: C42F5825FC5275E6
1 changed files with 5 additions and 0 deletions

View File

@ -50,6 +50,11 @@ removeElementsAtIndices(ArrayRef<T> input, ArrayRef<unsigned> indicesToDrop) {
}
#endif
// If the input is empty (which is an optimization we do for certain array
// attributes), simply return an empty vector.
if (input.empty())
return {};
// Copy over the live chunks.
size_t lastCopied = 0;
SmallVector<T> result;