From 300e36503ca6f0599d64d0e5d4705a1030dac6a1 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Wed, 15 Apr 2009 06:23:41 +0000 Subject: [PATCH] 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 --- lib/VMCore/Value.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 499b936e29c..af3f4e70784 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -365,6 +365,7 @@ Value *Value::getUnderlyingObject() { if (!isa(getType())) return this; Value *V = this; + unsigned MaxLookup = 6; do { if (Instruction *I = dyn_cast(V)) { if (!isa(I) && !isa(I)) @@ -379,7 +380,8 @@ Value *Value::getUnderlyingObject() { return V; } assert(isa(V->getType()) && "Unexpected operand type!"); - } while (1); + } while (--MaxLookup); + return V; } /// DoPHITranslation - If this value is a PHI node with CurBB as its parent,