Go to file
Chandler Carruth 2f1fd1658f [PM] Port ScalarEvolution to the new pass manager.
This change makes ScalarEvolution a stand-alone object and just produces
one from a pass as needed. Making this work well requires making the
object movable, using references instead of overwritten pointers in
a number of places, and other refactorings.

I've also wired it up to the new pass manager and added a RUN line to
a test to exercise it under the new pass manager. This includes basic
printing support much like with other analyses.

But there is a big and somewhat scary change here. Prior to this patch
ScalarEvolution was never *actually* invalidated!!! Re-running the pass
just re-wired up the various other analyses and didn't remove any of the
existing entries in the SCEV caches or clear out anything at all. This
might seem OK as everything in SCEV that can uses ValueHandles to track
updates to the values that serve as SCEV keys. However, this still means
that as we ran SCEV over each function in the module, we kept
accumulating more and more SCEVs into the cache. At the end, we would
have a SCEV cache with every value that we ever needed a SCEV for in the
entire module!!! Yowzers. The releaseMemory routine would dump all of
this, but that isn't realy called during normal runs of the pipeline as
far as I can see.

To make matters worse, there *is* actually a key that we don't update
with value handles -- there is a map keyed off of Loop*s. Because
LoopInfo *does* release its memory from run to run, it is entirely
possible to run SCEV over one function, then over another function, and
then lookup a Loop* from the second function but find an entry inserted
for the first function! Ouch.

To make matters still worse, there are plenty of updates that *don't*
trip a value handle. It seems incredibly unlikely that today GVN or
another pass that invalidates SCEV can update values in *just* such
a way that a subsequent run of SCEV will incorrectly find lookups in
a cache, but it is theoretically possible and would be a nightmare to
debug.

With this refactoring, I've fixed all this by actually destroying and
recreating the ScalarEvolution object from run to run. Technically, this
could increase the amount of malloc traffic we see, but then again it is
also technically correct. ;] I don't actually think we're suffering from
tons of malloc traffic from SCEV because if we were, the fact that we
never clear the memory would seem more likely to have come up as an
actual problem before now. So, I've made the simple fix here. If in fact
there are serious issues with too much allocation and deallocation,
I can work on a clever fix that preserves the allocations (while
clearing the data) between each run, but I'd prefer to do that kind of
optimization with a test case / benchmark that shows why we need such
cleverness (and that can test that we actually make it faster). It's
possible that this will make some things faster by making the SCEV
caches have higher locality (due to being significantly smaller) so
until there is a clear benchmark, I think the simple change is best.

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

llvm-svn: 245193
2015-08-17 02:08:17 +00:00
clang Enable passing test on Windows + MSYS. 2015-08-16 19:02:49 +00:00
clang-tools-extra clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp: Tweak not to override -std=c++11. 2015-08-15 02:27:22 +00:00
compiler-rt Fixup stale comment about supported OSs 2015-08-14 20:01:27 +00:00
debuginfo-tests New round of fixes for "Always compile debuginfo-tests for the host triple" 2014-10-18 23:47:59 +00:00
libclc Remove files accidentally not removed in r244310 2015-08-13 23:43:12 +00:00
libcxx Fix CMake error whet llvm-config reports a non-existent source directory. 2015-08-12 06:36:19 +00:00
libcxxabi Update to new lists.llvm.org 2015-08-05 04:01:26 +00:00
libunwind Enable zero-cost exceptions on non-Apple arm64 platforms 2015-08-13 14:21:03 +00:00
lld ELF: Also record the type of undefined symbols. 2015-08-14 16:46:28 +00:00
lldb Try to fix the lldb build on Visual C++. 2015-08-16 19:40:40 +00:00
llgo Update to new lists.llvm.org 2015-08-05 04:03:05 +00:00
llvm [PM] Port ScalarEvolution to the new pass manager. 2015-08-17 02:08:17 +00:00
openmp Remove unused KMP_SETVERSION macro 2015-08-13 15:26:38 +00:00
polly Add 2nd test case for sdiv/srem instructions in a SCEV 2015-08-16 19:53:21 +00:00