[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:13:24 PDT 2017


george.burgess.iv added a comment.

Thanks for the patch!



================
Comment at: lib/Analysis/MemorySSAUpdater.cpp:126
     } else {
       // Otherwise, have to walk the all access iterator.
       auto Iter = MA->getReverseIterator();
----------------
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.


https://reviews.llvm.org/D33950





More information about the llvm-commits mailing list