[PATCH] D25557: [LAA] Collect pointers with unknown bounds

Evgeny Astigeevich via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 13 06:40:14 PDT 2016


eastig created this revision.
eastig added reviewers: anemet, sbaranga, ashutosh.nema.
eastig added a subscriber: llvm-commits.
Herald added a subscriber: mzolotukhin.

This is an enhancement to LoopAccessAnalysis which enables collecting pointers with unknown bounds. Users of LAA can be interested in them.
The pointers are stored in RuntimePointerChecking. To have them and pointers with known bounds available after analysis, resetting of RuntimePointerChecking is removed from  AccessAnalysis::canCheckPtrAtRT.


https://reviews.llvm.org/D25557

Files:
  include/llvm/Analysis/LoopAccessAnalysis.h
  lib/Analysis/LoopAccessAnalysis.cpp


Index: lib/Analysis/LoopAccessAnalysis.cpp
===================================================================
--- lib/Analysis/LoopAccessAnalysis.cpp
+++ lib/Analysis/LoopAccessAnalysis.cpp
@@ -658,6 +658,7 @@
         DEBUG(dbgs() << "LAA: Found a runtime check ptr:" << *Ptr << '\n');
       } else {
         DEBUG(dbgs() << "LAA: Can't find bounds for ptr:" << *Ptr << '\n');
+        RtCheck.pointerWithUnknownBounds(Ptr);
         CanDoRT = false;
       }
     }
@@ -714,10 +715,7 @@
 
   RtCheck.Need = NeedRTCheck;
 
-  bool CanDoRTIfNeeded = !NeedRTCheck || CanDoRT;
-  if (!CanDoRTIfNeeded)
-    RtCheck.reset();
-  return CanDoRTIfNeeded;
+  return !NeedRTCheck || CanDoRT;
 }
 
 void AccessAnalysis::processMemAccesses() {
@@ -1537,8 +1535,7 @@
   unsigned NumReads = 0;
   unsigned NumReadWrites = 0;
 
-  PtrRtChecking->Pointers.clear();
-  PtrRtChecking->Need = false;
+  PtrRtChecking->reset();
 
   const bool IsAnnotatedParallel = TheLoop->isAnnotatedParallel();
 
Index: include/llvm/Analysis/LoopAccessAnalysis.h
===================================================================
--- include/llvm/Analysis/LoopAccessAnalysis.h
+++ include/llvm/Analysis/LoopAccessAnalysis.h
@@ -367,6 +367,7 @@
     Need = false;
     Pointers.clear();
     Checks.clear();
+    PtrsWithUnknownBounds.clear();
   }
 
   /// Insert a pointer and calculate the start and end SCEVs.
@@ -472,6 +473,17 @@
     return Pointers[PtrIdx];
   }
 
+  /// \brief Notify RuntimePointerChecking that Ptr has unknown bounds.
+  void pointerWithUnknownBounds(Value *Ptr) {
+    assert(Ptr);
+    PtrsWithUnknownBounds.push_back(Ptr);
+  }
+
+  /// \brief Get a list of pointers which have unknonw bounds.
+  const SmallVectorImpl<Value *> &getPointersWithUnknownBounds() const {
+    return PtrsWithUnknownBounds;
+  }
+
 private:
   /// \brief Groups pointers such that a single memcheck is required
   /// between two different groups. This will clear the CheckingGroups vector
@@ -481,15 +493,17 @@
                    bool UseDependencies);
 
   /// Generate the checks and return them.
-  SmallVector<PointerCheck, 4>
-  generateChecks() const;
+  SmallVector<PointerCheck, 4> generateChecks() const;
 
   /// Holds a pointer to the ScalarEvolution analysis.
   ScalarEvolution *SE;
 
   /// \brief Set of run-time checks required to establish independence of
   /// otherwise may-aliasing pointers in the loop.
   SmallVector<PointerCheck, 4> Checks;
+
+  /// \brief Set of pointers with unknown bounds.
+  SmallVector<Value *, 4> PtrsWithUnknownBounds;
 };
 
 /// \brief Drive the analysis of memory accesses in the loop


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25557.74505.patch
Type: text/x-patch
Size: 2619 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161013/e648be11/attachment.bin>


More information about the llvm-commits mailing list