LCOV - code coverage report
Current view: top level - lib/Analysis - PostDominators.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 19 23 82.6 %
Date: 2018-10-20 13:21:21 Functions: 8 10 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- PostDominators.cpp - Post-Dominator Calculation --------------------===//
       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 implements the post-dominator construction algorithms.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/Analysis/PostDominators.h"
      15             : #include "llvm/IR/Function.h"
      16             : #include "llvm/IR/PassManager.h"
      17             : #include "llvm/Pass.h"
      18             : #include "llvm/Support/raw_ostream.h"
      19             : 
      20             : using namespace llvm;
      21             : 
      22             : #define DEBUG_TYPE "postdomtree"
      23             : 
      24             : #ifdef EXPENSIVE_CHECKS
      25             : static constexpr bool ExpensiveChecksEnabled = true;
      26             : #else
      27             : static constexpr bool ExpensiveChecksEnabled = false;
      28             : #endif
      29             : 
      30             : //===----------------------------------------------------------------------===//
      31             : //  PostDominatorTree Implementation
      32             : //===----------------------------------------------------------------------===//
      33             : 
      34             : char PostDominatorTreeWrapperPass::ID = 0;
      35             : 
      36      515068 : INITIALIZE_PASS(PostDominatorTreeWrapperPass, "postdomtree",
      37             :                 "Post-Dominator Tree Construction", true, true)
      38             : 
      39         138 : bool PostDominatorTree::invalidate(Function &F, const PreservedAnalyses &PA,
      40             :                                    FunctionAnalysisManager::Invalidator &) {
      41             :   // Check whether the analysis, all analyses on functions, or the function's
      42             :   // CFG have been preserved.
      43             :   auto PAC = PA.getChecker<PostDominatorTreeAnalysis>();
      44         274 :   return !(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Function>>() ||
      45         136 :            PAC.preservedSet<CFGAnalyses>());
      46             : }
      47             : 
      48      153595 : bool PostDominatorTreeWrapperPass::runOnFunction(Function &F) {
      49      153595 :   DT.recalculate(F);
      50      153595 :   return false;
      51             : }
      52             : 
      53           0 : void PostDominatorTreeWrapperPass::verifyAnalysis() const {
      54             :   if (VerifyDomInfo)
      55             :     assert(DT.verify(PostDominatorTree::VerificationLevel::Full));
      56             :   else if (ExpensiveChecksEnabled)
      57             :     assert(DT.verify(PostDominatorTree::VerificationLevel::Basic));
      58           0 : }
      59             : 
      60           9 : void PostDominatorTreeWrapperPass::print(raw_ostream &OS, const Module *) const {
      61           9 :   DT.print(OS);
      62           9 : }
      63             : 
      64           0 : FunctionPass* llvm::createPostDomTree() {
      65           0 :   return new PostDominatorTreeWrapperPass();
      66             : }
      67             : 
      68             : AnalysisKey PostDominatorTreeAnalysis::Key;
      69             : 
      70         213 : PostDominatorTree PostDominatorTreeAnalysis::run(Function &F,
      71             :                                                  FunctionAnalysisManager &) {
      72         213 :   PostDominatorTree PDT(F);
      73         213 :   return PDT;
      74             : }
      75             : 
      76           5 : PostDominatorTreePrinterPass::PostDominatorTreePrinterPass(raw_ostream &OS)
      77           5 :   : OS(OS) {}
      78             : 
      79             : PreservedAnalyses
      80           5 : PostDominatorTreePrinterPass::run(Function &F, FunctionAnalysisManager &AM) {
      81           5 :   OS << "PostDominatorTree for function: " << F.getName() << "\n";
      82           5 :   AM.getResult<PostDominatorTreeAnalysis>(F).print(OS);
      83             : 
      84           5 :   return PreservedAnalyses::all();
      85             : }

Generated by: LCOV version 1.13