diff options
author | Rong Xu <xur@google.com> | 2016-08-10 17:49:11 +0000 |
---|---|---|
committer | Rong Xu <xur@google.com> | 2016-08-10 17:49:11 +0000 |
commit | 63f970ee2484d39782cb9686fdeca00d55e866ca (patch) | |
tree | 180a0e50c405b4d02856c84af5cda425457f20e9 /llvm/lib/Transforms/Utils/LCSSA.cpp | |
parent | 2dc5645b946c8fc3c9cf59b9c9c8515c4e62e807 (diff) | |
download | llvm-63f970ee2484d39782cb9686fdeca00d55e866ca.zip llvm-63f970ee2484d39782cb9686fdeca00d55e866ca.tar.gz llvm-63f970ee2484d39782cb9686fdeca00d55e866ca.tar.bz2 |
Fix LCSSA increased compile time
We are seeing r276077 drastically increasing compiler time for our larger
benchmarks in PGO profile generation build (both clang based and IR based
mode) -- it can be 20x slower than without the patch (like from 30 secs to
780 secs)
The increased time are all in pass LCSSA. The problematic code is about
PostProcessPHIs after use-rewrite. Note that the InsertedPhis from ssa_updater
is accumulating (never been cleared). Since the inserted PHIs are added to the
candidate for each rewrite, The earlier ones will be repeatedly added. Later
when adding the new PHIs to the work-list, we don't check the duplication
either. This can result in extremely long work-list that containing tons of
duplicated PHIs.
This patch fixes the issue by hoisting the code out of the loop.
Differential Revision: http://reviews.llvm.org/D23344
llvm-svn: 278250
Diffstat (limited to 'llvm/lib/Transforms/Utils/LCSSA.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LCSSA.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/LCSSA.cpp b/llvm/lib/Transforms/Utils/LCSSA.cpp index 8071df6..d15c15a 100644 --- a/llvm/lib/Transforms/Utils/LCSSA.cpp +++ b/llvm/lib/Transforms/Utils/LCSSA.cpp @@ -186,14 +186,14 @@ bool llvm::formLCSSAForInstructions(SmallVectorImpl<Instruction *> &Worklist, // Otherwise, do full PHI insertion. SSAUpdate.RewriteUse(*UseToRewrite); + } - // SSAUpdater might have inserted phi-nodes inside other loops. We'll need - // to post-process them to keep LCSSA form. - for (PHINode *InsertedPN : InsertedPHIs) { - if (auto *OtherLoop = LI.getLoopFor(InsertedPN->getParent())) - if (!L->contains(OtherLoop)) - PostProcessPHIs.push_back(InsertedPN); - } + // SSAUpdater might have inserted phi-nodes inside other loops. We'll need + // to post-process them to keep LCSSA form. + for (PHINode *InsertedPN : InsertedPHIs) { + if (auto *OtherLoop = LI.getLoopFor(InsertedPN->getParent())) + if (!L->contains(OtherLoop)) + PostProcessPHIs.push_back(InsertedPN); } // Post process PHI instructions that were inserted into another disjoint |