[LegacyPassManager] Reduce memory usage for AnalysisUsage
authorPhilip Reames <listmail@philipreames.com>
Fri, 4 Dec 2015 20:05:04 +0000 (20:05 +0000)
committerPhilip Reames <listmail@philipreames.com>
Fri, 4 Dec 2015 20:05:04 +0000 (20:05 +0000)
commit697fe024f6dad16e21c9b8e41bb27463971939c0
treed18fff812ad5410c1401a8b9f6f319aad2913ddf
parentc57a70c32743e51e0823918a0f6fdcd60c14a0ca
[LegacyPassManager] Reduce memory usage for AnalysisUsage

The LegacyPassManager was storing an instance of AnalysisUsage for each instance of each pass. In practice, most instances of a single pass class share the same dependencies. We can't rely on this because passes can (and some do) have dynamic dependencies based on instance options.

We can exploit the likely commonality by uniqueing the usage information after querying the pass, but before storing it into the pass manager. This greatly reduces memory consumption by the AnalysisUsage objects. For a long pass pipeline, I measured a decrease in memory consumption for this storage of about 50%. I have not measured on the default O3 pipeline, but I suspect it will see some benefit as well since many passes are repeated (e.g. InstCombine).

Differential Revision: http://reviews.llvm.org/D14677

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254760 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/LegacyPassManagers.h
lib/IR/LegacyPassManager.cpp