[MooreToCore] Emit targeted diagnostics for unsupported module port types (fixes #9572) #9575
+29
−5
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.
Summary
Fix assertion failure and emit precise diagnostic when
moore.modulehas unsupported port types. Previously,typeConverter.convertType()could returnnullptrfor unsupported types (e.g.,!moore.queue<i32, 10>,!moore.string), causing either a crash or an unhelpful "failed to legalize" error.Fixes #9572
Root Cause
File:
lib/Conversion/MooreToCore/MooreToCore.cppFunction:
getModulePortInfo()The function did not validate the result of
typeConverter.convertType():When conversion fails, the invalid
Typeis passed toModulePortInfoconstructor, triggering an assertion insanitizeInOut().Fix
Code Changes
lib/Conversion/MooreToCore/MooreToCore.cpp:231-285
FailureOr<hw::ModulePortInfo>:Test Coverage
test/Conversion/MooreToCore/errors.mlir
Added two test cases:
Behavior Changes
failed to legalize operation 'moore.module'port '<name>' has unsupported type '<type>' that cannot be converted to hardware typeFixes #9572