[PATCH] This patch introduces MemorySSA, a virtual SSA form for memory.Details on what it looks like are in MemorySSA.h

Philip Reames listmail at philipreames.com
Mon Apr 13 16:41:10 PDT 2015


On 04/13/2015 04:32 PM, Daniel Berlin wrote:
>>>> ================
>>>> Comment at: lib/Transforms/Utils/MemorySSA.cpp:942
>>>> @@ +941,3 @@
>>>> +  // Don't try to walk past an incomplete phi node during construction
>>>> +  if (P->getNumIncomingValues() != P->getNumPreds())
>>>> +    return std::make_pair(P, false);
>>>> ----------------
>>>> Er, huh?  How can this happen?  And should it?
>>> So, we use the caching walker during construction to optimize the uses
>>> on MemoryUse's.
>>> Depending on where the backedges are, you have no guarantee you won't
>>> hit a PHI node whose operands are not completely filled in yet,
>>> because the standard SSA rename algorithm is  top-down, and depth
>>> first, not breadth first  (so along one branch, you check if your
>>> successors have phi node, and if so, fill in your open operand.   Then
>>> you go to your successors, who may want to make queries involving that
>>> phi node, but not all operands are filled in because the renamer
>>> hasn't gotten to the *other* branch yet)
>>>
>>> Even if we made it breadth first, my gut tells me you can construct a
>>> CFG with backedges that will end up with not all operands filled in at
>>> some query point.
>> A clear comment in function description which says it has to handle
>> partially constructed memssa would be very helpful.  I understand why you
>> want this, but it really makes me wince.
>>
>> Any chance the optimization could be done via a lazy fixup after
>> construction?  Just a though.  (Not as part of this change though!)
>>
> So it can be done by fixup, at a cost of walking the memory accesses again.
> The only way to do it with *lazy* fixup would be to make the walkers
> modify the IR as they are walking it.
> Currently they are readonly.
> Honestly, that idea scares the hell out of me, so i'd rather either
> accept that we may walk partially constructed phi nodes during
> construction, or do at as a memory-access walk after construction.
Given your response, I'll discard that random idea.  :)  Dealing with 
the partially constructed graph isn't bad provided we're clear about it.

Philip



More information about the llvm-commits mailing list