diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2017-05-25 07:15:09 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2017-05-25 07:15:09 +0000 |
commit | 4fde77f8f1a8e4482e69b6a7484bc7d1b99b3c0a (patch) | |
tree | 0236fd0d87eb6e838a866ea68f6be609fb2b324b /lib/Passes | |
parent | 2dcd120478d144853e24587ebad633e178dfae8c (diff) |
[PM] Teach the PGO instrumentation pasess to run GlobalDCE before
instrumenting code.
This is important in the new pass manager. The old pass manager's
inliner has a small DCE routine embedded within it. The new pass manager
relies on the actual GlobalDCE pass for this.
Without this patch, instrumentation profiling with the new PM results in
massive code bloat in the object files because the instrumentation
itself ends up preventing DCE from working to remove the code.
We should probably change the instrumentation (and/or DCE) so that we
can eliminate dead code even if instrumented, but we shouldn't even
spend the time generating instrumentation for that code so this still
seems like a good patch.
Differential Revision: https://reviews.llvm.org/D33535
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303845 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Passes')
-rw-r--r-- | lib/Passes/PassBuilder.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Passes/PassBuilder.cpp b/lib/Passes/PassBuilder.cpp index fb56a6f05d36..4845bd2957b3 100644 --- a/lib/Passes/PassBuilder.cpp +++ b/lib/Passes/PassBuilder.cpp @@ -437,6 +437,11 @@ static void addPGOInstrPasses(ModulePassManager &MPM, bool DebugLogging, MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPipeline))); } + // Delete anything that is now dead to make sure that we don't instrument + // dead code. Instrumentation can end up keeping dead code around and + // dramatically increase code size. + MPM.addPass(GlobalDCEPass()); + if (RunProfileGen) { MPM.addPass(PGOInstrumentationGen()); |