[polly] r236583 - Add iterators for the ArrayInfo objects of the scop
Tobias Grosser
tobias at grosser.es
Wed May 6 03:05:21 PDT 2015
Author: grosser
Date: Wed May 6 05:05:20 2015
New Revision: 236583
URL: http://llvm.org/viewvc/llvm-project?rev=236583&view=rev
Log:
Add iterators for the ArrayInfo objects of the scop
This patch also changes the implementation of the ArrayInfoMap to a MapVector
which will ensure that iterating over the list of ArrayInfo objects gives
predictable results. The single loop that currently enumerates the ArrayInfo
objects only frees the individual objectes, hence a possibly changing
iteration order does not affect the outcome. The added robustness is for
future users of this interface.
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=236583&r1=236582&r2=236583&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Wed May 6 05:05:20 2015
@@ -23,6 +23,7 @@
#include "polly/ScopDetection.h"
#include "llvm/Analysis/RegionPass.h"
+#include "llvm/ADT/MapVector.h"
#include "isl/ctx.h"
@@ -745,8 +746,9 @@ private:
/// Constraints on parameters.
isl_set *Context;
+ typedef MapVector<const Value *, const ScopArrayInfo *> ArrayInfoMapTy;
/// @brief A map to remember ScopArrayInfo objects for all base pointers.
- DenseMap<const Value *, const ScopArrayInfo *> ScopArrayInfoMap;
+ ArrayInfoMapTy ScopArrayInfoMap;
/// @brief The assumptions under which this scop was built.
///
@@ -850,6 +852,19 @@ public:
/// @brief Take a list of parameters and add the new ones to the scop.
void addParams(std::vector<const SCEV *> NewParameters);
+ int getNumArrays() { return ScopArrayInfoMap.size(); }
+
+ typedef iterator_range<ArrayInfoMapTy::iterator> array_range;
+ typedef iterator_range<ArrayInfoMapTy::const_iterator> const_array_range;
+
+ inline array_range arrays() {
+ return array_range(ScopArrayInfoMap.begin(), ScopArrayInfoMap.end());
+ }
+
+ inline const_array_range arrays() const {
+ return const_array_range(ScopArrayInfoMap.begin(), ScopArrayInfoMap.end());
+ }
+
/// @brief Return the isl_id that represents a certain parameter.
///
/// @param Parameter A SCEV that was recognized as a Parameter.
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=236583&r1=236582&r2=236583&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed May 6 05:05:20 2015
@@ -1722,7 +1722,7 @@ Scop::~Scop() {
delete Stmt;
// Free the ScopArrayInfo objects.
- for (auto &ScopArrayInfoPair : ScopArrayInfoMap)
+ for (auto &ScopArrayInfoPair : arrays())
delete ScopArrayInfoPair.second;
// Free the alias groups
More information about the llvm-commits
mailing list