[llvm] 73a05cc - [LAA] Move visitPointers up in file (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 23 14:55:07 PST 2021
Author: Florian Hahn
Date: 2021-11-23T22:47:26Z
New Revision: 73a05cc8dfa114e29cd4d463c77a5577571c8c56
URL: https://github.com/llvm/llvm-project/commit/73a05cc8dfa114e29cd4d463c77a5577571c8c56
DIFF: https://github.com/llvm/llvm-project/commit/73a05cc8dfa114e29cd4d463c77a5577571c8c56.diff
LOG: [LAA] Move visitPointers up in file (NFC).
This allows easier re-use in earlier functions.
Added:
Modified:
llvm/lib/Analysis/LoopAccessAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 66826e22f8e3..d007181c09c3 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) {
More information about the llvm-commits
mailing list