aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorJulian Nagele <j.nagele@apple.com>2024-12-31 10:24:48 +0100
committerGitHub <noreply@github.com>2024-12-31 09:24:48 +0000
commitf035351af785b7349ab7bcd55149c781ceca24cb (patch)
treed25d56d771ccbf413e023a9fea6c552f1ba2a43e /llvm/lib/Analysis/ScalarEvolution.cpp
parente3fe41cdf5583d3a2f7454c76fa5cadccdccaf22 (diff)
downloadllvm-f035351af785b7349ab7bcd55149c781ceca24cb.zip
llvm-f035351af785b7349ab7bcd55149c781ceca24cb.tar.gz
llvm-f035351af785b7349ab7bcd55149c781ceca24cb.tar.bz2
[SCEV] Make sure starting block is marked as visited when recursively collecting loop guards. (#120749)
When `collectFromBlock` is called without a predecessor (in particular for loops that don't have a unique predecessor outside the loop) we never start climbing the predecessor chain, and thus don't mark the starting block as visited. Fixes https://github.com/llvm/llvm-project/issues/120615.
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 8ab5602..b5668a1 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -15765,6 +15765,7 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
// original header.
// TODO: share this logic with isLoopEntryGuardedByCond.
unsigned NumCollectedConditions = 0;
+ VisitedBlocks.insert(Block);
std::pair<const BasicBlock *, const BasicBlock *> Pair(Pred, Block);
for (; Pair.first;
Pair = SE.getPredecessorWithUniqueSuccessorForBB(Pair.first)) {