llvm.org GIT mirror llvm / 5a04f4a
Push constness through LoopInfo::isLoopHeader and clean it up a bit. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238843 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 4 years ago
4 changed file(s) with 10 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
4646 template class AnalysisManager;
4747 class PreservedAnalyses;
4848
49 template
50 inline void RemoveFromVector(std::vector &V, T *N) {
51 typename std::vector::iterator I = std::find(V.begin(), V.end(), N);
52 assert(I != V.end() && "N is not in this list!");
53 V.erase(I);
54 }
55
5649 class DominatorTree;
5750 class LoopInfo;
5851 class Loop;
323316 /// current loop, updating the Blocks as appropriate. This does not update
324317 /// the mapping in the LoopInfo class.
325318 void removeBlockFromLoop(BlockT *BB) {
326 RemoveFromVector(Blocks, BB);
319 auto I = std::find(Blocks.begin(), Blocks.end(), BB);
320 assert(I != Blocks.end() && "N is not in this list!");
321 Blocks.erase(I);
322
327323 DenseBlockSet.erase(BB);
328324 }
329325
492488 template
493489 class LoopInfoBase {
494490 // BBMap - Mapping of basic blocks to the inner most loop they occur in
495 DenseMap<BlockT *, LoopT *> BBMap;
491 DenseMap<const BlockT *, LoopT *> BBMap;
496492 std::vector TopLevelLoops;
497493 friend class LoopBase;
498494 friend class LoopInfo;
542538 /// getLoopFor - Return the inner most loop that BB lives in. If a basic
543539 /// block is in no loop (for example the entry node), null is returned.
544540 ///
545 LoopT *getLoopFor(const BlockT *BB) const {
546 return BBMap.lookup(const_cast(BB));
547 }
541 LoopT *getLoopFor(const BlockT *BB) const { return BBMap.lookup(BB); }
548542
549543 /// operator[] - same as getLoopFor...
550544 ///
561555 }
562556
563557 // isLoopHeader - True if the block is a loop header node
564 bool isLoopHeader(BlockT *BB) const {
558 bool isLoopHeader(const BlockT *BB) const {
565559 const LoopT *L = getLoopFor(BB);
566560 return L && L->getHeader() == BB;
567561 }
728722 /// \brief Provide a name for the analysis for debugging and logging.
729723 static StringRef name() { return "LoopAnalysis"; }
730724
731 LoopAnalysis() {}
732 LoopAnalysis(const LoopAnalysis &Arg) {}
733 LoopAnalysis(LoopAnalysis &&Arg) {}
734 LoopAnalysis &operator=(const LoopAnalysis &RHS) { return *this; }
735 LoopAnalysis &operator=(LoopAnalysis &&RHS) { return *this; }
736
737725 LoopInfo run(Function &F, AnalysisManager *AM);
738726 };
739727
526526 // Verify that blocks are mapped to valid loops.
527527 #ifndef NDEBUG
528528 for (auto &Entry : BBMap) {
529 BlockT *BB = Entry.first;
529 const BlockT *BB = Entry.first;
530530 LoopT *L = Entry.second;
531531 assert(Loops.count(L) && "orphaned loop");
532532 assert(L->contains(BB) && "orphaned block");
113113 }
114114
115115 // isLoopHeader - True if the block is a loop header node
116 inline bool isLoopHeader(MachineBasicBlock *BB) const {
116 inline bool isLoopHeader(const MachineBasicBlock *BB) const {
117117 return LI.isLoopHeader(BB);
118118 }
119119
417417 bool NVPTXAsmPrinter::isLoopHeaderOfNoUnroll(
418418 const MachineBasicBlock &MBB) const {
419419 MachineLoopInfo &LI = getAnalysis();
420 // TODO: isLoopHeader() should take "const MachineBasicBlock *".
421420 // We insert .pragma "nounroll" only to the loop header.
422 if (!LI.isLoopHeader(const_cast(&MBB)))
421 if (!LI.isLoopHeader(&MBB))
423422 return false;
424423
425424 // llvm.loop.unroll.disable is marked on the back edges of a loop. Therefore,