mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 05:29:24 +00:00
Make Escape Analysis work for any pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57412 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
36b708a318
commit
4b089929b4
@ -50,8 +50,9 @@ public:
|
|||||||
//===---------------------------------------------------------------------
|
//===---------------------------------------------------------------------
|
||||||
// Client API
|
// Client API
|
||||||
|
|
||||||
/// escapes - returns true if the AllocationInst can escape.
|
/// escapes - returns true if the value, which must have a pointer type,
|
||||||
bool escapes(AllocationInst* A);
|
/// can escape.
|
||||||
|
bool escapes(Value* A);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end llvm namespace
|
} // end llvm namespace
|
||||||
|
@ -98,18 +98,22 @@ bool EscapeAnalysis::runOnFunction(Function& F) {
|
|||||||
/// escape point.
|
/// escape point.
|
||||||
/// FIXME: Once we've discovered a path, it would be a good idea to memoize it,
|
/// 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.
|
/// and all of its subpaths, to amortize the cost of future queries.
|
||||||
bool EscapeAnalysis::escapes(AllocationInst* A) {
|
bool EscapeAnalysis::escapes(Value* A) {
|
||||||
std::vector<Instruction*> worklist;
|
assert(isa<PointerType>(A->getType()) &&
|
||||||
|
"Can't do escape analysis on non-pointer types!");
|
||||||
|
|
||||||
|
std::vector<Value*> worklist;
|
||||||
worklist.push_back(A);
|
worklist.push_back(A);
|
||||||
|
|
||||||
SmallPtrSet<Instruction*, 8> visited;
|
SmallPtrSet<Value*, 8> visited;
|
||||||
visited.insert(A);
|
visited.insert(A);
|
||||||
while (!worklist.empty()) {
|
while (!worklist.empty()) {
|
||||||
Instruction* curr = worklist.back();
|
Value* curr = worklist.back();
|
||||||
worklist.pop_back();
|
worklist.pop_back();
|
||||||
|
|
||||||
if (EscapePoints.count(curr))
|
if (Instruction* I = dyn_cast<Instruction>(curr))
|
||||||
return true;
|
if (EscapePoints.count(I))
|
||||||
|
return true;
|
||||||
|
|
||||||
if (StoreInst* S = dyn_cast<StoreInst>(curr)) {
|
if (StoreInst* S = dyn_cast<StoreInst>(curr)) {
|
||||||
// We know this must be an instruction, because constant gep's would
|
// We know this must be an instruction, because constant gep's would
|
||||||
|
Loading…
Reference in New Issue
Block a user