[PATCH] D25542: GVN-hoist: avoid calling MemoryLocation::get() on a call (PR30499)
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 12 20:40:48 PDT 2016
(as an aside, Hal, i'd love your opinion on whether MemoryLocation should
really be something that handles calls as well. Or, alternatively, at
least getModRefInfo uses something that does without people having to know
If we used something like MemoryLocOrCall [obviously this is just a simple
union class]), we could simplify parts of the AA API. I also wouldn't
need it to hack around things in the AA API's getModRefInfo.
Right now we have this artificial distinction where we have things that use
pointers get MemoryLocations, other things get ImmutableCallSites. This
kinda makes sense for alias() (though more advanced aa's are just
implementing that in terms of mod ref info they have created).
However, the current AA API operates on both *anyway*, and the overloads
you get are confusing.
IE we have:
You pretty much can't use getModRefInfo right now unless you check whether
the instructions you are trying to get mod ref info about are 0, 1, or 2
calls. Because calls don't have memorylocs, so you can't just always call
::get on them.
You then have to call the right overloads yourself.
That seems wrong.
(I'll ignore the fact that you also have to check whether you are holding a
fence inst, since you can't get memorylocations for those either, and ::get
will just crash. )
Right now the number of overloads is also ... high, and while we fixed the
last immediate problem i remember (where random things would get overloaded
to ImmutableCallSite versions when they weren't calls), staring at the
number of getModRefInfo overloads, i'm not sure i believe the way we have
it structured makes sense.
On Wed, Oct 12, 2016 at 8:26 PM, Daniel Berlin <dberlin at dberlin.org> wrote:
> You can get rid of UseInst too, MemoryLocOrCall will take a MemoryUse
> directly :)
> On Wed, Oct 12, 2016 at 8:20 PM, Sebastian Pop <sebpop at gmail.com> wrote:
>> On Wed, Oct 12, 2016 at 10:05 PM, Daniel Berlin <dberlin at dberlin.org>
>> > There is actually a much simpler fix you sholdl use.
>> > return instructionClobbersQuery(MD, MU MemoryLocOrCall(MU), AA);
>> > You need to move that version of instructionClobbersQuery up, but it was
>> > built to always do the right thing.
>> > Also note it will properly handle a case you are not: Fences do not have
>> > memorylocations, and calling get on them will also crash.
>> Right. I will commit the attached patch after testing.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-commits