summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/EscapeAnalysis.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-10-12 07:33:29 +0000
committerOwen Anderson <resistor@mac.com>2008-10-12 07:33:29 +0000
commitf2699bb57dcbdd37b874a8c2108efd2642d7387f (patch)
tree4d953cb584a6a835d87373976ca93a63f4238c47 /llvm/lib/Analysis/EscapeAnalysis.cpp
parent71cf4c440c1e905a0f2961efbf350ec4dcf31752 (diff)
downloadbcm5719-llvm-f2699bb57dcbdd37b874a8c2108efd2642d7387f.tar.gz
bcm5719-llvm-f2699bb57dcbdd37b874a8c2108efd2642d7387f.zip
Make Escape Analysis work for any pointer.
llvm-svn: 57412
Diffstat (limited to 'llvm/lib/Analysis/EscapeAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/EscapeAnalysis.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/EscapeAnalysis.cpp b/llvm/lib/Analysis/EscapeAnalysis.cpp
index 69dde4d7fdf..43bad29fb7d 100644
--- a/llvm/lib/Analysis/EscapeAnalysis.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud