[all-commits] [llvm/llvm-project] 73b951: [SCEV] Clarify requirements for zero-stride to be UB
Philip Reames via All-commits
all-commits at lists.llvm.org
Wed Sep 1 14:01:27 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 73b951a7f7dc07be37bcb3d545d228098c4e19f4
https://github.com/llvm/llvm-project/commit/73b951a7f7dc07be37bcb3d545d228098c4e19f4
Author: Philip Reames <listmail at philipreames.com>
Date: 2021-09-01 (Wed, 01 Sep 2021)
Changed paths:
M llvm/lib/Analysis/ScalarEvolution.cpp
Log Message:
-----------
[SCEV] Clarify requirements for zero-stride to be UB
There's a silent bug in our reasoning about zero strides. We assume that having a single static exit implies that if that exit is not taken, then the loop must be infinite. This ignores the potential for abnormal exits via exceptions. Consider the following example:
for (uint_8 i = 0; i < 1; i += 0) {
throw_on_thousandth_call();
}
Our reasoning is such that we'd conclude this loop can't take the backedge as that would lead to a (presumed) infinite loop.
In practice, this is a silent bug because the loopIsFiniteByAssumption returns false strictly more often than the loopHaNoAbnormalExits property. We could reasonable want to change that in the future, so fixing the codeflow now is worthwhile.
Differential Revision: https://reviews.llvm.org/D109029
More information about the All-commits
mailing list