[llvm] r280191 - [Loads] Properly populate the visited set in isDereferenceableAndAlignedPointer
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 30 20:22:32 PDT 2016
Author: majnemer
Date: Tue Aug 30 22:22:32 2016
New Revision: 280191
URL: http://llvm.org/viewvc/llvm-project?rev=280191&view=rev
Log:
[Loads] Properly populate the visited set in isDereferenceableAndAlignedPointer
There were paths where we wouldn't populate the visited set, causing us
to recurse forever if an SSA variable was defined in terms of itself.
This fixes PR30210.
Modified:
llvm/trunk/lib/Analysis/Loads.cpp
Modified: llvm/trunk/lib/Analysis/Loads.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Loads.cpp?rev=280191&r1=280190&r2=280191&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Loads.cpp (original)
+++ llvm/trunk/lib/Analysis/Loads.cpp Tue Aug 30 22:22:32 2016
@@ -55,6 +55,10 @@ static bool isDereferenceableAndAlignedP
const Value *V, unsigned Align, const APInt &Size, const DataLayout &DL,
const Instruction *CtxI, const DominatorTree *DT,
SmallPtrSetImpl<const Value *> &Visited) {
+ // Already visited? Bail out, we've likely hit unreachable code.
+ if (!Visited.insert(V).second)
+ return false;
+
// Note that it is not safe to speculate into a malloc'd region because
// malloc may return null.
@@ -87,8 +91,7 @@ static bool isDereferenceableAndAlignedP
// then the GEP (== Base + Offset == k_0 * Align + k_1 * Align) is also
// aligned to Align bytes.
- return Visited.insert(Base).second &&
- isDereferenceableAndAlignedPointer(Base, Align, Offset + Size, DL,
+ return isDereferenceableAndAlignedPointer(Base, Align, Offset + Size, DL,
CtxI, DT, Visited);
}
More information about the llvm-commits
mailing list