mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
enhance(compiler): fix warnings
remove unused signature, functions, variable remove pessimizing-moves add cast before comparison
This commit is contained in:
@@ -34,10 +34,6 @@ public:
|
||||
static outcome::checked<std::unique_ptr<KeySet>, StringError>
|
||||
generate(ClientParameters ¶ms, uint64_t seed_msb, uint64_t seed_lsb);
|
||||
|
||||
static outcome::checked<std::unique_ptr<KeySet>, StringError>
|
||||
generateCached(ClientParameters ¶ms, uint64_t seed_msb,
|
||||
uint64_t seed_lsb);
|
||||
|
||||
// isInputEncrypted return true if the input at the given pos is encrypted.
|
||||
bool isInputEncrypted(size_t pos);
|
||||
|
||||
|
||||
@@ -67,22 +67,22 @@ typedVectorResult(JITLambda::Argument &arguments) {
|
||||
template <>
|
||||
inline llvm::Expected<std::vector<uint8_t>>
|
||||
typedResult(JITLambda::Argument &arguments) {
|
||||
return std::move(typedVectorResult<uint8_t>(arguments));
|
||||
return typedVectorResult<uint8_t>(arguments);
|
||||
}
|
||||
template <>
|
||||
inline llvm::Expected<std::vector<uint16_t>>
|
||||
typedResult(JITLambda::Argument &arguments) {
|
||||
return std::move(typedVectorResult<uint16_t>(arguments));
|
||||
return typedVectorResult<uint16_t>(arguments);
|
||||
}
|
||||
template <>
|
||||
inline llvm::Expected<std::vector<uint32_t>>
|
||||
typedResult(JITLambda::Argument &arguments) {
|
||||
return std::move(typedVectorResult<uint32_t>(arguments));
|
||||
return typedVectorResult<uint32_t>(arguments);
|
||||
}
|
||||
template <>
|
||||
inline llvm::Expected<std::vector<uint64_t>>
|
||||
typedResult(JITLambda::Argument &arguments) {
|
||||
return std::move(typedVectorResult<uint64_t>(arguments));
|
||||
return typedVectorResult<uint64_t>(arguments);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -98,7 +98,7 @@ buildTensorLambdaResult(JITLambda::Argument &arguments) {
|
||||
arguments.getResultDimensions(0);
|
||||
|
||||
if (!tensorDimOrError)
|
||||
return std::move(tensorDimOrError.takeError());
|
||||
return tensorDimOrError.takeError();
|
||||
|
||||
return std::move(std::make_unique<TensorLambdaArgument<IntLambdaArgument<T>>>(
|
||||
*tensorOrError, *tensorDimOrError));
|
||||
@@ -113,7 +113,7 @@ typedResult(JITLambda::Argument &arguments) {
|
||||
arguments.getResultType(0);
|
||||
|
||||
if (!resTy)
|
||||
return std::move(resTy.takeError());
|
||||
return resTy.takeError();
|
||||
|
||||
switch (*resTy) {
|
||||
case JITLambda::Argument::ResultType::SCALAR: {
|
||||
@@ -122,14 +122,14 @@ typedResult(JITLambda::Argument &arguments) {
|
||||
if (llvm::Error err = arguments.getResult(0, res))
|
||||
return std::move(err);
|
||||
|
||||
return std::move(std::make_unique<IntLambdaArgument<uint64_t>>(res));
|
||||
return std::make_unique<IntLambdaArgument<uint64_t>>(res);
|
||||
}
|
||||
|
||||
case JITLambda::Argument::ResultType::TENSOR: {
|
||||
llvm::Expected<size_t> width = arguments.getResultWidth(0);
|
||||
|
||||
if (!width)
|
||||
return std::move(width.takeError());
|
||||
return width.takeError();
|
||||
|
||||
if (*width > 64)
|
||||
return StreamStringError("Cannot handle scalars with more than 64 bits");
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
llvm::Expected<bool> successOrError = tryAddArg<IntT>(jla, pos, arg);
|
||||
|
||||
if (!successOrError)
|
||||
return std::move(successOrError.takeError());
|
||||
return successOrError.takeError();
|
||||
|
||||
if (successOrError.get() == false)
|
||||
return tryAddArg<NextIntT, IntTs...>(jla, pos, arg);
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
uint8_t, size_t>(jla, pos, arg);
|
||||
|
||||
if (!successOrError)
|
||||
return std::move(successOrError.takeError());
|
||||
return successOrError.takeError();
|
||||
|
||||
if (successOrError.get() == false)
|
||||
return StreamStringError("Unknown argument type");
|
||||
|
||||
@@ -85,16 +85,6 @@ inline mlir::Type getGenericCleartextType(mlir::MLIRContext *context) {
|
||||
return mlir::IntegerType::get(context, 64);
|
||||
}
|
||||
|
||||
inline mlir::concretelang::Concrete::PlaintextListType
|
||||
getGenericPlaintextListType(mlir::MLIRContext *context) {
|
||||
return mlir::concretelang::Concrete::PlaintextListType::get(context);
|
||||
}
|
||||
|
||||
inline mlir::concretelang::Concrete::ForeignPlaintextListType
|
||||
getGenericForeignPlaintextListType(mlir::MLIRContext *context) {
|
||||
return mlir::concretelang::Concrete::ForeignPlaintextListType::get(context);
|
||||
}
|
||||
|
||||
inline mlir::concretelang::Concrete::LweKeySwitchKeyType
|
||||
getGenericLweKeySwitchKeyType(mlir::MLIRContext *context) {
|
||||
return mlir::concretelang::Concrete::LweKeySwitchKeyType::get(context);
|
||||
|
||||
@@ -149,8 +149,7 @@ struct TFHEApplyLookupTablePaddingPattern
|
||||
mlir::PatternBenefit benefit =
|
||||
mlir::concretelang::DEFAULT_PATTERN_BENEFIT)
|
||||
: mlir::OpRewritePattern<mlir::concretelang::TFHE::ApplyLookupTable>(
|
||||
context, benefit),
|
||||
typeConverter(typeConverter), v0Parameter(v0Parameter) {}
|
||||
context, benefit) {}
|
||||
|
||||
mlir::LogicalResult
|
||||
matchAndRewrite(mlir::concretelang::TFHE::ApplyLookupTable op,
|
||||
@@ -201,10 +200,6 @@ struct TFHEApplyLookupTablePaddingPattern
|
||||
|
||||
return mlir::success();
|
||||
};
|
||||
|
||||
private:
|
||||
mlir::TypeConverter &typeConverter;
|
||||
mlir::concretelang::V0Parameter &v0Parameter;
|
||||
};
|
||||
|
||||
template <typename Op>
|
||||
@@ -227,7 +222,8 @@ void populateWithTFHEApplyLookupTableParametrizationPattern(
|
||||
[&](mlir::concretelang::TFHE::ApplyLookupTable op) {
|
||||
if (op.glweDimension() != v0Parameter.glweDimension ||
|
||||
// TODO remove the shift when we have true polynomial size
|
||||
op.polynomialSize() != (1 << v0Parameter.logPolynomialSize) ||
|
||||
op.polynomialSize() !=
|
||||
((uint32_t)1 << v0Parameter.logPolynomialSize) ||
|
||||
op.levelKS() != v0Parameter.ksLevel ||
|
||||
op.baseLogKS() != v0Parameter.ksLogBase ||
|
||||
op.levelBS() != v0Parameter.brLevel ||
|
||||
|
||||
@@ -136,7 +136,6 @@ llvm::Expected<llvm::Optional<mlir::concretelang::V0FHEConstraint>>
|
||||
CompilerEngine::getV0FHEConstraint(CompilationResult &res) {
|
||||
mlir::MLIRContext &mlirContext = *this->compilationContext->getMLIRContext();
|
||||
mlir::ModuleOp module = res.mlirModuleRef->get();
|
||||
llvm::Optional<mlir::concretelang::V0FHEConstraint> fheConstraints;
|
||||
// If the values has been overwritten returns
|
||||
if (this->overrideMaxEintPrecision.hasValue() &&
|
||||
this->overrideMaxMANP.hasValue()) {
|
||||
@@ -160,7 +159,7 @@ CompilerEngine::getV0FHEConstraint(CompilationResult &res) {
|
||||
llvm::Error CompilerEngine::determineFHEParameters(CompilationResult &res) {
|
||||
auto fheConstraintOrErr = getV0FHEConstraint(res);
|
||||
if (auto err = fheConstraintOrErr.takeError())
|
||||
return std::move(err);
|
||||
return err;
|
||||
if (!fheConstraintOrErr.get().hasValue()) {
|
||||
return llvm::Error::success();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ JitCompilerEngine::buildLambda(llvm::StringRef s, llvm::StringRef funcName,
|
||||
std::unique_ptr<llvm::MemoryBuffer> mb = llvm::MemoryBuffer::getMemBuffer(s);
|
||||
llvm::Expected<JitCompilerEngine::Lambda> res =
|
||||
this->buildLambda(std::move(mb), funcName, cache, runtimeLibPath);
|
||||
return std::move(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
// Build a lambda from the function with the name given in
|
||||
@@ -77,7 +77,7 @@ JitCompilerEngine::buildLambda(llvm::SourceMgr &sm, llvm::StringRef funcName,
|
||||
this->compile(sm, Target::LLVM_IR);
|
||||
|
||||
if (!compResOrErr)
|
||||
return std::move(compResOrErr.takeError());
|
||||
return compResOrErr.takeError();
|
||||
|
||||
auto compRes = std::move(compResOrErr.get());
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ mlir::LogicalResult processInputBuffer(
|
||||
if (!resOrErr) {
|
||||
mlir::concretelang::log_error()
|
||||
<< "Failed to JIT-invoke " << funcName << " with arguments "
|
||||
<< jitArgs << ": " << llvm::toString(std::move(resOrErr.takeError()));
|
||||
<< jitArgs << ": " << llvm::toString(resOrErr.takeError());
|
||||
return mlir::failure();
|
||||
}
|
||||
|
||||
@@ -348,13 +348,14 @@ mlir::LogicalResult processInputBuffer(
|
||||
break;
|
||||
case JIT_INVOKE:
|
||||
// Case just here to satisfy the compiler; already handled above
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
auto retOrErr = ce.compile(std::move(buffer), target, outputLib);
|
||||
|
||||
if (!retOrErr) {
|
||||
mlir::concretelang::log_error()
|
||||
<< llvm::toString(std::move(retOrErr.takeError())) << "\n";
|
||||
<< llvm::toString(retOrErr.takeError()) << "\n";
|
||||
|
||||
return mlir::failure();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user