- Add checks for store. That is needed because GlobalsAA is called twice in the current pipeline with different sets of Function passes following it. However, the loads are eliminated using instcombine which happens everywhere. On the other hand, DeadStoreElimination is performed only once so by checking for store we'll be able to catch more cases when GlobalsAA is invalidated unintentionally.
- Add empty function above/below the test so that we don't depend on the relative order of instcombine/dead-store-elimination and the pass that invalidates the analysis (inside the same FunctionPassManager).
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
llvm/test/Transforms/PhaseOrdering/globalaa-retained.ll | ||
---|---|---|
9–14 ↗ | (On Diff #95127) | I think this comment is a bit hard to understand. Below I tried tweaking the comment a bit, so it's a bit easier to understand, just adding more words to point to key ideas needed to understand the comment. I've marked my additions between asterisks. ; *This test checks that a number of loads and stores are eliminated, that can only be eliminated based on GlobalsAA information. As such, it tests that GlobalsAA information is retained until the passes that perform this optimization, and it protects against accidentally dropping the GlobalsAA information earlier in the pipeline, which has happened a few times.* ; *GlobalsAA* invalidation might happen later in the pipeline than the ; optimization eliminating unnecessary loads/stores. ; *Since GlobalsAA is a module-level analysis, any FunctionPass invalidating the GlobalsAA information will affect FunctionPass pipelines that execute later. For example, assume a FunctionPass1 | FunctionPass2 pipeline and 2 functions to be processed: f1 and f2. Assume furthermore that FunctionPass1 uses GlobalsAA info to do an optimization, and FunctionPass2 invalidates GlobalsAA. Assume the function passes run in the following order: FunctionPass1(f1), FunctionPass2(f1), FunctionPass1(f2), FunctionPass2(f2). Then FunctionPass1 will not be able to optimize f2, since GlobalsAA will have been invalidated in FuntionPass2(f1). To try and also test this scenario, there is an empty function before and after * ; the function we're checking so that one of ; them will be processed by the whole set of FunctionPasses before @f. ; That will ensure *that if the invalidation happens, it happens* before the actual ; optimizations on @f start. Other than that, I'm just wondering if there are any guarantees that the pipeline couldn't process the functions in the order @f, @bar, @bar2? |
I have to note that after http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20170410/444886.html
[llvm] r300200 - Re-apply "[GVNHoist] Move GVNHoist to function simplification part of pipeline."
that test starts failing.
Does this mean that the test (if it had already been committed), would have found that r300200 breaks retaining GlobalsAA info; or is something wrong with the test?
Should GVNHoist be marked as preserving GlobalsAA? Or does it break GlobalsAA?
Yes, it would have found that. GVNHoist does not mark GlobalsAA as preserved. It most probably should but I'm not totally sure about that.