mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-12 03:32:10 +00:00
Fix crashes and infinite loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57408 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4382f62a05
commit
5efff7735d
@ -48,6 +48,7 @@ bool EscapeAnalysis::runOnFunction(Function& F) {
|
|||||||
bool inserted = false;
|
bool inserted = false;
|
||||||
for (Function::arg_iterator AI = F.arg_begin(), AE = F.arg_end();
|
for (Function::arg_iterator AI = F.arg_begin(), AE = F.arg_end();
|
||||||
AI != AE; ++AI) {
|
AI != AE; ++AI) {
|
||||||
|
if (!isa<PointerType>(AI->getType())) continue;
|
||||||
AliasAnalysis::AliasResult R = AA.alias(Pointer, StoreSize, AI, ~0UL);
|
AliasAnalysis::AliasResult R = AA.alias(Pointer, StoreSize, AI, ~0UL);
|
||||||
if (R != AliasAnalysis::NoAlias) {
|
if (R != AliasAnalysis::NoAlias) {
|
||||||
EscapePoints.insert(S);
|
EscapePoints.insert(S);
|
||||||
@ -102,26 +103,27 @@ bool EscapeAnalysis::escapes(AllocationInst* A) {
|
|||||||
worklist.push_back(A);
|
worklist.push_back(A);
|
||||||
|
|
||||||
SmallPtrSet<Instruction*, 8> visited;
|
SmallPtrSet<Instruction*, 8> visited;
|
||||||
|
visited.insert(A);
|
||||||
while (!worklist.empty()) {
|
while (!worklist.empty()) {
|
||||||
Instruction* curr = worklist.back();
|
Instruction* curr = worklist.back();
|
||||||
worklist.pop_back();
|
worklist.pop_back();
|
||||||
|
|
||||||
visited.insert(curr);
|
|
||||||
|
|
||||||
if (EscapePoints.count(curr))
|
if (EscapePoints.count(curr))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (Instruction::use_iterator UI = curr->use_begin(), UE = curr->use_end();
|
if (StoreInst* S = dyn_cast<StoreInst>(curr)) {
|
||||||
UI != UE; ++UI)
|
// We know this must be an instruction, because constant gep's would
|
||||||
if (Instruction* U = dyn_cast<Instruction>(UI))
|
// have been found to alias a global, so stores to them would have
|
||||||
if (!visited.count(U))
|
// been in EscapePoints.
|
||||||
if (StoreInst* S = dyn_cast<StoreInst>(U)) {
|
if (visited.insert(cast<Instruction>(S->getPointerOperand())))
|
||||||
// We know this must be an instruction, because constant gep's would
|
worklist.push_back(cast<Instruction>(S->getPointerOperand()));
|
||||||
// have been found to alias a global, so stores to them would have
|
} else {
|
||||||
// been in EscapePoints.
|
for (Instruction::use_iterator UI = curr->use_begin(),
|
||||||
worklist.push_back(cast<Instruction>(S->getPointerOperand()));
|
UE = curr->use_end(); UI != UE; ++UI)
|
||||||
} else
|
if (Instruction* U = dyn_cast<Instruction>(UI))
|
||||||
|
if (visited.insert(U))
|
||||||
worklist.push_back(U);
|
worklist.push_back(U);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user