diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2009-04-15 06:23:41 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2009-04-15 06:23:41 +0000 |
commit | 300e36503ca6f0599d64d0e5d4705a1030dac6a1 (patch) | |
tree | a0672fb1b81cb3632304b6fd4e14e13acdd6fa03 | |
parent | 37a4d8dbbbf7d8c4ed368a65ce3e9308262aa1f6 (diff) |
Limit the number of times we're willing to chase pointers. Removes an O(n^2)
problem from instcombine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69151 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Value.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 499b936e29..af3f4e7078 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -365,6 +365,7 @@ Value *Value::getUnderlyingObject() { if (!isa<PointerType>(getType())) return this; Value *V = this; + unsigned MaxLookup = 6; do { if (Instruction *I = dyn_cast<Instruction>(V)) { if (!isa<BitCastInst>(I) && !isa<GetElementPtrInst>(I)) @@ -379,7 +380,8 @@ Value *Value::getUnderlyingObject() { return V; } assert(isa<PointerType>(V->getType()) && "Unexpected operand type!"); - } while (1); + } while (--MaxLookup); + return V; } /// DoPHITranslation - If this value is a PHI node with CurBB as its parent, |