SCEV's loop and block disposition caches are a mess. Loop disposition has
a public method to be called to external users when it may break, but for
some reason is not called from forgetLoop. Block disposition does not even
have API for this. So it may be (and actually is) broken.
It should not be a responsibility of transform passes to know what caches SCEV
has or how they work. It's enough that have API to forgetLoop and forgetValue
that allow to signal that something might have changed.
In this patch, we regain full control of SCEV over its disposition caches. Accessor
methods are moved to private API and are now called from forgetLoop and
forgetValue. It might be tad more conservative than needed, but it's a lesser evil
compared to the broken state we now have.
It may have a negative compile time impact. Though, it shouldn't really be a problem:
typically passes tend to make all queries first and only then do the IR changes, so we
should at least enjoy full power of caching while querying.
This looks like a really big hammer that goes against how SCEV invalidation normally works. Note that the loop above is supposed to walk all SCEVs based on the value and calls forgetMemoizedResults() for them -- this includes clearing the loop and block dispositions.