[llvm-commits] [llvm] r57408 - /llvm/trunk/lib/Analysis/EscapeAnalysis.cpp
Owen Anderson
resistor at mac.com
Sat Oct 11 23:03:40 PDT 2008
Author: resistor
Date: Sun Oct 12 01:03:38 2008
New Revision: 57408
URL: http://llvm.org/viewvc/llvm-project?rev=57408&view=rev
Log:
Fix crashes and infinite loops.
Modified:
llvm/trunk/lib/Analysis/EscapeAnalysis.cpp
Modified: llvm/trunk/lib/Analysis/EscapeAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/EscapeAnalysis.cpp?rev=57408&r1=57407&r2=57408&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/EscapeAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/EscapeAnalysis.cpp Sun Oct 12 01:03:38 2008
@@ -48,6 +48,7 @@
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 @@
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;
More information about the llvm-commits
mailing list