forked from OSchip/llvm-project
This patch updates memory management of ScopBuilder class.
1. SCoP object is not owned by ScopBuilder. It just creates a SCoP and hand over ownership through getScop() method. 2. ScopInfoRegionPass owns the SCoP object for a given region. Patch by Utpal Bora <cs14mtech11017@iith.ac.in> Differential Revision: http://reviews.llvm.org/D20912 llvm-svn: 273855
This commit is contained in:
parent
efb0b899d3
commit
b7e9713563
|
@ -2288,9 +2288,6 @@ class ScopBuilder {
|
||||||
// The Scop
|
// The Scop
|
||||||
std::unique_ptr<Scop> scop;
|
std::unique_ptr<Scop> scop;
|
||||||
|
|
||||||
// Clear the context.
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
// Build the SCoP for Region @p R.
|
// Build the SCoP for Region @p R.
|
||||||
void buildScop(Region &R, AssumptionCache &AC);
|
void buildScop(Region &R, AssumptionCache &AC);
|
||||||
|
|
||||||
|
@ -2485,18 +2482,16 @@ public:
|
||||||
/// @brief Try to build the Polly IR of static control part on the current
|
/// @brief Try to build the Polly IR of static control part on the current
|
||||||
/// SESE-Region.
|
/// SESE-Region.
|
||||||
///
|
///
|
||||||
/// @return If the current region is a valid for a static control part,
|
/// @return Give up the ownership of the scop object or static control part
|
||||||
/// return the Polly IR representing this static control part,
|
/// for the region
|
||||||
/// return null otherwise.
|
std::unique_ptr<Scop> getScop() { return std::move(scop); }
|
||||||
Scop *getScop() { return scop.get(); }
|
|
||||||
const Scop *getScop() const { return scop.get(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief The legacy pass manager's analysis pass to compute scop information
|
/// @brief The legacy pass manager's analysis pass to compute scop information
|
||||||
/// for a region.
|
/// for a region.
|
||||||
class ScopInfoRegionPass : public RegionPass {
|
class ScopInfoRegionPass : public RegionPass {
|
||||||
/// @brief The ScopBuilder pointer which is used to construct a Scop.
|
/// @brief The Scop pointer which is used to construct a Scop.
|
||||||
std::unique_ptr<ScopBuilder> SI;
|
std::unique_ptr<Scop> S;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
|
@ -2504,27 +2499,19 @@ public:
|
||||||
ScopInfoRegionPass() : RegionPass(ID) {}
|
ScopInfoRegionPass() : RegionPass(ID) {}
|
||||||
~ScopInfoRegionPass() {}
|
~ScopInfoRegionPass() {}
|
||||||
|
|
||||||
/// @brief Build ScopBuilder object, which constructs Polly IR of static
|
/// @brief Build Scop object, the Polly IR of static control
|
||||||
/// control part for the current SESE-Region.
|
/// part for the current SESE-Region.
|
||||||
///
|
///
|
||||||
/// @return Return Scop for the current Region.
|
/// @return If the current region is a valid for a static control part,
|
||||||
Scop *getScop() {
|
/// return the Polly IR representing this static control part,
|
||||||
if (SI)
|
/// return null otherwise.
|
||||||
return SI.get()->getScop();
|
Scop *getScop() { return S.get(); }
|
||||||
else
|
const Scop *getScop() const { return S.get(); }
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
const Scop *getScop() const {
|
|
||||||
if (SI)
|
|
||||||
return SI.get()->getScop();
|
|
||||||
else
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief Calculate the polyhedral scop information for a given Region.
|
/// @brief Calculate the polyhedral scop information for a given Region.
|
||||||
bool runOnRegion(Region *R, RGPassManager &RGM) override;
|
bool runOnRegion(Region *R, RGPassManager &RGM) override;
|
||||||
|
|
||||||
void releaseMemory() override { SI.reset(); }
|
void releaseMemory() override { S.reset(); }
|
||||||
|
|
||||||
void print(raw_ostream &O, const Module *M = nullptr) const override;
|
void print(raw_ostream &O, const Module *M = nullptr) const override;
|
||||||
|
|
||||||
|
|
|
@ -4881,8 +4881,6 @@ ScopBuilder::ScopBuilder(Region *R, AssumptionCache &AC, AliasAnalysis &AA,
|
||||||
emitOptimizationRemarkAnalysis(F->getContext(), DEBUG_TYPE, *F, End, Msg);
|
emitOptimizationRemarkAnalysis(F->getContext(), DEBUG_TYPE, *F, End, Msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopBuilder::clear() { scop.reset(); }
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
void ScopInfoRegionPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
void ScopInfoRegionPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.addRequired<LoopInfoWrapperPass>();
|
AU.addRequired<LoopInfoWrapperPass>();
|
||||||
|
@ -4909,19 +4907,16 @@ bool ScopInfoRegionPass::runOnRegion(Region *R, RGPassManager &RGM) {
|
||||||
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
||||||
auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(*F);
|
auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(*F);
|
||||||
|
|
||||||
SI.reset(new ScopBuilder(R, AC, AA, DL, DT, LI, SD, SE));
|
ScopBuilder SB(R, AC, AA, DL, DT, LI, SD, SE);
|
||||||
|
S = SB.getScop(); // take ownership of scop object
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopInfoRegionPass::print(raw_ostream &OS, const Module *) const {
|
void ScopInfoRegionPass::print(raw_ostream &OS, const Module *) const {
|
||||||
Scop *scop;
|
if (S)
|
||||||
if (SI) {
|
S->print(OS);
|
||||||
if ((scop = SI->getScop())) {
|
else
|
||||||
scop->print(OS);
|
OS << "Invalid Scop!\n";
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OS << "Invalid Scop!\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char ScopInfoRegionPass::ID = 0;
|
char ScopInfoRegionPass::ID = 0;
|
||||||
|
|
Loading…
Reference in New Issue