From 94876527af8703273c523840cf41b00aaf85389b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 15 Sep 2006 17:24:45 +0000 Subject: [PATCH] revert previous two patches. They cause miscompilation of MultiSource/Applications/Burg git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30397 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/ArgumentPromotion.cpp | 36 +----------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index a929df05d88..5183d43bc7c 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -179,40 +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(Argument* Arg) { - std::vector Worklist; - Worklist.push_back(Arg->getParent()->begin()); - - std::set 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(I) || isa(I)) { - ContainsAccess = true; - break; - } - - if (ContainsAccess) continue; - - TerminatorInst* TI = BB->getTerminator(); - if (isa(TI) || isa(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. @@ -286,7 +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) && !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 -- 2.34.1