[PATCH] D51486: Add check to Latch's terminator in UnrollRuntimeLoopRemainder

Rodrigo Caetano Rocha via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 30 08:11:33 PDT 2018


rcorcs added a comment.

Sorry, I'll make sure to upload with a full context in the next time.

The comment partially covers my concern.

The comment and the assertion that you've pointed out only covers the case where the latch block has a conditional branch that does not exit the loop.
However, if the latch block has an unconditional branch, then it will break in the command LatchBR->getSuccessor(ExitIndex) with an out of range assertion.

Since the latch has an unconditional branch, it means that:

- LatchBR->getSuccessor(0) == Header, and then ExitIndex will be 1.
- but LatchBR has no successor at position 1.

The way I see it, the two problems are related.

For this reason, I think that it would be better if we catch both cases of malformed loops.

But since the comment that you mention says that "This needs to be guaranteed by the callers of UnrollRuntimeLoopRemainder",
I guess it would be better to handle it with an assertion instead of return false (as I suggested in this patch).

If you agree with my point, I can update the patch with the assertion (instead of return false).

Thanks for the feedback.


Repository:
  rL LLVM

https://reviews.llvm.org/D51486





More information about the llvm-commits mailing list