Index: lib/Transforms/IPO/PassManagerBuilder.cpp =================================================================== --- lib/Transforms/IPO/PassManagerBuilder.cpp +++ lib/Transforms/IPO/PassManagerBuilder.cpp @@ -502,6 +502,15 @@ if (Inliner) { MPM.add(Inliner); Inliner = nullptr; + + // The inliner performs some kind of dead code elimination as it goes, + // but there are cases that are not really caught by it. We might + // at some point consider teaching the inliner about them, but it + // is OK for now to run GlobalOpt + GlobalDCE in tandem as their + // benefits generally outweight the cost, making the whole pipeline + // faster. See PR34652. + PM.add(createGlobalOptimizerPass()); + PM.add(createGlobalDCEPass()); } if (!DisableUnitAtATime) MPM.add(createPostOrderFunctionAttrsLegacyPass());