[llvm-commits] [polly] r143654 - /polly/trunk/lib/Analysis/ScopDetection.cpp

Tobias Grosser grosser at fim.uni-passau.de
Thu Nov 3 14:03:19 PDT 2011


Author: grosser
Date: Thu Nov  3 16:03:18 2011
New Revision: 143654

URL: http://llvm.org/viewvc/llvm-project?rev=143654&view=rev
Log:
ScopDetection: Use SCEVValidator for memory accesses.

We currently run the old memory access checker in parallel, as we would
otherwise fail in TempScop because of currently unsupported functions. We will
remove the old memory access checker as soon as TempScop is fixed.

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=143654&r1=143653&r2=143654&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Thu Nov  3 16:03:18 2011
@@ -118,21 +118,24 @@
 private:
   const Region *R;
   ScalarEvolution &SE;
-  const Value **BaseAddress;
+  Value **BaseAddress;
 
 public:
   static bool isValid(const Region *R, const SCEV *Scev,
                       ScalarEvolution &SE,
-                      const Value **BaseAddress = NULL) {
+                      Value **BaseAddress = NULL) {
     if (isa<SCEVCouldNotCompute>(Scev))
       return false;
 
+    if (BaseAddress)
+      *BaseAddress = NULL;
+
     SCEVValidator Validator(R, SE, BaseAddress);
     return Validator.visit(Scev) != SCEVType::INVALID;
   }
 
   SCEVValidator(const Region *R, ScalarEvolution &SE,
-                const Value **BaseAddress) : R(R), SE(SE),
+                Value **BaseAddress) : R(R), SE(SE),
     BaseAddress(BaseAddress) {};
 
   SCEVType::TYPE visitConstant(const SCEVConstant *Constant) {
@@ -261,6 +264,19 @@
   }
 
   SCEVType::TYPE visitUnknown(const SCEVUnknown* Expr) {
+
+    Value *V = Expr->getValue();
+
+    if (isa<UndefValue>(V))
+        return SCEVType::INVALID;
+
+    if (BaseAddress) {
+      if (*BaseAddress)
+        return SCEVType::INVALID;
+      else
+        *BaseAddress = V;
+    }
+
     if (Instruction *I = dyn_cast<Instruction>(Expr->getValue()))
       if (R->contains(I))
         return SCEVType::INVALID;
@@ -438,9 +454,16 @@
   Value *Ptr = getPointerOperand(Inst), *BasePtr;
   const SCEV *AccessFunction = SE->getSCEV(Ptr);
 
-  if (!isValidAffineFunction(AccessFunction, Context.CurRegion, &BasePtr))
+  if (!SCEVValidator::isValid(&Context.CurRegion, AccessFunction, *SE,
+                                 &BasePtr))
     INVALID(AffFunc, "Bad memory address " << *AccessFunction);
 
+  // FIXME: Also check with isValidAffineFunction, as for the moment it is
+  //        protecting us to fail because of not supported features in TempScop.
+  //        As soon as TempScop is fixed, this needs to be removed.
+  if (!isValidAffineFunction(AccessFunction, Context.CurRegion, &BasePtr))
+    INVALID(AffFunc, "Access not supported in TempScop" << *AccessFunction);
+
   // FIXME: Alias Analysis thinks IntToPtrInst aliases with alloca instructions
   // created by IndependentBlocks Pass.
   if (isa<IntToPtrInst>(BasePtr))





More information about the llvm-commits mailing list