The default invalidate method for analysis results is just looking
at the preserved state of the pass itself. It does not consider if
the analysis has an internal state that depend on other analyses.
Thus, we need to implement LoopAccessInfoManager::invalidate in order
to catch if LoopAccessAnalysis needs to be invalidated due to
transitive analyses such as AAManager is being invalidated. Otherwise
we might end up having references to an AAManager that is stale.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/Analysis/LoopAccessAnalysis/invalidation.ll | ||
---|---|---|
5 | That was to see what happened when having an explicit invalidation of access-info. I.e. that the new invalidate function returns true in the early "// If not, give up now." exit, so that my patch wasn't lacking the check previously made by the default invalidate function. Maybe nicer to extract that kind of test into a separate RUN-line? |
- Simplify return stmt in LoopAccessInfoManager::invalidate according to feedback.
- Use a separate RUN line in the test case to verify invalidata<access-info>.
- Reduce amount of CHECK:s in the test case. Don't think we need to verify what is going on with all other analyses. Better to make the CHECK:s focus on what is important for each sub-test.
llvm/test/Analysis/LoopAccessAnalysis/invalidation.ll | ||
---|---|---|
9–12 | I don't know why analyses tend to appear in different order (both when running and invalidating), e.g. when comparing an opt built using clang or with gcc. Maybe some set iteration that isn't guaranteeing iteration order. I've updated this patch to use a bit less DAG checks. I don't think it was important to check everything. But it is an interesting idea for the future to see if we can get it more consistent (lots of tests that are checking "Running analysis:" and "Invalidating analysis:" seem to use -DAG, which I think is a bit easy to forget when adding new tests). |
llvm/test/Analysis/LoopAccessAnalysis/invalidation.ll | ||
---|---|---|
9–12 | it's the order we call sub-analyses in LoopAccessAnalysis::run. the evaluation order of arguments is not necessarily consistent across all platforms. fetching them before the call to LoopAccessInfoManager should work (I've done that for other passes/analyses before) | |
38 | I was wondering if the order of invalidation is guaranteed to be consistent, and I think it is as long as the order we fetch analyses is consistent because AnalysisResultListT is a std::list |
llvm/test/Analysis/LoopAccessAnalysis/invalidation.ll | ||
---|---|---|
9–12 | Ok. That sounds like a reasonable cause. I'll fix that for LoopAccessAnalysis::run. | |
76 | Last I checked it was needed to get make the RUN on line 8 to crash. But since it crashes due to dangling references/pointers that might be a bit of a coincidence. In order to just validate that the pass manager is doing invalidations, then I think the actual IR isn't important at all (i.e. we could remove more things and not only the attributes). |
llvm/test/Analysis/LoopAccessAnalysis/invalidation.ll | ||
---|---|---|
9–12 | FWIW, I made a follow-up commit here: https://reviews.llvm.org/rG951a980dc7aa61b1d414e7d565166ee8071367c6 |