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

George Burgess IV via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 13:14:21 PDT 2017


george.burgess.iv 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:
> 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();```


https://reviews.llvm.org/D33950





More information about the llvm-commits mailing list