This is an archive of the discontinued LLVM Phabricator instance.

Make globalaa-retained.ll test catching more cases.
ClosedPublic

Authored by a.elovikov on Apr 13 2017, 8:02 AM.

Details

Summary
  • 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).

Diff Detail

Repository
rL LLVM

Event Timeline

a.elovikov created this revision.Apr 13 2017, 8:02 AM
kristof.beyls added inline comments.Apr 14 2017, 12:45 AM
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.
Is the comment still valid? If so, I think it'll be easier to understand.

; *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?

a.elovikov updated this revision to Diff 95278.Apr 14 2017, 2:08 AM
  • Make the comment more detailed.
a.elovikov marked an inline comment as done.Apr 14 2017, 2:09 AM
kristof.beyls accepted this revision.Apr 14 2017, 2:32 AM

LGTM, Thanks!

This revision is now accepted and ready to land.Apr 14 2017, 2:32 AM

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.

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?

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.

This revision was automatically updated to reflect the committed changes.