[PATCH] D45889: [MemCpyOpt] Do not iterate beyond beginning of basic block

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 20 11:49:34 PDT 2018


bjope added a comment.

In https://reviews.llvm.org/D45889#1073834, @efriedma wrote:

> This sort of thing gets very confusing; it would be better to explicitly reject unreachable blocks in MemCpyOptPass::iterateOnFunction.


Ok. I'm not so familiar with this code and is not 100% sure that this only happens for unreachable blocks.
The processStore method can be invoked for store instructions that is first in reachable blocks as well, right? It was not obvious to me that we never could end up doing the `--SI->getIterator()` also for reachable code.
Maybe the check for that `LI->getParent() == SI->getParent()` and `LoadInst *LI = dyn_cast<LoadInst>(SI->getOperand(0))` somehow will guarantee that.
But how is it guaranteed that `C` always is before `SI` when entering the loop?

I can try to add something in MemCpyOptPass::iterateOnFunction to avoid optimizing in non-reachable blocks instead. And then maybe I can add some asserts in processStore to show that SI can't be first in the BB somewhere before doing  `--SI->getIterator()`.


Repository:
  rL LLVM

https://reviews.llvm.org/D45889





More information about the llvm-commits mailing list