aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-10-03 07:26:07 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-10-03 07:26:07 +0000
commit99435d32b3318f1b2f593f484ea9ba26804bf56c (patch)
tree10e057f6588fb75649e761ded770e99e23a279f6
parentf7da4e939f02678cbe56cae666506da3b1a5e100 (diff)
Revert previous patch. Still breaking things.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30698 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp50
1 files changed, 1 insertions, 49 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index a3ebc65f12..5183d43bc7 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -179,53 +179,6 @@ static bool AllCalleesPassInValidPointerForArgument(Argument *Arg) {
return true;
}
-/// AccessOccursOnPath - Returns true if and only if a load or GEP instruction
-/// on Pointer occurs in Path, or in every control-flow path that succeeds it.
-bool AccessOccursOnPath(Value* V, BasicBlock* Start) {
- std::vector<BasicBlock*> Worklist;
- Worklist.push_back(Start);
-
- std::set<BasicBlock*> Visited;
-
- while (!Worklist.empty()) {
- BasicBlock* BB = Worklist.back();
- Worklist.pop_back();
- Visited.insert(BB);
-
- bool ContainsAccess = false;
- for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
- if (isa<LoadInst>(I)) {
- for (Instruction::op_iterator OI = I->op_begin(), OE = I->op_end(); OI != OE; ++OI)
- if (*OI == V) {
- ContainsAccess = true;
- break;
- }
- } else if (isa<GetElementPtrInst>(I)) {
- for (Instruction::op_iterator OI = I->op_begin(), OE = I->op_end(); OI != OE; ++OI)
- if (*OI == V) {
- ContainsAccess = AccessOccursOnPath(I, I->getParent());
- break;
- }
- }
-
- if (ContainsAccess)
- break;
- }
-
- if (ContainsAccess) continue;
-
- TerminatorInst* TI = BB->getTerminator();
- if (isa<BranchInst>(TI) || isa<SwitchInst>(TI)) {
- for (unsigned i = 0; i < TI->getNumSuccessors(); ++i)
- if (!Visited.count(TI->getSuccessor(i)))
- Worklist.push_back(TI->getSuccessor(i));
- } else {
- return false;
- }
- }
-
- return true;
-}
/// isSafeToPromoteArgument - As you might guess from the name of this method,
/// it checks to see if it is both safe and useful to promote the argument.
@@ -299,8 +252,7 @@ bool ArgPromotion::isSafeToPromoteArgument(Argument *Arg) const {
// of the pointer in the entry block of the function) or if we can prove that
// all pointers passed in are always to legal locations (for example, no null
// pointers are passed in, no pointers to free'd memory, etc).
- if (!AccessOccursOnPath(Arg, Arg->getParent()->begin()) &&
- !AllCalleesPassInValidPointerForArgument(Arg))
+ if (!HasLoadInEntryBlock && !AllCalleesPassInValidPointerForArgument(Arg))
return false; // Cannot prove that this is safe!!
// Okay, now we know that the argument is only used by load instructions and