diff --git a/llvm/lib/Target/EVM/EVMTargetMachine.cpp b/llvm/lib/Target/EVM/EVMTargetMachine.cpp index eaf0892de5ff..8e28d24346b6 100644 --- a/llvm/lib/Target/EVM/EVMTargetMachine.cpp +++ b/llvm/lib/Target/EVM/EVMTargetMachine.cpp @@ -26,6 +26,7 @@ #include "llvm/MC/TargetRegistry.h" #include "llvm/Passes/PassBuilder.h" #include "llvm/Transforms/IPO/GlobalDCE.h" +#include "llvm/Transforms/Scalar/MergeIdenticalBB.h" #include "llvm/Transforms/Utils.h" using namespace llvm; @@ -115,6 +116,11 @@ void EVMTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { PM.addPass(GlobalDCEPass()); PM.addPass(createModuleToFunctionPassAdaptor(EVMAllocaHoistingPass())); }); + PB.registerScalarOptimizerLateEPCallback( + [](FunctionPassManager &PM, OptimizationLevel Level) { + if (Level.getSizeLevel() || Level.getSpeedupLevel() > 1) + PM.addPass(MergeIdenticalBBPass()); + }); } namespace {