diff options
author | Florian Hahn <flo@fhahn.com> | 2021-11-23 22:47:26 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2021-11-23 22:47:26 +0000 |
commit | 73a05cc8dfa114e29cd4d463c77a5577571c8c56 (patch) | |
tree | 515839aacd1a990eb331814db3cfb9fedc2dfa6d /llvm/lib/Analysis/LoopAccessAnalysis.cpp | |
parent | 877433ad453cd1bd77497ec47828074b6e010edb (diff) | |
download | llvm-73a05cc8dfa114e29cd4d463c77a5577571c8c56.zip llvm-73a05cc8dfa114e29cd4d463c77a5577571c8c56.tar.gz llvm-73a05cc8dfa114e29cd4d463c77a5577571c8c56.tar.bz2 |
[LAA] Move visitPointers up in file (NFC).
This allows easier re-use in earlier functions.
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopAccessAnalysis.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
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<void(Value *)> AddPointer) { + SmallPtrSet<Value *, 8> Visited; + SmallVector<Value *> WorkList; + WorkList.push_back(StartPtr); + + while (!WorkList.empty()) { + Value *Ptr = WorkList.pop_back_val(); + if (!Visited.insert(Ptr).second) + continue; + auto *PN = dyn_cast<PHINode>(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<void(Value *)> AddPointer) { - SmallPtrSet<Value *, 8> Visited; - SmallVector<Value *> WorkList; - WorkList.push_back(StartPtr); - - while (!WorkList.empty()) { - Value *Ptr = WorkList.pop_back_val(); - if (!Visited.insert(Ptr).second) - continue; - auto *PN = dyn_cast<PHINode>(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) { |