Skip to content

Commit c2bff67

Browse files
authored
[mlir][emitc] Don't convert unsupported types in EmitC
This PR adds check for unsupported types in emitc, which fixes a crash.
1 parent b9d27ac commit c2bff67

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mlir/lib/Conversion/SCFToEmitC/SCFToEmitC.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,11 @@ void SCFToEmitCPass::runOnOperation() {
322322
// Fallback converter
323323
// See note https://mlir.llvm.org/docs/DialectConversion/#type-converter
324324
// Type converters are called most to least recently inserted
325-
typeConverter.addConversion([](Type t) { return t; });
325+
typeConverter.addConversion([](Type type) -> std::optional<Type> {
326+
if (emitc::isSupportedEmitCType(type))
327+
return type;
328+
return {};
329+
});
326330
populateEmitCSizeTTypeConversions(typeConverter);
327331
populateSCFToEmitCConversionPatterns(patterns, typeConverter);
328332

0 commit comments

Comments
 (0)