diff options
author | Dan Gohman <gohman@apple.com> | 2010-11-08 20:26:19 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-11-08 20:26:19 +0000 |
commit | 142ff82a185d223b41d2b5f67f63aea1c312d258 (patch) | |
tree | a5c603d27b6e8d77fdeaea2e58d5a1ec9837aa9e /llvm/lib/Analysis/BasicAliasAnalysis.cpp | |
parent | 2a9221793ac686ac249211b4ff4b48eddfd2458f (diff) | |
download | bcm5719-llvm-142ff82a185d223b41d2b5f67f63aea1c312d258.tar.gz bcm5719-llvm-142ff82a185d223b41d2b5f67f63aea1c312d258.zip |
Re-introduce the MaxLookup limit to BasicAliasAnalysis'
pointsToConstantMemory code to guard against possible
compile time slowdowns.
llvm-svn: 118440
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index db493eeedca..73114fe5aab 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -524,6 +524,7 @@ bool BasicAliasAnalysis::pointsToConstantMemory(const Location &Loc, bool OrLocal) { assert(Visited.empty() && "Visited must be cleared after use!"); + unsigned MaxLookup = 8; SmallVector<const Value *, 16> Worklist; Worklist.push_back(Loc.Ptr); do { @@ -559,6 +560,11 @@ BasicAliasAnalysis::pointsToConstantMemory(const Location &Loc, bool OrLocal) { // If all values incoming to a phi node point to local memory, then so does // the phi. if (const PHINode *PN = dyn_cast<PHINode>(V)) { + // Don't bother inspecting phi nodes with many operands. + if (PN->getNumIncomingValues() > MaxLookup) { + Visited.clear(); + return AliasAnalysis::pointsToConstantMemory(Loc, OrLocal); + } for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) Worklist.push_back(PN->getIncomingValue(i)); continue; @@ -568,10 +574,10 @@ BasicAliasAnalysis::pointsToConstantMemory(const Location &Loc, bool OrLocal) { Visited.clear(); return AliasAnalysis::pointsToConstantMemory(Loc, OrLocal); - } while (!Worklist.empty()); + } while (!Worklist.empty() && --MaxLookup); Visited.clear(); - return true; + return Worklist.empty(); } /// getModRefBehavior - Return the behavior when calling the given call site. |