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

          Line data    Source code
       1             : //===-- llvm/CodeGen/ExpandISelPseudos.cpp ----------------------*- C++ -*-===//
       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             : // Expand Pseudo-instructions produced by ISel. These are usually to allow
      11             : // the expansion to contain control flow, such as a conditional move
      12             : // implemented with a conditional branch and a phi, or an atomic operation
      13             : // implemented with a loop.
      14             : //
      15             : //===----------------------------------------------------------------------===//
      16             : 
      17             : #include "llvm/CodeGen/MachineFunction.h"
      18             : #include "llvm/CodeGen/MachineFunctionPass.h"
      19             : #include "llvm/CodeGen/Passes.h"
      20             : #include "llvm/Support/Debug.h"
      21             : #include "llvm/Target/TargetLowering.h"
      22             : #include "llvm/Target/TargetSubtargetInfo.h"
      23             : using namespace llvm;
      24             : 
      25             : #define DEBUG_TYPE "expand-isel-pseudos"
      26             : 
      27             : namespace {
      28       16820 :   class ExpandISelPseudos : public MachineFunctionPass {
      29             :   public:
      30             :     static char ID; // Pass identification, replacement for typeid
      31       16922 :     ExpandISelPseudos() : MachineFunctionPass(ID) {}
      32             : 
      33             :   private:
      34             :     bool runOnMachineFunction(MachineFunction &MF) override;
      35             : 
      36       16869 :     void getAnalysisUsage(AnalysisUsage &AU) const override {
      37       16869 :       MachineFunctionPass::getAnalysisUsage(AU);
      38       16869 :     }
      39             :   };
      40             : } // end anonymous namespace
      41             : 
      42             : char ExpandISelPseudos::ID = 0;
      43             : char &llvm::ExpandISelPseudosID = ExpandISelPseudos::ID;
      44      151199 : INITIALIZE_PASS(ExpandISelPseudos, DEBUG_TYPE,
      45             :                 "Expand ISel Pseudo-instructions", false, false)
      46             : 
      47      142764 : bool ExpandISelPseudos::runOnMachineFunction(MachineFunction &MF) {
      48      142764 :   bool Changed = false;
      49      142764 :   const TargetLowering *TLI = MF.getSubtarget().getTargetLowering();
      50             : 
      51             :   // Iterate through each instruction in the function, looking for pseudos.
      52      285528 :   for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
      53      281937 :     MachineBasicBlock *MBB = &*I;
      54      563874 :     for (MachineBasicBlock::iterator MBBI = MBB->begin(), MBBE = MBB->end();
      55     4494493 :          MBBI != MBBE; ) {
      56    12637668 :       MachineInstr &MI = *MBBI++;
      57             : 
      58             :       // If MI is a pseudo, expand it.
      59     4212556 :       if (MI.usesCustomInsertionHook()) {
      60       26970 :         Changed = true;
      61       26970 :         MachineBasicBlock *NewMBB = TLI->EmitInstrWithCustomInserter(MI, MBB);
      62             :         // The expansion may involve new basic blocks.
      63       26970 :         if (NewMBB != MBB) {
      64        3517 :           MBB = NewMBB;
      65        7034 :           I = NewMBB->getIterator();
      66        3517 :           MBBI = NewMBB->begin();
      67        3517 :           MBBE = NewMBB->end();
      68             :         }
      69             :       }
      70             :     }
      71             :   }
      72             : 
      73      142764 :   return Changed;
      74             : }

Generated by: LCOV version 1.13