[polly] r230222 - [NFC] Unify the use of Context.CurRegion

Johannes Doerfert doerfert at cs.uni-saarland.de
Mon Feb 23 06:18:28 PST 2015


Author: jdoerfert
Date: Mon Feb 23 08:18:28 2015
New Revision: 230222

URL: http://llvm.org/viewvc/llvm-project?rev=230222&view=rev
Log:
[NFC] Unify the use of Context.CurRegion

Modified:
    polly/trunk/lib/Analysis/ScopDetection.cpp

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=230222&r1=230221&r2=230222&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Mon Feb 23 08:18:28 2015
@@ -278,11 +278,12 @@ std::string ScopDetection::regionIsInval
 
 bool ScopDetection::isValidCFG(BasicBlock &BB,
                                DetectionContext &Context) const {
-  Region &RefRegion = Context.CurRegion;
+  Region &CurRegion = Context.CurRegion;
+
   TerminatorInst *TI = BB.getTerminator();
 
   // Return instructions are only valid if the region is the top level region.
-  if (isa<ReturnInst>(TI) && !RefRegion.getExit() && TI->getNumOperands() == 0)
+  if (isa<ReturnInst>(TI) && !CurRegion.getExit() && TI->getNumOperands() == 0)
     return true;
 
   BranchInst *Br = dyn_cast<BranchInst>(TI);
@@ -324,8 +325,8 @@ bool ScopDetection::isValidCFG(BasicBloc
     const SCEV *LHS = SE->getSCEVAtScope(ICmp->getOperand(0), L);
     const SCEV *RHS = SE->getSCEVAtScope(ICmp->getOperand(1), L);
 
-    if (!isAffineExpr(&Context.CurRegion, LHS, *SE) ||
-        !isAffineExpr(&Context.CurRegion, RHS, *SE))
+    if (!isAffineExpr(&CurRegion, LHS, *SE) ||
+        !isAffineExpr(&CurRegion, RHS, *SE))
       return invalid<ReportNonAffBranch>(Context, /*Assert=*/true, &BB, LHS,
                                          RHS, ICmp);
   }
@@ -426,6 +427,8 @@ bool ScopDetection::isInvariant(const Va
 MapInsnToMemAcc InsnToMemAcc;
 
 bool ScopDetection::hasAffineMemoryAccesses(DetectionContext &Context) const {
+  Region &CurRegion = Context.CurRegion;
+
   for (const SCEVUnknown *BasePointer : Context.NonAffineAccesses) {
     Value *BaseValue = BasePointer->getValue();
     ArrayShape *Shape = new ArrayShape(BasePointer);
@@ -454,7 +457,7 @@ bool ScopDetection::hasAffineMemoryAcces
         const Instruction *Insn = Pair.first;
         const SCEV *AF = Pair.second;
 
-        if (!isAffineExpr(&Context.CurRegion, AF, *SE, BaseValue)) {
+        if (!isAffineExpr(&CurRegion, AF, *SE, BaseValue)) {
           invalid<ReportNonAffineAccess>(Context, /*Assert=*/true, AF, Insn,
                                          BaseValue);
           if (!KeepGoing)
@@ -481,7 +484,7 @@ bool ScopDetection::hasAffineMemoryAcces
       TempMemoryAccesses.insert({Insn, Acc});
 
       if (!AF) {
-        if (isAffineExpr(&Context.CurRegion, Pair.second, *SE, BaseValue))
+        if (isAffineExpr(&CurRegion, Pair.second, *SE, BaseValue))
           Acc->DelinearizedSubscripts.push_back(Pair.second);
         else
           IsNonAffine = true;
@@ -491,7 +494,7 @@ bool ScopDetection::hasAffineMemoryAcces
         if (Acc->DelinearizedSubscripts.size() == 0)
           IsNonAffine = true;
         for (const SCEV *S : Acc->DelinearizedSubscripts)
-          if (!isAffineExpr(&Context.CurRegion, S, *SE, BaseValue))
+          if (!isAffineExpr(&CurRegion, S, *SE, BaseValue))
             IsNonAffine = true;
       }
 
@@ -514,6 +517,8 @@ bool ScopDetection::hasAffineMemoryAcces
 
 bool ScopDetection::isValidMemoryAccess(Instruction &Inst,
                                         DetectionContext &Context) const {
+  Region &CurRegion = Context.CurRegion;
+
   Value *Ptr = getPointerOperand(Inst);
   Loop *L = LI->getLoopFor(Inst.getParent());
   const SCEV *AccessFunction = SE->getSCEVAtScope(Ptr, L);
@@ -532,7 +537,7 @@ bool ScopDetection::isValidMemoryAccess(
 
   // Check that the base address of the access is invariant in the current
   // region.
-  if (!isInvariant(*BaseValue, Context.CurRegion))
+  if (!isInvariant(*BaseValue, CurRegion))
     // Verification of this property is difficult as the independent blocks
     // pass may introduce aliasing that we did not have when running the
     // scop detection.
@@ -553,10 +558,10 @@ bool ScopDetection::isValidMemoryAccess(
   if (PollyDelinearize) {
     Context.Accesses[BasePointer].push_back({&Inst, AccessFunction});
 
-    if (!isAffineExpr(&Context.CurRegion, AccessFunction, *SE, BaseValue))
+    if (!isAffineExpr(&CurRegion, AccessFunction, *SE, BaseValue))
       Context.NonAffineAccesses.insert(BasePointer);
   } else if (!AllowNonAffine) {
-    if (!isAffineExpr(&Context.CurRegion, AccessFunction, *SE, BaseValue))
+    if (!isAffineExpr(&CurRegion, AccessFunction, *SE, BaseValue))
       return invalid<ReportNonAffineAccess>(Context, /*Assert=*/true,
                                             AccessFunction, &Inst, BaseValue);
   }
@@ -592,7 +597,7 @@ bool ScopDetection::isValidMemoryAccess(
       // sure the base pointer is not an instruction defined inside the scop.
       for (const auto &Ptr : AS) {
         Instruction *Inst = dyn_cast<Instruction>(Ptr.getValue());
-        if (Inst && Context.CurRegion.contains(Inst)) {
+        if (Inst && CurRegion.contains(Inst)) {
           CanBuildRunTimeCheck = false;
           break;
         }
@@ -787,19 +792,19 @@ void ScopDetection::findScops(Region &R)
 }
 
 bool ScopDetection::allBlocksValid(DetectionContext &Context) const {
-  Region &R = Context.CurRegion;
+  Region &CurRegion = Context.CurRegion;
 
-  for (const BasicBlock *BB : R.blocks()) {
+  for (const BasicBlock *BB : CurRegion.blocks()) {
     Loop *L = LI->getLoopFor(BB);
     if (L && L->getHeader() == BB && (!isValidLoop(L, Context) && !KeepGoing))
       return false;
   }
 
-  for (BasicBlock *BB : R.blocks())
+  for (BasicBlock *BB : CurRegion.blocks())
     if (!isValidCFG(*BB, Context) && !KeepGoing)
       return false;
 
-  for (BasicBlock *BB : R.blocks())
+  for (BasicBlock *BB : CurRegion.blocks())
     for (BasicBlock::iterator I = BB->begin(), E = --BB->end(); I != E; ++I)
       if (!isValidInstruction(*I, Context) && !KeepGoing)
         return false;
@@ -811,10 +816,9 @@ bool ScopDetection::allBlocksValid(Detec
 }
 
 bool ScopDetection::isValidExit(DetectionContext &Context) const {
-  Region &R = Context.CurRegion;
 
   // PHI nodes are not allowed in the exit basic block.
-  if (BasicBlock *Exit = R.getExit()) {
+  if (BasicBlock *Exit = Context.CurRegion.getExit()) {
     BasicBlock::iterator I = Exit->begin();
     if (I != Exit->end() && isa<PHINode>(*I))
       return invalid<ReportPHIinExit>(Context, /*Assert=*/true, I);
@@ -824,16 +828,16 @@ bool ScopDetection::isValidExit(Detectio
 }
 
 bool ScopDetection::isValidRegion(DetectionContext &Context) const {
-  Region &R = Context.CurRegion;
+  Region &CurRegion = Context.CurRegion;
 
-  DEBUG(dbgs() << "Checking region: " << R.getNameStr() << "\n\t");
+  DEBUG(dbgs() << "Checking region: " << CurRegion.getNameStr() << "\n\t");
 
-  if (R.isTopLevelRegion()) {
+  if (CurRegion.isTopLevelRegion()) {
     DEBUG(dbgs() << "Top level region is invalid\n");
     return false;
   }
 
-  if (!R.getEntry()->getName().count(OnlyRegion)) {
+  if (!CurRegion.getEntry()->getName().count(OnlyRegion)) {
     DEBUG({
       dbgs() << "Region entry does not match -polly-region-only";
       dbgs() << "\n";
@@ -841,8 +845,8 @@ bool ScopDetection::isValidRegion(Detect
     return false;
   }
 
-  if (!R.getEnteringBlock()) {
-    BasicBlock *entry = R.getEntry();
+  if (!CurRegion.getEnteringBlock()) {
+    BasicBlock *entry = CurRegion.getEntry();
     Loop *L = LI->getLoopFor(entry);
 
     if (L) {
@@ -853,7 +857,7 @@ bool ScopDetection::isValidRegion(Detect
            ++PI) {
         // Region entering edges come from the same loop but outside the region
         // are not allowed.
-        if (L->contains(*PI) && !R.contains(*PI))
+        if (L->contains(*PI) && !CurRegion.contains(*PI))
           return invalid<ReportIndEdge>(Context, /*Assert=*/true, *PI);
       }
     }
@@ -861,8 +865,9 @@ bool ScopDetection::isValidRegion(Detect
 
   // SCoP cannot contain the entry block of the function, because we need
   // to insert alloca instruction there when translate scalar to array.
-  if (R.getEntry() == &(R.getEntry()->getParent()->getEntryBlock()))
-    return invalid<ReportEntry>(Context, /*Assert=*/true, R.getEntry());
+  if (CurRegion.getEntry() ==
+      &(CurRegion.getEntry()->getParent()->getEntryBlock()))
+    return invalid<ReportEntry>(Context, /*Assert=*/true, CurRegion.getEntry());
 
   if (!isValidExit(Context))
     return false;





More information about the llvm-commits mailing list