X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FAnalysis%2FLoopInfo.h;h=bbcde8d9721a346a62d4ba8be39f309cd0d55a29;hb=5057ee83579a7e70ef5b8e5c7d0421327bb12030;hp=1f8c1dba39b00438ec03cef43258c85d9ca2760a;hpb=30dd113d6f670b8c5dc91239869a7fb208aab4a8;p=oota-llvm.git diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 1f8c1dba39b..bbcde8d9721 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -47,13 +47,6 @@ namespace llvm { template class AnalysisManager; class PreservedAnalyses; -template -inline void RemoveFromVector(std::vector &V, T *N) { - typename std::vector::iterator I = std::find(V.begin(), V.end(), N); - assert(I != V.end() && "N is not in this list!"); - V.erase(I); -} - class DominatorTree; class LoopInfo; class Loop; @@ -79,9 +72,9 @@ class LoopBase { SmallPtrSet DenseBlockSet; - LoopBase(const LoopBase &) LLVM_DELETED_FUNCTION; + LoopBase(const LoopBase &) = delete; const LoopBase& - operator=(const LoopBase &) LLVM_DELETED_FUNCTION; + operator=(const LoopBase &) = delete; public: /// Loop ctor - This creates an empty loop. LoopBase() : ParentLoop(nullptr) {} @@ -324,7 +317,10 @@ public: /// current loop, updating the Blocks as appropriate. This does not update /// the mapping in the LoopInfo class. void removeBlockFromLoop(BlockT *BB) { - RemoveFromVector(Blocks, BB); + auto I = std::find(Blocks.begin(), Blocks.end(), BB); + assert(I != Blocks.end() && "N is not in this list!"); + Blocks.erase(I); + DenseBlockSet.erase(BB); } @@ -361,11 +357,11 @@ public: /// isLoopInvariant - Return true if the specified value is loop invariant /// - bool isLoopInvariant(Value *V) const; + bool isLoopInvariant(const Value *V) const; /// hasLoopInvariantOperands - Return true if all the operands of the /// specified instruction are loop invariant. - bool hasLoopInvariantOperands(Instruction *I) const; + bool hasLoopInvariantOperands(const Instruction *I) const; /// makeLoopInvariant - If the given value is an instruction inside of the /// loop and it can be hoisted, do so to make it trivially loop-invariant. @@ -464,23 +460,20 @@ public: /// cannot find a terminating instruction with location information, /// it returns an unknown location. DebugLoc getStartLoc() const { - DebugLoc StartLoc; BasicBlock *HeadBB; // Try the pre-header first. - if ((HeadBB = getLoopPreheader()) != nullptr) { - StartLoc = HeadBB->getTerminator()->getDebugLoc(); - if (!StartLoc.isUnknown()) - return StartLoc; - } + if ((HeadBB = getLoopPreheader()) != nullptr) + if (DebugLoc DL = HeadBB->getTerminator()->getDebugLoc()) + return DL; // If we have no pre-header or there are no instructions with debug // info in it, try the header. HeadBB = getHeader(); if (HeadBB) - StartLoc = HeadBB->getTerminator()->getDebugLoc(); + return HeadBB->getTerminator()->getDebugLoc(); - return StartLoc; + return DebugLoc(); } private: @@ -496,13 +489,13 @@ private: template class LoopInfoBase { // BBMap - Mapping of basic blocks to the inner most loop they occur in - DenseMap BBMap; + DenseMap BBMap; std::vector TopLevelLoops; friend class LoopBase; friend class LoopInfo; - void operator=(const LoopInfoBase &) LLVM_DELETED_FUNCTION; - LoopInfoBase(const LoopInfoBase &) LLVM_DELETED_FUNCTION; + void operator=(const LoopInfoBase &) = delete; + LoopInfoBase(const LoopInfoBase &) = delete; public: LoopInfoBase() { } ~LoopInfoBase() { releaseMemory(); } @@ -546,9 +539,7 @@ public: /// getLoopFor - Return the inner most loop that BB lives in. If a basic /// block is in no loop (for example the entry node), null is returned. /// - LoopT *getLoopFor(const BlockT *BB) const { - return BBMap.lookup(const_cast(BB)); - } + LoopT *getLoopFor(const BlockT *BB) const { return BBMap.lookup(BB); } /// operator[] - same as getLoopFor... /// @@ -565,7 +556,7 @@ public: } // isLoopHeader - True if the block is a loop header node - bool isLoopHeader(BlockT *BB) const { + bool isLoopHeader(const BlockT *BB) const { const LoopT *L = getLoopFor(BB); return L && L->getHeader() == BB; } @@ -651,8 +642,8 @@ class LoopInfo : public LoopInfoBase { friend class LoopBase; - void operator=(const LoopInfo &) LLVM_DELETED_FUNCTION; - LoopInfo(const LoopInfo &) LLVM_DELETED_FUNCTION; + void operator=(const LoopInfo &) = delete; + LoopInfo(const LoopInfo &) = delete; public: LoopInfo() {} @@ -732,12 +723,6 @@ public: /// \brief Provide a name for the analysis for debugging and logging. static StringRef name() { return "LoopAnalysis"; } - LoopAnalysis() {} - LoopAnalysis(const LoopAnalysis &Arg) {} - LoopAnalysis(LoopAnalysis &&Arg) {} - LoopAnalysis &operator=(const LoopAnalysis &RHS) { return *this; } - LoopAnalysis &operator=(LoopAnalysis &&RHS) { return *this; } - LoopInfo run(Function &F, AnalysisManager *AM); };