LCOV - code coverage report
Current view: top level - include/llvm/Analysis - PostDominators.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 10 15 66.7 %
Date: 2018-10-20 13:21:21 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //=- llvm/Analysis/PostDominators.h - Post Dominator Calculation --*- C++ -*-=//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file exposes interfaces to post dominance information.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_ANALYSIS_POSTDOMINATORS_H
      15             : #define LLVM_ANALYSIS_POSTDOMINATORS_H
      16             : 
      17             : #include "llvm/ADT/DepthFirstIterator.h"
      18             : #include "llvm/IR/Dominators.h"
      19             : #include "llvm/IR/PassManager.h"
      20             : #include "llvm/Pass.h"
      21             : 
      22             : namespace llvm {
      23             : 
      24             : class Function;
      25             : class raw_ostream;
      26             : 
      27             : /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
      28             : /// compute the post-dominator tree.
      29         761 : class PostDominatorTree : public PostDomTreeBase<BasicBlock> {
      30             : public:
      31             :   using Base = PostDomTreeBase<BasicBlock>;
      32             : 
      33             :   PostDominatorTree() = default;
      34         415 :   explicit PostDominatorTree(Function &F) { recalculate(F); }
      35             :   /// Handle invalidation explicitly.
      36             :   bool invalidate(Function &F, const PreservedAnalyses &PA,
      37             :                   FunctionAnalysisManager::Invalidator &);
      38             : };
      39             : 
      40             : /// Analysis pass which computes a \c PostDominatorTree.
      41             : class PostDominatorTreeAnalysis
      42             :     : public AnalysisInfoMixin<PostDominatorTreeAnalysis> {
      43             :   friend AnalysisInfoMixin<PostDominatorTreeAnalysis>;
      44             : 
      45             :   static AnalysisKey Key;
      46             : 
      47             : public:
      48             :   /// Provide the result type for this analysis pass.
      49             :   using Result = PostDominatorTree;
      50             : 
      51             :   /// Run the analysis pass over a function and produce a post dominator
      52             :   ///        tree.
      53             :   PostDominatorTree run(Function &F, FunctionAnalysisManager &);
      54             : };
      55             : 
      56             : /// Printer pass for the \c PostDominatorTree.
      57             : class PostDominatorTreePrinterPass
      58             :     : public PassInfoMixin<PostDominatorTreePrinterPass> {
      59             :   raw_ostream &OS;
      60             : 
      61             : public:
      62             :   explicit PostDominatorTreePrinterPass(raw_ostream &OS);
      63             : 
      64             :   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
      65             : };
      66             : 
      67             : struct PostDominatorTreeWrapperPass : public FunctionPass {
      68             :   static char ID; // Pass identification, replacement for typeid
      69             : 
      70             :   PostDominatorTree DT;
      71             : 
      72       30528 :   PostDominatorTreeWrapperPass() : FunctionPass(ID) {
      73       15264 :     initializePostDominatorTreeWrapperPassPass(*PassRegistry::getPassRegistry());
      74       15264 :   }
      75             : 
      76      169660 :   PostDominatorTree &getPostDomTree() { return DT; }
      77             :   const PostDominatorTree &getPostDomTree() const { return DT; }
      78             : 
      79             :   bool runOnFunction(Function &F) override;
      80             : 
      81             :   void verifyAnalysis() const override;
      82             : 
      83       15231 :   void getAnalysisUsage(AnalysisUsage &AU) const override {
      84             :     AU.setPreservesAll();
      85       15231 :   }
      86             : 
      87      153541 :   void releaseMemory() override {
      88             :     DT.releaseMemory();
      89      153541 :   }
      90             : 
      91             :   void print(raw_ostream &OS, const Module*) const override;
      92             : };
      93             : 
      94             : FunctionPass* createPostDomTree();
      95             : 
      96             : template <> struct GraphTraits<PostDominatorTree*>
      97             :   : public GraphTraits<DomTreeNode*> {
      98             :   static NodeRef getEntryNode(PostDominatorTree *DT) {
      99           0 :     return DT->getRootNode();
     100             :   }
     101             : 
     102           0 :   static nodes_iterator nodes_begin(PostDominatorTree *N) {
     103           0 :     if (getEntryNode(N))
     104             :       return df_begin(getEntryNode(N));
     105             :     else
     106             :       return df_end(getEntryNode(N));
     107             :   }
     108             : 
     109           0 :   static nodes_iterator nodes_end(PostDominatorTree *N) {
     110           0 :     return df_end(getEntryNode(N));
     111             :   }
     112             : };
     113             : 
     114             : } // end namespace llvm
     115             : 
     116             : #endif // LLVM_ANALYSIS_POSTDOMINATORS_H

Generated by: LCOV version 1.13