[PATCH] D30344: [MemorySSA] Add OptimizeUses flag

Daniel Berlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 28 05:37:25 PST 2017


dberlin added a comment.

In https://reviews.llvm.org/D30344#686639, @Prazek wrote:

> In https://reviews.llvm.org/D30344#686088, @dberlin wrote:
>
> > Can't you just  call setDefiningAccess on the uses in question to set them?
>
>
> Not sure what do you mean, so I will describe it with more details with new resaon.


i mean if the uses are getting optimized, you can just reset them to their original access.

> I want to have separate list (or other strusture) having only memory accesses with invariant group.

I'm not strongly opposed, but it'd have to have a good reason.
This strikes me as invariant.group possibly not being well designed if we have to do this to make it work well in something that actually wants to process them en-masse.
But i'll set that aside.

> I would like to make a unit test to check if getClobberingAccess returns the best memory def without help of OptimizeUses.

Okay.

So just call setDefiningAccess on the use and reset it to the nearest store.

> creating instructions, building mssa, then setting up invariant group attributes, and then calling getClobberingAccess won't work, because the link list for invariant groups will be empty

The optimal way to test would seem to me to be:
create instructions, add invariant group attributes, build memoryssa, store away,what things optimized, reset defining access on each load to nearest store, call get clobbering access, compare that we got exactly same result as we did before.

THis verifies both ways give the same results.

What am i missing?

> other way is to create mssa; create instructions with invariant group; insert each instruction into mssa; then call getClobberingAccess, but this seems to be more painfull, than just:

Why is this more painful?
It's almost certainly <100 lines of code, and even then, can be done trivially with a simpler helper function.

> create instructions with invariant group; create mssa WITHOUT optimizing uses; test getClobberingAccess

Except you aren't testing a thing that a user would use here?
You are also basically embedded strong knowledge about MSSA into your test.
What if i added a trivial  optimizer during renaming or otherwise change the linking?
Now your test breaks.
Whereas, if you take the "painful" approach, it just always works.
Or if you just set the test up to be the way you want it, using setDefiningAccess, it will also always work.

I would strongly prefer one of these two methods over trying to control, internally, for testing, what memoryssa does, with flags you pass during building it.


https://reviews.llvm.org/D30344





More information about the llvm-commits mailing list