Skip to content

Commit

Permalink
fix(compiler): do not optimize llvm twice
Browse files Browse the repository at this point in the history
  • Loading branch information
rudy-6-4 committed Sep 8, 2023
1 parent 74c4a7e commit 229bbc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 229bbc2

Please sign in to comment.