summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-08-31 03:22:32 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-08-31 03:22:32 +0000
commita90e51e10682e6c425364fea4ae9c154292ecf7b (patch)
tree99a8b1ecb1cbb6b002fec7f6c8affbb51983be48
parent54f18e8a857094a608e63924d38d51b5964f2eab (diff)
downloadbcm5719-llvm-a90e51e10682e6c425364fea4ae9c154292ecf7b.tar.gz
bcm5719-llvm-a90e51e10682e6c425364fea4ae9c154292ecf7b.zip
[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. llvm-svn: 280191
-rw-r--r--llvm/lib/Analysis/Loads.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp
index 4837ccfc230..af7ccb9dfc9 100644
--- a/llvm/lib/Analysis/Loads.cpp
+++ b/llvm/lib/Analysis/Loads.cpp
@@ -55,6 +55,10 @@ static bool isDereferenceableAndAlignedPointer(
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 isDereferenceableAndAlignedPointer(
// 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);
}
OpenPOWER on IntegriCloud