This is a short term solution to the problem that many passes currently fail
to update the assumption cache. In the long term the verifier should not
be controllable with a flag. We should either fix all passes to correctly
update the assumption cache and enable the verifier unconditionally or
somehow arrange for the assumption list to be updated automatically by passes.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I guess I'm late to the party here, but checking my assumptions (no pun intended!) -- if AssumptionCacheTracker::verifyAnalysis fails after a pass Frobnicate then we're in a situation where opt -frobnicate -other-pass may have different behavior than opt -frobnicate | opt -other-pass (assuming other-pass uses AssumptionCache), right? If so, that's troubling.
While i agree it's troubling, it's interesting to note that we have that behavior elsewhere.
For example memdep caches, but not in a way that invalidates fully.
Thus, opt -gvn -gvn will give different answers than opt -gvn | opt -gvn
both are "correct" answers, just the former is more conservative than the latter.
Yeah, SCEV also has this property. So do several other analyses IIRC. =[
I'm not thrilled about making it worse, and we have a PR tracking this. My current best idea is to pull this up into a function analysis that can actually be invalidated. We can trivially make the new PM work this way today, and with some work could probably get it to work in the old PM as well.
(There remains the meta discussion of whether an analysis invalidation strategy to be conservatively correct is the most efficient approach or we should do something else, but even if we decide to do something else that seems significantly longer term to me.)
(There remains the meta discussion of whether an analysis invalidation strategy to be conservatively correct is the most efficient approach or we should do something else, but even if we decide to do something else that seems significantly longer term to me.)
FWIW: GCC computes aliasing exactly twice, and only does conservative updates in between.
It beats us in precision :)
SO i'm not worried on the memdepish front. AC i'd be more worried about.
Yea, the problem is: do you prefer different answers or an assertion failure. We discussed on IRC that Peter found a number of places where we already don't update the cache and, thus, only luck was preventing hitting asserts later. We should use the flag introduced in this pass to search out and fix these things, but in the mean time, we shouldn't trouble our users with assertion failures.
We should use the flag introduced in this pass to search out and fix these things, but in the mean time, we shouldn't trouble our users with assertion failures.
[realized after writing: I guess this is what @chandlerc said above?]
The other option would be to not make it an ImmutablePass and instead treat it like an analysis that gets preserved explicitly.
Btw, in WritingAnLLVMPass.rst ImmutablePass is described as "that do not have to be run, do not change state, and never need to be updated". That means either AC is not an ImmutablePass or the definition of an immutable pass needs to be relaxed.
llvm/trunk/include/llvm/Analysis/AssumptionCache.h | ||
---|---|---|
171 | "The nature of the AssumptionCache is that it is not invalidated by any changes to the function body" no longer seems accurate. Since forgetting to update the AC (after cloning) will fail "verification", perhaps we should either state that cloning will invalidate AC or avoid calling the thing we do later "verification"? |
"The nature of the AssumptionCache is that it is not invalidated by any changes to the function body" no longer seems accurate.
Since forgetting to update the AC (after cloning) will fail "verification", perhaps we should either state that cloning will invalidate AC or avoid calling the thing we do later "verification"?