fix(compiler): do not optimize llvm twice

This commit is contained in:
rudy
2023-09-08 14:46:14 +02:00
committed by rudy-6-4
parent 74c4a7eae5
commit 229bbc2327
2 changed files with 4 additions and 1 deletions

View File

@@ -148,6 +148,7 @@ llvm::Error emitObject(llvm::Module &module, string objectPath) {
// https://llvm.org/docs/NewPassManager.html#status-of-the-new-and-legacy-pass-managers
llvm::legacy::PassManager pm;
auto FileType = llvm::CGFT_ObjectFile;
targetMachine->setOptLevel(llvm::CodeGenOpt::Level::Aggressive);
if (targetMachine->addPassesToEmitFile(pm, objectFile->os(), nullptr,
FileType, false)) {
return StreamStringError("TheTargetMachine can't emit object file");

View File

@@ -527,8 +527,10 @@ lowerLLVMDialectToLLVMIR(mlir::MLIRContext &context,
mlir::LogicalResult optimizeLLVMModule(llvm::LLVMContext &llvmContext,
llvm::Module &module) {
// -O3 is done LLVMEmitFile.cpp
auto optLevel = llvm::CodeGenOpt::None;
std::function<llvm::Error(llvm::Module *)> optPipeline =
mlir::makeOptimizingTransformer(3, 0, nullptr);
mlir::makeOptimizingTransformer(optLevel, 0, nullptr);
if (optPipeline(&module))
return mlir::failure();