From 58f385b11b6551d2183e9c0d9d80255069ce691a Mon Sep 17 00:00:00 2001 From: youben11 Date: Mon, 15 Nov 2021 15:42:55 +0100 Subject: [PATCH] fix: move CompilationResult in return old toolchain (gcc 6.x) was complaining about not being able to convert CompilationResult to Expected --- compiler/lib/Support/CompilerEngine.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/compiler/lib/Support/CompilerEngine.cpp b/compiler/lib/Support/CompilerEngine.cpp index 03ac0f26f..82874abe2 100644 --- a/compiler/lib/Support/CompilerEngine.cpp +++ b/compiler/lib/Support/CompilerEngine.cpp @@ -176,7 +176,7 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) { if (smHandler.verify().failed()) return StreamStringError("Verification of diagnostics failed"); else - return res; + return std::move(res); } if (!mlirModuleRef) { @@ -187,13 +187,13 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) { mlir::ModuleOp module = res.mlirModuleRef->get(); if (target == Target::ROUND_TRIP) - return res; + return std::move(res); // HLFHE High level pass to determine FHE parameters if (auto err = this->determineFHEParameters(res)) return std::move(err); if (target == Target::HLFHE) - return res; + return std::move(res); // HLFHE -> MidLFHE if (mlir::zamalang::pipeline::lowerHLFHEToMidLFHE(mlirContext, module, @@ -202,7 +202,7 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) { return errorDiag("Lowering from HLFHE to MidLFHE failed"); } if (target == Target::MIDLFHE) - return res; + return std::move(res); // MidLFHE -> LowLFHE if (mlir::zamalang::pipeline::lowerMidLFHEToLowLFHE( @@ -211,7 +211,7 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) { return errorDiag("Lowering from MidLFHE to LowLFHE failed"); } if (target == Target::LOWLFHE) - return res; + return std::move(res); // LowLFHE -> Canonical dialects if (mlir::zamalang::pipeline::lowerLowLFHEToStd(mlirContext, module, @@ -220,7 +220,7 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) { return errorDiag("Lowering from LowLFHE to canonical MLIR dialects failed"); } if (target == Target::STD) - return res; + return std::move(res); // Generate client parameters if requested if (this->generateClientParameters) { @@ -252,7 +252,7 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) { } if (target == Target::LLVM) - return res; + return std::move(res); // Lowering to actual LLVM IR (i.e., not the LLVM dialect) llvm::LLVMContext &llvmContext = *this->compilationContext->getLLVMContext(); @@ -264,7 +264,7 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) { return StreamStringError("Failed to convert from LLVM dialect to LLVM IR"); if (target == Target::LLVM_IR) - return res; + return std::move(res); if (mlir::zamalang::pipeline::optimizeLLVMModule(llvmContext, *res.llvmModule) .failed()) { @@ -272,7 +272,7 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) { } if (target == Target::OPTIMIZED_LLVM_IR) - return res; + return std::move(res); if (target == Target::LIBRARY) { if (!lib) { @@ -283,10 +283,10 @@ CompilerEngine::compile(llvm::SourceMgr &sm, Target target, OptionalLib lib) { if (!objPath) { return StreamStringError(llvm::toString(objPath.takeError())); } - return res; + return std::move(res); } - return res; + return std::move(res); } // Compile the source `s` to the target dialect `target`. If successful, the