diff options
author | Owen Anderson <resistor@mac.com> | 2008-10-12 06:03:38 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-10-12 06:03:38 +0000 |
commit | 5efff7735d358d64c92aec999f448d8054acd8ba (patch) | |
tree | 17d566113c42c9ccc5af5c583e795b74b7fc4184 /lib/Analysis/EscapeAnalysis.cpp | |
parent | 4382f62a05745dc70cec673131f40f77791fa56a (diff) |
Fix crashes and infinite loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57408 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/EscapeAnalysis.cpp')
-rw-r--r-- | lib/Analysis/EscapeAnalysis.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/Analysis/EscapeAnalysis.cpp b/lib/Analysis/EscapeAnalysis.cpp index a2579abff4..69dde4d7fd 100644 --- a/lib/Analysis/EscapeAnalysis.cpp +++ b/lib/Analysis/EscapeAnalysis.cpp @@ -48,6 +48,7 @@ bool EscapeAnalysis::runOnFunction(Function& F) { bool inserted = false; for (Function::arg_iterator AI = F.arg_begin(), AE = F.arg_end(); AI != AE; ++AI) { + if (!isa<PointerType>(AI->getType())) continue; AliasAnalysis::AliasResult R = AA.alias(Pointer, StoreSize, AI, ~0UL); if (R != AliasAnalysis::NoAlias) { EscapePoints.insert(S); @@ -102,26 +103,27 @@ bool EscapeAnalysis::escapes(AllocationInst* A) { worklist.push_back(A); SmallPtrSet<Instruction*, 8> visited; + visited.insert(A); while (!worklist.empty()) { Instruction* curr = worklist.back(); worklist.pop_back(); - visited.insert(curr); - if (EscapePoints.count(curr)) return true; - for (Instruction::use_iterator UI = curr->use_begin(), UE = curr->use_end(); - UI != UE; ++UI) - if (Instruction* U = dyn_cast<Instruction>(UI)) - if (!visited.count(U)) - if (StoreInst* S = dyn_cast<StoreInst>(U)) { - // We know this must be an instruction, because constant gep's would - // have been found to alias a global, so stores to them would have - // been in EscapePoints. - worklist.push_back(cast<Instruction>(S->getPointerOperand())); - } else + if (StoreInst* S = dyn_cast<StoreInst>(curr)) { + // We know this must be an instruction, because constant gep's would + // have been found to alias a global, so stores to them would have + // been in EscapePoints. + if (visited.insert(cast<Instruction>(S->getPointerOperand()))) + worklist.push_back(cast<Instruction>(S->getPointerOperand())); + } else { + for (Instruction::use_iterator UI = curr->use_begin(), + UE = curr->use_end(); UI != UE; ++UI) + if (Instruction* U = dyn_cast<Instruction>(UI)) + if (visited.insert(U)) worklist.push_back(U); + } } return false; |