[llvm] fa4b518 - [BasicAA] Guard against empty successors list (PR59360)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 6 07:59:09 PST 2022
Author: Nikita Popov
Date: 2022-12-06T16:59:00+01:00
New Revision: fa4b518f1d644d60a68639af77386fc925faf8d9
URL: https://github.com/llvm/llvm-project/commit/fa4b518f1d644d60a68639af77386fc925faf8d9
DIFF: https://github.com/llvm/llvm-project/commit/fa4b518f1d644d60a68639af77386fc925faf8d9.diff
LOG: [BasicAA] Guard against empty successors list (PR59360)
Succs can be empty here if a phi predecessor is unreachable.
Fixes https://github.com/llvm/llvm-project/issues/59360
Added:
Modified:
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Analysis/BasicAA/phi-aa.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index e70be0f20d4c0..2b552bf974063 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1671,7 +1671,8 @@ bool BasicAAResult::isValueEqualInPotentialCycles(const Value *V,
// block can (non-trivially) reach itself.
BasicBlock *BB = const_cast<BasicBlock *>(Inst->getParent());
SmallVector<BasicBlock *> Succs(successors(BB));
- return !isPotentiallyReachableFromMany(Succs, BB, nullptr, DT);
+ return !Succs.empty() &&
+ !isPotentiallyReachableFromMany(Succs, BB, nullptr, DT);
}
/// Computes the symbolic
diff erence between two de-composed GEPs.
diff --git a/llvm/test/Analysis/BasicAA/phi-aa.ll b/llvm/test/Analysis/BasicAA/phi-aa.ll
index 799bf5b2d3fd5..f9d61a60e4697 100644
--- a/llvm/test/Analysis/BasicAA/phi-aa.ll
+++ b/llvm/test/Analysis/BasicAA/phi-aa.ll
@@ -246,3 +246,21 @@ join:
load i32, i32* %gep3
ret void
}
+
+; Don't crash with an unreachable predecessor.
+; CHECK-LABEL: pr59360
+; CHECK: MayAlias: i32* %loaded.ptr, i32* %phi
+define void @pr59360() {
+entry:
+ br label %outer
+
+loopexit: ; No predecessors!
+ br label %outer
+
+outer: ; preds = %loopexit, %entry
+ %phi = phi i32* [ %loaded.ptr, %loopexit ], [ null, %entry ]
+ store i32 0, i32* %phi, align 4
+ %loaded.ptr = load i32*, i32** null, align 8
+ %0 = load i32, i32* %loaded.ptr, align 4
+ ret void
+}
More information about the llvm-commits
mailing list