[PATCH] D33950: [mssa] If there is no definition in a block prior to an inserted use, return nullptr.

Daniel Berlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 13:39:59 PDT 2017


dberlin added inline comments.


================
Comment at: lib/Analysis/MemorySSAUpdater.cpp:126
     } else {
       // Otherwise, have to walk the all access iterator.
       auto Iter = MA->getReverseIterator();
----------------
george.burgess.iv wrote:
> george.burgess.iv wrote:
> > If we instead refactor this else block to look something like:
> > 
> > ```
> > auto End = getWritableBlockAccesses()->rend();
> > for (auto &U : make_range(++MA->getReverseIterator(), End))
> >   if (!isa<MemoryUse>(U))
> >     return cast<MemoryAccess>(&U);
> > // Note that if MA comes before Defs->begin(), we won't hit a def.
> > return nullptr;
> > ```
> > 
> > does that still fix the problem?
> > 
> > Personally, I feel like that's clearer about the intent, and is probably less prone to edge-cases.
> Oops; I meant:
> 
> ```auto End = getWritableBlockAccesses(MA->getBlock())->rend();```
I was going to suggest the same thing george did :)



https://reviews.llvm.org/D33950





More information about the llvm-commits mailing list