diff options
author | Dan Gohman <gohman@apple.com> | 2010-06-28 21:16:52 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-06-28 21:16:52 +0000 |
commit | 50f424c3d079d4774bb323de1e0b77cf4627be69 (patch) | |
tree | cf16075a9b993fb4d2ae431eebba08aa00e1a5a6 /lib/VMCore/Value.cpp | |
parent | 08baddbc0708d6965b72b40aa3c1f40b56a31835 (diff) |
Fix Value::stripPointerCasts and BasicAA to avoid trouble on
code in unreachable blocks, which have have use-def cycles.
This fixes PR7514.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107071 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Value.cpp')
-rw-r--r-- | lib/VMCore/Value.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 645dd5a21c..585edf09c9 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -322,7 +322,13 @@ void Value::replaceAllUsesWith(Value *New) { Value *Value::stripPointerCasts() { if (!getType()->isPointerTy()) return this; + + // Even though we don't look through PHI nodes, we could be called on an + // instruction in an unreachable block, which may be on a cycle. + SmallPtrSet<Value *, 4> Visited; + Value *V = this; + Visited.insert(V); do { if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) { if (!GEP->hasAllZeroIndices()) @@ -338,7 +344,9 @@ Value *Value::stripPointerCasts() { return V; } assert(V->getType()->isPointerTy() && "Unexpected operand type!"); - } while (1); + } while (Visited.insert(V)); + + return V; } Value *Value::getUnderlyingObject(unsigned MaxLookup) { |