[Polly][PATCH] Use reference to clarify pointer can never be null
Tobias Grosser
tobias at grosser.es
Sat Apr 18 06:47:38 PDT 2015
---
include/polly/ScopDetection.h | 2 +-
include/polly/TempScopInfo.h | 2 +-
lib/Analysis/ScopDetection.cpp | 7 ++-----
lib/Analysis/ScopInfo.cpp | 4 ++--
lib/Analysis/TempScopInfo.cpp | 16 +++++++---------
5 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/include/polly/ScopDetection.h b/include/polly/ScopDetection.h
index 492634a..47edc2c 100644
--- a/include/polly/ScopDetection.h
+++ b/include/polly/ScopDetection.h
@@ -334,7 +334,7 @@ public:
bool isMaxRegionInScop(const Region &R, bool Verify = true) const;
/// @brief Return the set of loops in non-affine subregions for @p R.
- const BoxedLoopsSetTy *getBoxedLoops(const Region *R) const;
+ const BoxedLoopsSetTy &getBoxedLoops(const Region *R) const;
/// @brief Return true if @p SubR is a non-affine subregion in @p ScopR.
bool isNonAffineSubRegion(const Region *SubR, const Region *ScopR) const;
diff --git a/include/polly/TempScopInfo.h b/include/polly/TempScopInfo.h
index f37b052..6c1d62b 100644
--- a/include/polly/TempScopInfo.h
+++ b/include/polly/TempScopInfo.h
@@ -266,7 +266,7 @@ class TempScopInfo : public FunctionPass {
/// @return The IRAccess to describe the access function of the
/// instruction.
IRAccess buildIRAccess(Instruction *Inst, Loop *L, Region *R,
- const ScopDetection::BoxedLoopsSetTy *BoxedLoops);
+ const ScopDetection::BoxedLoopsSetTy &BoxedLoops);
/// @brief Analyze and extract the cross-BB scalar dependences (or,
/// dataflow dependencies) of an instruction.
diff --git a/lib/Analysis/ScopDetection.cpp b/lib/Analysis/ScopDetection.cpp
index a0385a6..28ea895 100644
--- a/lib/Analysis/ScopDetection.cpp
+++ b/lib/Analysis/ScopDetection.cpp
@@ -1037,12 +1037,9 @@ bool ScopDetection::isNonAffineSubRegion(const Region *SubR,
return NonAffineSubRegionMap.lookup(ScopR).count(SubR);
}
-const ScopDetection::BoxedLoopsSetTy *
+const ScopDetection::BoxedLoopsSetTy &
ScopDetection::getBoxedLoops(const Region *R) const {
- auto BLMIt = BoxedLoopsMap.find(R);
- if (BLMIt == BoxedLoopsMap.end())
- return nullptr;
- return &BLMIt->second;
+ return BoxedLoopsMap.find(R)->second;
}
void polly::ScopDetection::verifyRegion(const Region &R) const {
diff --git a/lib/Analysis/ScopInfo.cpp b/lib/Analysis/ScopInfo.cpp
index 911c662..3583bcc 100644
--- a/lib/Analysis/ScopInfo.cpp
+++ b/lib/Analysis/ScopInfo.cpp
@@ -1630,14 +1630,14 @@ bool Scop::buildAliasGroups(AliasAnalysis &AA) {
static unsigned getMaxLoopDepthInRegion(const Region &R, LoopInfo &LI,
ScopDetection &SD) {
- const ScopDetection::BoxedLoopsSetTy *BoxedLoops = SD.getBoxedLoops(&R);
+ const ScopDetection::BoxedLoopsSetTy &BoxedLoops = SD.getBoxedLoops(&R);
unsigned MinLD = INT_MAX, MaxLD = 0;
for (BasicBlock *BB : R.blocks()) {
if (Loop *L = LI.getLoopFor(BB)) {
if (!R.contains(L))
continue;
- if (BoxedLoops && BoxedLoops->count(L))
+ if (BoxedLoops.count(L))
continue;
unsigned LD = L->getLoopDepth();
MinLD = std::min(MinLD, LD);
diff --git a/lib/Analysis/TempScopInfo.cpp b/lib/Analysis/TempScopInfo.cpp
index 7bfd564..0fa861b 100644
--- a/lib/Analysis/TempScopInfo.cpp
+++ b/lib/Analysis/TempScopInfo.cpp
@@ -214,7 +214,7 @@ extern MapInsnToMemAcc InsnToMemAcc;
IRAccess
TempScopInfo::buildIRAccess(Instruction *Inst, Loop *L, Region *R,
- const ScopDetection::BoxedLoopsSetTy *BoxedLoops) {
+ const ScopDetection::BoxedLoopsSetTy &BoxedLoops) {
unsigned Size;
Type *SizeType;
enum IRAccess::TypeKind Type;
@@ -244,13 +244,11 @@ TempScopInfo::buildIRAccess(Instruction *Inst, Loop *L, Region *R,
// Check if the access depends on a loop contained in a non-affine subregion.
bool isVariantInNonAffineLoop = false;
- if (BoxedLoops) {
- SetVector<const Loop *> Loops;
- findLoops(AccessFunction, Loops);
- for (const Loop *L : Loops)
- if (BoxedLoops->count(L))
- isVariantInNonAffineLoop = true;
- }
+ SetVector<const Loop *> Loops;
+ findLoops(AccessFunction, Loops);
+ for (const Loop *L : Loops)
+ if (BoxedLoops.count(L))
+ isVariantInNonAffineLoop = true;
bool IsAffine = !isVariantInNonAffineLoop &&
isAffineExpr(R, AccessFunction, *SE, BasePointer->getValue());
@@ -287,7 +285,7 @@ void TempScopInfo::buildAccessFunctions(Region &R, BasicBlock &BB,
Loop *L = LI->getLoopFor(&BB);
// The set of loops contained in non-affine subregions that are part of R.
- const ScopDetection::BoxedLoopsSetTy *BoxedLoops = SD->getBoxedLoops(&R);
+ auto BoxedLoops = SD->getBoxedLoops(&R);
for (BasicBlock::iterator I = BB.begin(), E = --BB.end(); I != E; ++I) {
Instruction *Inst = I;
--
2.1.0
More information about the llvm-commits
mailing list