LCOV - code coverage report
Current view: top level - lib/Analysis - DominanceFrontier.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 24 30 80.0 %
Date: 2018-10-20 13:21:21 Functions: 9 11 81.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DominanceFrontier.cpp - Dominance Frontier 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             : #include "llvm/Analysis/DominanceFrontier.h"
      11             : #include "llvm/Analysis/DominanceFrontierImpl.h"
      12             : #include "llvm/Config/llvm-config.h"
      13             : #include "llvm/IR/Dominators.h"
      14             : #include "llvm/IR/Function.h"
      15             : #include "llvm/IR/PassManager.h"
      16             : #include "llvm/Pass.h"
      17             : #include "llvm/Support/Compiler.h"
      18             : #include "llvm/Support/Debug.h"
      19             : #include "llvm/Support/raw_ostream.h"
      20             : 
      21             : using namespace llvm;
      22             : 
      23             : namespace llvm {
      24             : 
      25             : template class DominanceFrontierBase<BasicBlock, false>;
      26             : template class DominanceFrontierBase<BasicBlock, true>;
      27             : template class ForwardDominanceFrontierBase<BasicBlock>;
      28             : 
      29             : } // end namespace llvm
      30             : 
      31             : char DominanceFrontierWrapperPass::ID = 0;
      32             : 
      33       60874 : INITIALIZE_PASS_BEGIN(DominanceFrontierWrapperPass, "domfrontier",
      34             :                 "Dominance Frontier Construction", true, true)
      35       60874 : INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
      36      137328 : INITIALIZE_PASS_END(DominanceFrontierWrapperPass, "domfrontier",
      37             :                 "Dominance Frontier Construction", true, true)
      38             : 
      39        4824 : DominanceFrontierWrapperPass::DominanceFrontierWrapperPass()
      40        4824 :     : FunctionPass(ID), DF() {
      41        4824 :   initializeDominanceFrontierWrapperPassPass(*PassRegistry::getPassRegistry());
      42        4824 : }
      43             : 
      44       49133 : void DominanceFrontierWrapperPass::releaseMemory() {
      45             :   DF.releaseMemory();
      46       49133 : }
      47             : 
      48       24589 : bool DominanceFrontierWrapperPass::runOnFunction(Function &) {
      49       24589 :   releaseMemory();
      50       24589 :   DF.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
      51       24589 :   return false;
      52             : }
      53             : 
      54        4824 : void DominanceFrontierWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
      55             :   AU.setPreservesAll();
      56             :   AU.addRequired<DominatorTreeWrapperPass>();
      57        4824 : }
      58             : 
      59           2 : void DominanceFrontierWrapperPass::print(raw_ostream &OS, const Module *) const {
      60           2 :   DF.print(OS);
      61           2 : }
      62             : 
      63             : #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
      64             : LLVM_DUMP_METHOD void DominanceFrontierWrapperPass::dump() const {
      65             :   print(dbgs());
      66             : }
      67             : #endif
      68             : 
      69             : /// Handle invalidation explicitly.
      70          19 : bool DominanceFrontier::invalidate(Function &F, const PreservedAnalyses &PA,
      71             :                                    FunctionAnalysisManager::Invalidator &) {
      72             :   // Check whether the analysis, all analyses on functions, or the function's
      73             :   // CFG have been preserved.
      74             :   auto PAC = PA.getChecker<DominanceFrontierAnalysis>();
      75          38 :   return !(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Function>>() ||
      76          19 :            PAC.preservedSet<CFGAnalyses>());
      77             : }
      78             : 
      79             : AnalysisKey DominanceFrontierAnalysis::Key;
      80             : 
      81          30 : DominanceFrontier DominanceFrontierAnalysis::run(Function &F,
      82             :                                                  FunctionAnalysisManager &AM) {
      83             :   DominanceFrontier DF;
      84          30 :   DF.analyze(AM.getResult<DominatorTreeAnalysis>(F));
      85          30 :   return DF;
      86             : }
      87             : 
      88           0 : DominanceFrontierPrinterPass::DominanceFrontierPrinterPass(raw_ostream &OS)
      89           0 :   : OS(OS) {}
      90             : 
      91             : PreservedAnalyses
      92           0 : DominanceFrontierPrinterPass::run(Function &F, FunctionAnalysisManager &AM) {
      93           0 :   OS << "DominanceFrontier for function: " << F.getName() << "\n";
      94           0 :   AM.getResult<DominanceFrontierAnalysis>(F).print(OS);
      95             : 
      96           0 :   return PreservedAnalyses::all();
      97             : }

Generated by: LCOV version 1.13