summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/include/polly/TempScopInfo.h17
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp2
-rw-r--r--polly/lib/Analysis/TempScopInfo.cpp37
-rw-r--r--polly/lib/CodeGen/CodeGeneration.cpp2
4 files changed, 28 insertions, 30 deletions
diff --git a/polly/include/polly/TempScopInfo.h b/polly/include/polly/TempScopInfo.h
index 71e81076e0f..26c83155c0c 100644
--- a/polly/include/polly/TempScopInfo.h
+++ b/polly/include/polly/TempScopInfo.h
@@ -206,7 +206,7 @@ typedef std::map<const Region *, TempScop *> TempScopMapType;
/// @brief The Function Pass to extract temporary information for Static control
/// part in llvm function.
///
-class TempScopInfo : public FunctionPass {
+class TempScopInfo : public RegionPass {
//===-------------------------------------------------------------------===//
TempScopInfo(const TempScopInfo &) = delete;
const TempScopInfo &operator=(const TempScopInfo &) = delete;
@@ -240,8 +240,8 @@ class TempScopInfo : public FunctionPass {
// zero scev every time when we need it.
const SCEV *ZeroOffset;
- // Mapping regions to the corresponding Scop in current function.
- TempScopMapType TempScops;
+ // The TempScop for this region.
+ TempScop *TempScopOfRegion;
// Clear the context.
void clear();
@@ -308,20 +308,19 @@ class TempScopInfo : public FunctionPass {
public:
static char ID;
- explicit TempScopInfo() : FunctionPass(ID) {}
+ explicit TempScopInfo() : RegionPass(ID), TempScopOfRegion(nullptr) {}
~TempScopInfo();
- /// @brief Get the temporay Scop information in LLVM IR represent
- /// for Region R.
+ /// @brief Get the temporay Scop information in LLVM IR for this region.
///
/// @return The Scop information in LLVM IR represent.
- TempScop *getTempScop(const Region *R) const;
+ TempScop *getTempScop() const;
- /// @name FunctionPass interface
+ /// @name RegionPass interface
//@{
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
virtual void releaseMemory() { clear(); }
- virtual bool runOnFunction(Function &F);
+ virtual bool runOnRegion(Region *R, RGPassManager &RGM);
virtual void print(raw_ostream &OS, const Module *) const;
//@}
};
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 8b561b5bf40..2678138205c 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -1977,7 +1977,7 @@ bool ScopInfo::runOnRegion(Region *R, RGPassManager &RGM) {
ScopDetection &SD = getAnalysis<ScopDetection>();
ScalarEvolution &SE = getAnalysis<ScalarEvolution>();
- TempScop *tempScop = getAnalysis<TempScopInfo>().getTempScop(R);
+ TempScop *tempScop = getAnalysis<TempScopInfo>().getTempScop();
// This region is no Scop.
if (!tempScop) {
diff --git a/polly/lib/Analysis/TempScopInfo.cpp b/polly/lib/Analysis/TempScopInfo.cpp
index 0195537e9ac..a03c4c372d8 100644
--- a/polly/lib/Analysis/TempScopInfo.cpp
+++ b/polly/lib/Analysis/TempScopInfo.cpp
@@ -460,34 +460,30 @@ TempScop *TempScopInfo::buildTempScop(Region &R) {
return TScop;
}
-TempScop *TempScopInfo::getTempScop(const Region *R) const {
- TempScopMapType::const_iterator at = TempScops.find(R);
- return at == TempScops.end() ? 0 : at->second;
-}
+TempScop *TempScopInfo::getTempScop() const { return TempScopOfRegion; }
void TempScopInfo::print(raw_ostream &OS, const Module *) const {
- for (TempScopMapType::const_iterator I = TempScops.begin(),
- E = TempScops.end();
- I != E; ++I)
- I->second->print(OS, SE, LI);
+ if (TempScopOfRegion)
+ TempScopOfRegion->print(OS, SE, LI);
}
-bool TempScopInfo::runOnFunction(Function &F) {
+bool TempScopInfo::runOnRegion(Region *R, RGPassManager &RGM) {
+ SD = &getAnalysis<ScopDetection>();
+
+ if (!SD->isMaxRegionInScop(*R))
+ return false;
+
+ Function *F = R->getEntry()->getParent();
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
PDT = &getAnalysis<PostDominatorTree>();
SE = &getAnalysis<ScalarEvolution>();
LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
- SD = &getAnalysis<ScopDetection>();
AA = &getAnalysis<AliasAnalysis>();
- TD = &F.getParent()->getDataLayout();
- ZeroOffset = SE->getConstant(TD->getIntPtrType(F.getContext()), 0);
+ TD = &F->getParent()->getDataLayout();
+ ZeroOffset = SE->getConstant(TD->getIntPtrType(F->getContext()), 0);
- for (ScopDetection::iterator I = SD->begin(), E = SD->end(); I != E; ++I) {
- if (!SD->isMaxRegionInScop(**I))
- continue;
- Region *R = const_cast<Region *>(*I);
- TempScops.insert(std::make_pair(R, buildTempScop(*R)));
- }
+ assert(!TempScopOfRegion && "Build the TempScop only once");
+ TempScopOfRegion = buildTempScop(*R);
return false;
}
@@ -508,8 +504,9 @@ TempScopInfo::~TempScopInfo() { clear(); }
void TempScopInfo::clear() {
BBConds.clear();
AccFuncMap.clear();
- DeleteContainerSeconds(TempScops);
- TempScops.clear();
+ if (TempScopOfRegion)
+ delete TempScopOfRegion;
+ TempScopOfRegion = nullptr;
}
//===----------------------------------------------------------------------===//
diff --git a/polly/lib/CodeGen/CodeGeneration.cpp b/polly/lib/CodeGen/CodeGeneration.cpp
index 1795cadad58..b2631a2687b 100644
--- a/polly/lib/CodeGen/CodeGeneration.cpp
+++ b/polly/lib/CodeGen/CodeGeneration.cpp
@@ -30,6 +30,7 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Analysis/PostDominators.h"
using namespace polly;
using namespace llvm;
@@ -170,6 +171,7 @@ public:
AU.addPreserved<LoopInfoWrapperPass>();
AU.addPreserved<DominatorTreeWrapperPass>();
+ AU.addPreserved<PostDominatorTree>();
AU.addPreserved<IslAstInfo>();
AU.addPreserved<ScopDetection>();
AU.addPreserved<ScalarEvolution>();
OpenPOWER on IntegriCloud