From: Florian Hahn Date: Tue, 23 Nov 2021 22:47:26 +0000 (+0000) Subject: [LAA] Move visitPointers up in file (NFC). X-Git-Tag: upstream/15.0.7~24948 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=73a05cc8dfa114e29cd4d463c77a5577571c8c56;p=platform%2Fupstream%2Fllvm.git [LAA] Move visitPointers up in file (NFC). This allows easier re-use in earlier functions. --- diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 66826e2..d007181 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -666,6 +666,29 @@ static bool isNoWrap(PredicatedScalarEvolution &PSE, return false; } +static void visitPointers(Value *StartPtr, const Loop &InnermostLoop, + function_ref AddPointer) { + SmallPtrSet Visited; + SmallVector WorkList; + WorkList.push_back(StartPtr); + + while (!WorkList.empty()) { + Value *Ptr = WorkList.pop_back_val(); + if (!Visited.insert(Ptr).second) + continue; + auto *PN = dyn_cast(Ptr); + // SCEV does not look through non-header PHIs inside the loop. Such phis + // can be analyzed by adding separate accesses for each incoming pointer + // value. + if (PN && InnermostLoop.contains(PN->getParent()) && + PN->getParent() != InnermostLoop.getHeader()) { + for (const Use &Inc : PN->incoming_values()) + WorkList.push_back(Inc); + } else + AddPointer(Ptr); + } +} + bool AccessAnalysis::createCheckForAccess(RuntimePointerChecking &RtCheck, MemAccessInfo Access, const ValueToValueMap &StridesMap, @@ -1256,29 +1279,6 @@ bool llvm::isConsecutiveAccess(Value *A, Value *B, const DataLayout &DL, return Diff && *Diff == 1; } -static void visitPointers(Value *StartPtr, const Loop &InnermostLoop, - function_ref AddPointer) { - SmallPtrSet Visited; - SmallVector WorkList; - WorkList.push_back(StartPtr); - - while (!WorkList.empty()) { - Value *Ptr = WorkList.pop_back_val(); - if (!Visited.insert(Ptr).second) - continue; - auto *PN = dyn_cast(Ptr); - // SCEV does not look through non-header PHIs inside the loop. Such phis - // can be analyzed by adding separate accesses for each incoming pointer - // value. - if (PN && InnermostLoop.contains(PN->getParent()) && - PN->getParent() != InnermostLoop.getHeader()) { - for (const Use &Inc : PN->incoming_values()) - WorkList.push_back(Inc); - } else - AddPointer(Ptr); - } -} - void MemoryDepChecker::addAccess(StoreInst *SI) { visitPointers(SI->getPointerOperand(), *InnermostLoop, [this, SI](Value *Ptr) {