LCOV - code coverage report
Current view: top level - lib/CodeGen - TailDuplication.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 14 14 100.0 %
Date: 2017-09-14 15:23:50 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- TailDuplication.cpp - Duplicate blocks into predecessors' tails ----===//
       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 pass duplicates basic blocks ending in unconditional branches into
      11             : // the tails of their predecessors, using the TailDuplicator utility class.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
      16             : #include "llvm/CodeGen/MachineFunction.h"
      17             : #include "llvm/CodeGen/MachineFunctionPass.h"
      18             : #include "llvm/CodeGen/TailDuplicator.h"
      19             : #include "llvm/Pass.h"
      20             : 
      21             : using namespace llvm;
      22             : 
      23             : #define DEBUG_TYPE "tailduplication"
      24             : 
      25             : namespace {
      26             : 
      27             : /// Perform tail duplication. Delegates to TailDuplicator
      28       30591 : class TailDuplicatePass : public MachineFunctionPass {
      29             :   TailDuplicator Duplicator;
      30             : 
      31             : public:
      32             :   static char ID;
      33             : 
      34       61560 :   explicit TailDuplicatePass() : MachineFunctionPass(ID) {}
      35             : 
      36             :   bool runOnMachineFunction(MachineFunction &MF) override;
      37             : 
      38             :   void getAnalysisUsage(AnalysisUsage &AU) const override;
      39             : };
      40             : 
      41             : } // end anonymous namespace
      42             : 
      43             : char TailDuplicatePass::ID = 0;
      44             : 
      45             : char &llvm::TailDuplicateID = TailDuplicatePass::ID;
      46             : 
      47      151199 : INITIALIZE_PASS(TailDuplicatePass, DEBUG_TYPE, "Tail Duplication", false, false)
      48             : 
      49      268479 : bool TailDuplicatePass::runOnMachineFunction(MachineFunction &MF) {
      50      268479 :   if (skipFunction(*MF.getFunction()))
      51             :     return false;
      52             : 
      53      268365 :   auto MBPI = &getAnalysis<MachineBranchProbabilityInfo>();
      54             : 
      55             :   // TODO: Querying isSSA() to determine pre-/post-regalloc is fragile, better
      56             :   // split this into two passes instead.
      57      536730 :   bool PreRegAlloc = MF.getRegInfo().isSSA();
      58      268365 :   Duplicator.initMF(MF, PreRegAlloc, MBPI, /* LayoutMode */ false);
      59             : 
      60      268365 :   bool MadeChange = false;
      61      269555 :   while (Duplicator.tailDuplicateBlocks())
      62             :     MadeChange = true;
      63             : 
      64             :   return MadeChange;
      65             : }
      66             : 
      67       30680 : void TailDuplicatePass::getAnalysisUsage(AnalysisUsage &AU) const {
      68       30680 :   AU.addRequired<MachineBranchProbabilityInfo>();
      69       30680 :   MachineFunctionPass::getAnalysisUsage(AU);
      70       30680 : }

Generated by: LCOV version 1.13