[llvm] r243312 - [LAA] Split out a helper from addRuntimeCheck to generate the check, NFC
Adam Nemet
anemet at apple.com
Mon Jul 27 12:38:48 PDT 2015
Author: anemet
Date: Mon Jul 27 14:38:48 2015
New Revision: 243312
URL: http://llvm.org/viewvc/llvm-project?rev=243312&view=rev
Log:
[LAA] Split out a helper from addRuntimeCheck to generate the check, NFC
Modified:
llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h
llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp
Modified: llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h?rev=243312&r1=243311&r2=243312&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h Mon Jul 27 14:38:48 2015
@@ -384,6 +384,15 @@ public:
void groupChecks(MemoryDepChecker::DepCandidates &DepCands,
bool UseDependencies);
+ /// Generate the checks and return them.
+ ///
+ /// \p PtrToPartition contains the partition number for pointers. If passed,
+ /// omit checks between pointers belonging to the same partition. Partition
+ /// number -1 means that the pointer is used in multiple partitions. In this
+ /// case we can't safely omit the check.
+ SmallVector<PointerCheck, 4>
+ generateChecks(const SmallVectorImpl<int> *PtrPartition = nullptr) const;
+
/// \brief Decide if we need to add a check between two groups of pointers,
/// according to needsChecking.
bool needsChecking(const CheckingPtrGroup &M, const CheckingPtrGroup &N,
Modified: llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp?rev=243312&r1=243311&r2=243312&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp Mon Jul 27 14:38:48 2015
@@ -148,6 +148,23 @@ void RuntimePointerChecking::insert(Loop
Pointers.emplace_back(Ptr, ScStart, ScEnd, WritePtr, DepSetId, ASId, Sc);
}
+SmallVector<RuntimePointerChecking::PointerCheck, 4>
+RuntimePointerChecking::generateChecks(
+ const SmallVectorImpl<int> *PtrPartition) const {
+ SmallVector<PointerCheck, 4> Checks;
+
+ for (unsigned i = 0; i < CheckingGroups.size(); ++i) {
+ for (unsigned j = i + 1; j < CheckingGroups.size(); ++j) {
+ const RuntimePointerChecking::CheckingPtrGroup &CGI = CheckingGroups[i];
+ const RuntimePointerChecking::CheckingPtrGroup &CGJ = CheckingGroups[j];
+
+ if (needsChecking(CGI, CGJ, PtrPartition))
+ Checks.push_back(std::make_pair(&CGI, &CGJ));
+ }
+ }
+ return Checks;
+}
+
bool RuntimePointerChecking::needsChecking(
const CheckingPtrGroup &M, const CheckingPtrGroup &N,
const SmallVectorImpl<int> *PtrPartition) const {
@@ -1708,20 +1725,7 @@ std::pair<Instruction *, Instruction *>
if (!PtrRtChecking.Need)
return std::make_pair(nullptr, nullptr);
- SmallVector<RuntimePointerChecking::PointerCheck, 4> Checks;
- for (unsigned i = 0; i < PtrRtChecking.CheckingGroups.size(); ++i) {
- for (unsigned j = i + 1; j < PtrRtChecking.CheckingGroups.size(); ++j) {
- const RuntimePointerChecking::CheckingPtrGroup &CGI =
- PtrRtChecking.CheckingGroups[i];
- const RuntimePointerChecking::CheckingPtrGroup &CGJ =
- PtrRtChecking.CheckingGroups[j];
-
- if (PtrRtChecking.needsChecking(CGI, CGJ, PtrPartition))
- Checks.push_back(std::make_pair(&CGI, &CGJ));
- }
- }
-
- return addRuntimeCheck(Loc, Checks);
+ return addRuntimeCheck(Loc, PtrRtChecking.generateChecks(PtrPartition));
}
LoopAccessInfo::LoopAccessInfo(Loop *L, ScalarEvolution *SE,
More information about the llvm-commits
mailing list