From cb18bfa3d2fbfab3e880ce639db4247db8c07552 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 27 Dec 2010 18:39:08 +0000 Subject: fix some issues Frits noticed, add AliasAnalysis as a dependency llvm-svn: 122585 --- llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | 24 ++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index f8748efecea..476cb284bae 100644 --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -15,6 +15,7 @@ #define DEBUG_TYPE "loop-idiom" #include "llvm/Transforms/Scalar.h" +#include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/ScalarEvolutionExpressions.h" #include "llvm/Analysis/ScalarEvolutionExpander.h" @@ -59,6 +60,8 @@ namespace { AU.addPreservedID(LoopSimplifyID); AU.addRequiredID(LCSSAID); AU.addPreservedID(LCSSAID); + AU.addRequired(); + AU.addPreserved(); AU.addRequired(); AU.addPreserved(); AU.addPreserved(); @@ -73,6 +76,7 @@ INITIALIZE_PASS_DEPENDENCY(LoopInfo) INITIALIZE_PASS_DEPENDENCY(LoopSimplify) INITIALIZE_PASS_DEPENDENCY(LCSSA) INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) +INITIALIZE_AG_DEPENDENCY(AliasAnalysis) INITIALIZE_PASS_END(LoopIdiomRecognize, "loop-idiom", "Recognize loop idioms", false, false) @@ -141,13 +145,15 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L, LPPassManager &LPM) { StoreInst *SI = dyn_cast(I++); if (SI == 0 || SI->isVolatile()) continue; - WeakVH InstPtr; - if (processLoopStore(SI, BECount)) { - // If processing the store invalidated our iterator, start over from the - // head of the loop. - if (InstPtr == 0) - I = BB->begin(); - } + WeakVH InstPtr(SI); + if (!processLoopStore(SI, BECount)) continue; + + MadeChange = true; + + // If processing the store invalidated our iterator, start over from the + // head of the loop. + if (InstPtr == 0) + I = BB->begin(); } return MadeChange; @@ -204,6 +210,10 @@ processLoopStoreOfSplatValue(StoreInst *SI, unsigned StoreSize, // would be unsafe to do if there is anything else in the loop that may read // or write to the aliased location. Check for an alias. + // FIXME: Need to get a base pointer that is valid. + // if (LoopCanModRefLocation(SI->getPointerOperand()) + + // FIXME: TODO safety check. // Okay, everything looks good, insert the memset. -- cgit v1.2.3