Fix LCSSA increased compile time
authorRong Xu <xur@google.com>
Wed, 10 Aug 2016 17:49:11 +0000 (17:49 +0000)
committerRong Xu <xur@google.com>
Wed, 10 Aug 2016 17:49:11 +0000 (17:49 +0000)
commit63f970ee2484d39782cb9686fdeca00d55e866ca
tree180a0e50c405b4d02856c84af5cda425457f20e9
parent2dc5645b946c8fc3c9cf59b9c9c8515c4e62e807
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
llvm/lib/Transforms/Utils/LCSSA.cpp