Index: polly/trunk/include/polly/ScopInfo.h =================================================================== --- polly/trunk/include/polly/ScopInfo.h +++ polly/trunk/include/polly/ScopInfo.h @@ -2288,9 +2288,6 @@ // The Scop std::unique_ptr scop; - // Clear the context. - void clear(); - // Build the SCoP for Region @p R. void buildScop(Region &R, AssumptionCache &AC); @@ -2485,18 +2482,16 @@ /// @brief Try to build the Polly IR of static control part on the current /// SESE-Region. /// - /// @return If the current region is a valid for a static control part, - /// return the Polly IR representing this static control part, - /// return null otherwise. - Scop *getScop() { return scop.get(); } - const Scop *getScop() const { return scop.get(); } + /// @return Give up the ownership of the scop object or static control part + /// for the region + std::unique_ptr getScop() { return std::move(scop); } }; /// @brief The legacy pass manager's analysis pass to compute scop information /// for a region. class ScopInfoRegionPass : public RegionPass { - /// @brief The ScopBuilder pointer which is used to construct a Scop. - std::unique_ptr SI; + /// @brief The Scop pointer which is used to construct a Scop. + std::unique_ptr S; public: static char ID; // Pass identification, replacement for typeid @@ -2504,27 +2499,19 @@ ScopInfoRegionPass() : RegionPass(ID) {} ~ScopInfoRegionPass() {} - /// @brief Build ScopBuilder object, which constructs Polly IR of static - /// control part for the current SESE-Region. + /// @brief Build Scop object, the Polly IR of static control + /// part for the current SESE-Region. /// - /// @return Return Scop for the current Region. - Scop *getScop() { - if (SI) - return SI.get()->getScop(); - else - return nullptr; - } - const Scop *getScop() const { - if (SI) - return SI.get()->getScop(); - else - return nullptr; - } + /// @return If the current region is a valid for a static control part, + /// return the Polly IR representing this static control part, + /// return null otherwise. + Scop *getScop() { return S.get(); } + const Scop *getScop() const { return S.get(); } /// @brief Calculate the polyhedral scop information for a given Region. 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; Index: polly/trunk/lib/Analysis/ScopInfo.cpp =================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp +++ polly/trunk/lib/Analysis/ScopInfo.cpp @@ -4881,8 +4881,6 @@ emitOptimizationRemarkAnalysis(F->getContext(), DEBUG_TYPE, *F, End, Msg); } -void ScopBuilder::clear() { scop.reset(); } - //===----------------------------------------------------------------------===// void ScopInfoRegionPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); @@ -4909,19 +4907,16 @@ auto &DT = getAnalysis().getDomTree(); auto &AC = getAnalysis().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; } void ScopInfoRegionPass::print(raw_ostream &OS, const Module *) const { - Scop *scop; - if (SI) { - if ((scop = SI->getScop())) { - scop->print(OS); - return; - } - } - OS << "Invalid Scop!\n"; + if (S) + S->print(OS); + else + OS << "Invalid Scop!\n"; } char ScopInfoRegionPass::ID = 0;