clean(compiler): Return nullptr when conversion fails (should not happens but more safe in release mode) and remove dead code

This commit is contained in:
Quentin Bourgerie
2021-09-08 11:39:48 +02:00
parent d03adbd7dc
commit d2a3214bba

View File

@@ -27,6 +27,7 @@ LweCiphertextType convertTypeToLWE(mlir::MLIRContext *context,
return lwe;
}
assert(false && "expect glwe or lwe");
return nullptr;
}
template <typename PType>
@@ -50,6 +51,7 @@ PlaintextType convertPlaintextTypeFromType(mlir::MLIRContext *context,
return convertPlaintextTypeFromPType<LweCiphertextType>(context, lwe);
}
assert(false && "expect glwe or lwe");
return nullptr;
}
template <typename PType>
@@ -73,6 +75,7 @@ CleartextType convertCleartextTypeFromType(mlir::MLIRContext *context,
return convertCleartextTypeFromPType<LweCiphertextType>(context, lwe);
}
assert(false && "expect glwe or lwe");
return nullptr;
}
mlir::Value createZeroLWEOpFromMidLFHE(mlir::PatternRewriter rewriter,
@@ -113,7 +116,6 @@ mlir::Value createAddPlainLweCiphertextWithGlwe(
.create<mlir::zamalang::LowLFHE::EncodeIntOp>(loc, encoded_type, arg1)
.plaintext();
// convert result type
GLWECipherTextType glwe_type = result.getType().cast<GLWECipherTextType>();
LweCiphertextType lwe_type =
convertTypeToLWE(rewriter.getContext(), result.getType());
// replace op using the encoded plaintext instead of int