LCOV - code coverage report
Current view: top level - lib/CodeGen - MachineRegionInfo.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 5 50 10.0 %
Date: 2017-09-14 15:23:50 Functions: 2 12 16.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- lib/Codegen/MachineRegionInfo.cpp ----------------------------------===//
       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/CodeGen/MachineRegionInfo.h"
      11             : #include "llvm/ADT/Statistic.h"
      12             : #include "llvm/Analysis/RegionInfoImpl.h"
      13             : #include "llvm/CodeGen/MachinePostDominators.h"
      14             : #include "llvm/Pass.h"
      15             : #include "llvm/Support/Compiler.h"
      16             : #include "llvm/Support/Debug.h"
      17             : 
      18             : #define DEBUG_TYPE "machine-region-info"
      19             : 
      20             : using namespace llvm;
      21             : 
      22             : STATISTIC(numMachineRegions,       "The # of machine regions");
      23             : STATISTIC(numMachineSimpleRegions, "The # of simple machine regions");
      24             : 
      25             : namespace llvm {
      26             : 
      27             : template class RegionBase<RegionTraits<MachineFunction>>;
      28             : template class RegionNodeBase<RegionTraits<MachineFunction>>;
      29             : template class RegionInfoBase<RegionTraits<MachineFunction>>;
      30             : 
      31             : } // end namespace llvm
      32             : 
      33             : //===----------------------------------------------------------------------===//
      34             : // MachineRegion implementation
      35             : 
      36           0 : MachineRegion::MachineRegion(MachineBasicBlock *Entry, MachineBasicBlock *Exit,
      37             :                              MachineRegionInfo* RI,
      38           0 :                              MachineDominatorTree *DT, MachineRegion *Parent) :
      39           0 :   RegionBase<RegionTraits<MachineFunction>>(Entry, Exit, RI, DT, Parent) {}
      40             : 
      41             : MachineRegion::~MachineRegion() = default;
      42             : 
      43             : //===----------------------------------------------------------------------===//
      44             : // MachineRegionInfo implementation
      45             : 
      46             : MachineRegionInfo::MachineRegionInfo() = default;
      47             : 
      48             : MachineRegionInfo::~MachineRegionInfo() = default;
      49             : 
      50           0 : void MachineRegionInfo::updateStatistics(MachineRegion *R) {
      51           0 :   ++numMachineRegions;
      52             : 
      53             :   // TODO: Slow. Should only be enabled if -stats is used.
      54           0 :   if (R->isSimple())
      55             :     ++numMachineSimpleRegions;
      56           0 : }
      57             : 
      58           0 : void MachineRegionInfo::recalculate(MachineFunction &F,
      59             :                                     MachineDominatorTree *DT_,
      60             :                                     MachinePostDominatorTree *PDT_,
      61             :                                     MachineDominanceFrontier *DF_) {
      62           0 :   DT = DT_;
      63           0 :   PDT = PDT_;
      64           0 :   DF = DF_;
      65             : 
      66           0 :   MachineBasicBlock *Entry = GraphTraits<MachineFunction*>::getEntryNode(&F);
      67             : 
      68           0 :   TopLevelRegion = new MachineRegion(Entry, nullptr, this, DT, nullptr);
      69           0 :   updateStatistics(TopLevelRegion);
      70           0 :   calculate(F);
      71           0 : }
      72             : 
      73             : //===----------------------------------------------------------------------===//
      74             : // MachineRegionInfoPass implementation
      75             : //
      76             : 
      77           0 : MachineRegionInfoPass::MachineRegionInfoPass() : MachineFunctionPass(ID) {
      78           0 :   initializeMachineRegionInfoPassPass(*PassRegistry::getPassRegistry());
      79           0 : }
      80             : 
      81             : MachineRegionInfoPass::~MachineRegionInfoPass() = default;
      82             : 
      83           0 : bool MachineRegionInfoPass::runOnMachineFunction(MachineFunction &F) {
      84           0 :   releaseMemory();
      85             : 
      86           0 :   auto DT = &getAnalysis<MachineDominatorTree>();
      87           0 :   auto PDT = &getAnalysis<MachinePostDominatorTree>();
      88           0 :   auto DF = &getAnalysis<MachineDominanceFrontier>();
      89             : 
      90           0 :   RI.recalculate(F, DT, PDT, DF);
      91             : 
      92             :   DEBUG(RI.dump());
      93             : 
      94           0 :   return false;
      95             : }
      96             : 
      97           0 : void MachineRegionInfoPass::releaseMemory() {
      98           0 :   RI.releaseMemory();
      99           0 : }
     100             : 
     101           0 : void MachineRegionInfoPass::verifyAnalysis() const {
     102             :   // Only do verification when user wants to, otherwise this expensive check
     103             :   // will be invoked by PMDataManager::verifyPreservedAnalysis when
     104             :   // a regionpass (marked PreservedAll) finish.
     105           0 :   if (MachineRegionInfo::VerifyRegionInfo)
     106           0 :     RI.verifyAnalysis();
     107           0 : }
     108             : 
     109           0 : void MachineRegionInfoPass::getAnalysisUsage(AnalysisUsage &AU) const {
     110           0 :   AU.setPreservesAll();
     111           0 :   AU.addRequired<MachineDominatorTree>();
     112           0 :   AU.addRequired<MachinePostDominatorTree>();
     113           0 :   AU.addRequired<MachineDominanceFrontier>();
     114           0 :   MachineFunctionPass::getAnalysisUsage(AU);
     115           0 : }
     116             : 
     117           0 : void MachineRegionInfoPass::print(raw_ostream &OS, const Module *) const {
     118           0 :   RI.print(OS);
     119           0 : }
     120             : 
     121             : #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
     122             : LLVM_DUMP_METHOD void MachineRegionInfoPass::dump() const {
     123             :   RI.dump();
     124             : }
     125             : #endif
     126             : 
     127             : char MachineRegionInfoPass::ID = 0;
     128             : char &MachineRegionInfoPassID = MachineRegionInfoPass::ID;
     129             : 
     130       20212 : INITIALIZE_PASS_BEGIN(MachineRegionInfoPass, DEBUG_TYPE,
     131             :                       "Detect single entry single exit regions", true, true)
     132       20212 : INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree)
     133       20212 : INITIALIZE_PASS_DEPENDENCY(MachinePostDominatorTree)
     134       20212 : INITIALIZE_PASS_DEPENDENCY(MachineDominanceFrontier)
     135      151199 : INITIALIZE_PASS_END(MachineRegionInfoPass, DEBUG_TYPE,
     136             :                     "Detect single entry single exit regions", true, true)
     137             : 
     138             : // Create methods available outside of this file, to use them
     139             : // "include/llvm/LinkAllPasses.h". Otherwise the pass would be deleted by
     140             : // the link time optimization.
     141             : 
     142             : namespace llvm {
     143             : 
     144           0 : FunctionPass *createMachineRegionInfoPass() {
     145           0 :   return new MachineRegionInfoPass();
     146             : }
     147             : 
     148             : } // end namespace llvm

Generated by: LCOV version 1.13