diff options
author | Owen Anderson <resistor@mac.com> | 2008-10-12 07:33:29 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-10-12 07:33:29 +0000 |
commit | 4b089929b4cfa4b3ca7ad6a79db5c60b73012755 (patch) | |
tree | 955b80b1a2d26f96954b95f280449176c4bafe9f /lib/Analysis/EscapeAnalysis.cpp | |
parent | 36b708a3188cd02909d102c26ec6c251147890d7 (diff) |
Make Escape Analysis work for any pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/EscapeAnalysis.cpp')
-rw-r--r-- | lib/Analysis/EscapeAnalysis.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Analysis/EscapeAnalysis.cpp b/lib/Analysis/EscapeAnalysis.cpp index 69dde4d7fd..43bad29fb7 100644 --- a/lib/Analysis/EscapeAnalysis.cpp +++ b/lib/Analysis/EscapeAnalysis.cpp @@ -98,18 +98,22 @@ bool EscapeAnalysis::runOnFunction(Function& F) { /// escape point. /// FIXME: Once we've discovered a path, it would be a good idea to memoize it, /// and all of its subpaths, to amortize the cost of future queries. -bool EscapeAnalysis::escapes(AllocationInst* A) { - std::vector<Instruction*> worklist; +bool EscapeAnalysis::escapes(Value* A) { + assert(isa<PointerType>(A->getType()) && + "Can't do escape analysis on non-pointer types!"); + + std::vector<Value*> worklist; worklist.push_back(A); - SmallPtrSet<Instruction*, 8> visited; + SmallPtrSet<Value*, 8> visited; visited.insert(A); while (!worklist.empty()) { - Instruction* curr = worklist.back(); + Value* curr = worklist.back(); worklist.pop_back(); - if (EscapePoints.count(curr)) - return true; + if (Instruction* I = dyn_cast<Instruction>(curr)) + if (EscapePoints.count(I)) + return true; if (StoreInst* S = dyn_cast<StoreInst>(curr)) { // We know this must be an instruction, because constant gep's would |