From 8e0cf1874d5c1176fae53a400f1adb0b6c1d1694 Mon Sep 17 00:00:00 2001 From: Andreas Jonson Date: Sun, 17 Sep 2017 22:17:28 +0200 Subject: [PATCH] remove inlined functions for faster compilation after inlining remove functions that is not called any more reduces compile times due to the removed functions is not further optimized. --- lib/Transforms/IPO/PassManagerBuilder.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/Transforms/IPO/PassManagerBuilder.cpp b/lib/Transforms/IPO/PassManagerBuilder.cpp index 6d0071d4f60a..fabef9d146fd 100644 --- a/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -475,10 +475,14 @@ void PassManagerBuilder::populateModulePassManager( // Start of CallGraph SCC passes. if (!DisableUnitAtATime) MPM.add(createPruneEHPass()); // Remove dead EH info + + bool RunInliner = false; if (Inliner) { MPM.add(Inliner); Inliner = nullptr; + RunInliner = true; } + if (!DisableUnitAtATime) MPM.add(createPostOrderFunctionAttrsLegacyPass()); if (OptLevel > 2) @@ -492,6 +496,17 @@ void PassManagerBuilder::populateModulePassManager( // we must insert a no-op module pass to reset the pass manager. MPM.add(createBarrierNoopPass()); + // 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. + if (RunInliner) { + MPM.add(createGlobalOptimizerPass()); + MPM.add(createGlobalDCEPass()); + } + if (!DisableUnitAtATime && OptLevel > 1 && !PrepareForLTO && !PrepareForThinLTO) // Remove avail extern fns and globals definitions if we aren't