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

Generated by: LCOV version 1.13