[PATCH] D95026: [SimplifyCFG] Update FoldBranchToCommonDest to be poison-safe
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 9 12:40:04 PST 2021
aqjune added a comment.
I could reproduce the failures from two-stage build and submitted a bug report: https://bugs.llvm.org/show_bug.cgi?id=49495
Consider this code snippet:
vector<ty> v; // empty
ty* b = v.begin(), *e = v.end()
if (b != e && b < (e - 1))
// reverse items in [b, e)
After the patch, LLVM was optimizing it into
vector<ty> v; // empty
ty* b = v.begin(), *e = v.end()
if (b < (e - 1))
// reverse items in [b, e)
But this is wrong. Since v is empty, v.begin() and v.end() can return NULL. `e - 1` raises overflow, hence the branch is taken, which is wrong.
PopulateLoopsDFS<llvm::BasicBlock, llvm::Loop>::insertIntoLoop was containing a code snippet that looked like this.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95026/new/
https://reviews.llvm.org/D95026
More information about the llvm-commits
mailing list