Skip to content

Commit 011f5aa

Browse files
committed
Check invalid types not invalid ops per review comments from JK and AA
1 parent 384e09c commit 011f5aa

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/Transforms/ConvertToCiphertextSemantics/ConvertToCiphertextSemantics.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,20 @@ struct ConvertToCiphertextSemantics
10641064

10651065
RewritePatternSet patterns(context);
10661066
ConversionTarget target(*context);
1067-
target.markUnknownOpDynamicallyLegal([&](Operation* op) {
1067+
1068+
// check for invalid types and bail out of the pass
1069+
SmallVector<Type, 2> _invalid_types = {mlir::IndexType::get(context)};
1070+
mlir::TypeRange invalid_types(_invalid_types);
1071+
auto _helper_valid_type =
1072+
[invalid_types](const Type &type) -> LogicalResult {
1073+
return (llvm::is_contained(invalid_types, type) ? failure() : success());
1074+
};
1075+
if (!walkAndValidateTypes<secret::GenericOp>(module, _helper_valid_type)
1076+
.succeeded()) {
1077+
return signalPassFailure();
1078+
}
1079+
1080+
target.markUnknownOpDynamicallyLegal([&](Operation *op) {
10681081
return isa<ModuleOp>(op) || hasMaterializedAttr(op);
10691082
});
10701083

0 commit comments

Comments
 (0)