mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-04 05:31:06 +00:00
Duncan convinced me that it's not possible to transform control-based escapes into
data-based ones. Just be conservative when analyzing control-based escapes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57400 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
99cbdff66c
commit
4382f62a05
@ -78,6 +78,11 @@ bool EscapeAnalysis::runOnFunction(Function& F) {
|
|||||||
// for malloc to alloca promotion.
|
// for malloc to alloca promotion.
|
||||||
} else if (isa<ReturnInst>(I)) {
|
} else if (isa<ReturnInst>(I)) {
|
||||||
EscapePoints.insert(I);
|
EscapePoints.insert(I);
|
||||||
|
|
||||||
|
// Branching on the value of a pointer may allow the value to escape through
|
||||||
|
// methods not discoverable via def-use chaining.
|
||||||
|
} else if(isa<BranchInst>(I) || isa<SwitchInst>(I)) {
|
||||||
|
EscapePoints.insert(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Are there any other possible escape points?
|
// FIXME: Are there any other possible escape points?
|
||||||
@ -93,19 +98,18 @@ bool EscapeAnalysis::runOnFunction(Function& F) {
|
|||||||
/// 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(AllocationInst* A) {
|
||||||
std::vector<Value*> worklist;
|
std::vector<Instruction*> worklist;
|
||||||
worklist.push_back(A);
|
worklist.push_back(A);
|
||||||
|
|
||||||
SmallPtrSet<Value*, 8> visited;
|
SmallPtrSet<Instruction*, 8> visited;
|
||||||
while (!worklist.empty()) {
|
while (!worklist.empty()) {
|
||||||
Value* curr = worklist.back();
|
Instruction* curr = worklist.back();
|
||||||
worklist.pop_back();
|
worklist.pop_back();
|
||||||
|
|
||||||
visited.insert(curr);
|
visited.insert(curr);
|
||||||
|
|
||||||
if (Instruction* CurrInst = dyn_cast<Instruction>(curr))
|
if (EscapePoints.count(curr))
|
||||||
if (EscapePoints.count(CurrInst))
|
return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
for (Instruction::use_iterator UI = curr->use_begin(), UE = curr->use_end();
|
for (Instruction::use_iterator UI = curr->use_begin(), UE = curr->use_end();
|
||||||
UI != UE; ++UI)
|
UI != UE; ++UI)
|
||||||
@ -116,13 +120,6 @@ bool EscapeAnalysis::escapes(AllocationInst* A) {
|
|||||||
// have been found to alias a global, so stores to them would have
|
// have been found to alias a global, so stores to them would have
|
||||||
// been in EscapePoints.
|
// been in EscapePoints.
|
||||||
worklist.push_back(cast<Instruction>(S->getPointerOperand()));
|
worklist.push_back(cast<Instruction>(S->getPointerOperand()));
|
||||||
} else if (isa<BranchInst>(U) || isa<SwitchInst>(U)) {
|
|
||||||
// Because branches on the pointer value can hide data dependencies,
|
|
||||||
// we need to track values that were generated by branching on the
|
|
||||||
// pointer (or some derived value). To do that, we push the block,
|
|
||||||
// whose uses will be the PHINodes that generate information based
|
|
||||||
// one it.
|
|
||||||
worklist.push_back(U->getParent());
|
|
||||||
} else
|
} else
|
||||||
worklist.push_back(U);
|
worklist.push_back(U);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user