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 &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,8 +493,7 @@ bool UseDependencies); /// Generate the checks and return them. - SmallVector - generateChecks() const; + SmallVector generateChecks() const; /// Holds a pointer to the ScalarEvolution analysis. ScalarEvolution *SE; @@ -490,6 +501,9 @@ /// \brief Set of run-time checks required to establish independence of /// otherwise may-aliasing pointers in the loop. SmallVector Checks; + + /// \brief Set of pointers with unknown bounds. + SmallVector PtrsWithUnknownBounds; }; /// \brief Drive the analysis of memory accesses in the loop 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();