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

          Line data    Source code
       1             : //===-- FuncletLayout.cpp - Contiguously lay out funclets -----------------===//
       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 basic block placement transformations which result in
      11             : // funclets being contiguous.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : #include "llvm/CodeGen/Analysis.h"
      15             : #include "llvm/CodeGen/MachineFunction.h"
      16             : #include "llvm/CodeGen/MachineFunctionPass.h"
      17             : #include "llvm/CodeGen/Passes.h"
      18             : using namespace llvm;
      19             : 
      20             : #define DEBUG_TYPE "funclet-layout"
      21             : 
      22             : namespace {
      23       14896 : class FuncletLayout : public MachineFunctionPass {
      24             : public:
      25             :   static char ID; // Pass identification, replacement for typeid
      26       14983 :   FuncletLayout() : MachineFunctionPass(ID) {
      27       14983 :     initializeFuncletLayoutPass(*PassRegistry::getPassRegistry());
      28       14983 :   }
      29             : 
      30             :   bool runOnMachineFunction(MachineFunction &F) override;
      31       14930 :   MachineFunctionProperties getRequiredProperties() const override {
      32       44790 :     return MachineFunctionProperties().set(
      33       44790 :         MachineFunctionProperties::Property::NoVRegs);
      34             :   }
      35             : };
      36             : }
      37             : 
      38             : char FuncletLayout::ID = 0;
      39             : char &llvm::FuncletLayoutID = FuncletLayout::ID;
      40      196148 : INITIALIZE_PASS(FuncletLayout, DEBUG_TYPE,
      41             :                 "Contiguously Lay Out Funclets", false, false)
      42             : 
      43      124369 : bool FuncletLayout::runOnMachineFunction(MachineFunction &F) {
      44             :   DenseMap<const MachineBasicBlock *, int> FuncletMembership =
      45      248738 :       getFuncletMembership(F);
      46      124369 :   if (FuncletMembership.empty())
      47             :     return false;
      48             : 
      49         639 :   F.sort([&](MachineBasicBlock &X, MachineBasicBlock &Y) {
      50         505 :     auto FuncletX = FuncletMembership.find(&X);
      51         505 :     auto FuncletY = FuncletMembership.find(&Y);
      52             :     assert(FuncletX != FuncletMembership.end());
      53             :     assert(FuncletY != FuncletMembership.end());
      54         505 :     return FuncletX->second < FuncletY->second;
      55             :   });
      56             : 
      57             :   // Conservatively assume we changed something.
      58          67 :   return true;
      59             : }

Generated by: LCOV version 1.13