[llvm-commits] [llvm] r57412 - in /llvm/trunk: include/llvm/Analysis/EscapeAnalysis.h lib/Analysis/EscapeAnalysis.cpp
Owen Anderson
resistor at mac.com
Sun Oct 12 00:33:33 PDT 2008
Author: resistor
Date: Sun Oct 12 02:33:29 2008
New Revision: 57412
URL: http://llvm.org/viewvc/llvm-project?rev=57412&view=rev
Log:
Make Escape Analysis work for any pointer.
Modified:
llvm/trunk/include/llvm/Analysis/EscapeAnalysis.h
llvm/trunk/lib/Analysis/EscapeAnalysis.cpp
Modified: llvm/trunk/include/llvm/Analysis/EscapeAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/EscapeAnalysis.h?rev=57412&r1=57411&r2=57412&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/EscapeAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/EscapeAnalysis.h Sun Oct 12 02:33:29 2008
@@ -50,8 +50,9 @@
//===---------------------------------------------------------------------
// Client API
- /// escapes - returns true if the AllocationInst can escape.
- bool escapes(AllocationInst* A);
+ /// escapes - returns true if the value, which must have a pointer type,
+ /// can escape.
+ bool escapes(Value* A);
};
} // end llvm namespace
Modified: llvm/trunk/lib/Analysis/EscapeAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/EscapeAnalysis.cpp?rev=57412&r1=57411&r2=57412&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/EscapeAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/EscapeAnalysis.cpp Sun Oct 12 02:33:29 2008
@@ -98,18 +98,22 @@
/// 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
More information about the llvm-commits
mailing list