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

          Line data    Source code
       1             : //===-- FEntryInsertion.cpp - Patchable prologues for LLVM -------------===//
       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 edits function bodies to insert fentry calls.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/CodeGen/MachineFunction.h"
      15             : #include "llvm/CodeGen/MachineFunctionPass.h"
      16             : #include "llvm/CodeGen/MachineInstrBuilder.h"
      17             : #include "llvm/CodeGen/Passes.h"
      18             : #include "llvm/IR/Function.h"
      19             : #include "llvm/IR/Module.h"
      20             : #include "llvm/Target/TargetFrameLowering.h"
      21             : #include "llvm/Target/TargetInstrInfo.h"
      22             : #include "llvm/Target/TargetSubtargetInfo.h"
      23             : 
      24             : using namespace llvm;
      25             : 
      26             : namespace {
      27       16820 : struct FEntryInserter : public MachineFunctionPass {
      28             :   static char ID; // Pass identification, replacement for typeid
      29       16923 :   FEntryInserter() : MachineFunctionPass(ID) {
      30       16923 :     initializeFEntryInserterPass(*PassRegistry::getPassRegistry());
      31       16923 :   }
      32             : 
      33             :   bool runOnMachineFunction(MachineFunction &F) override;
      34             : };
      35             : }
      36             : 
      37      142734 : bool FEntryInserter::runOnMachineFunction(MachineFunction &MF) {
      38             :   const std::string FEntryName =
      39      570936 :       MF.getFunction()->getFnAttribute("fentry-call").getValueAsString();
      40      142734 :   if (FEntryName != "true")
      41             :     return false;
      42             : 
      43           4 :   auto &FirstMBB = *MF.begin();
      44           2 :   auto *TII = MF.getSubtarget().getInstrInfo();
      45           8 :   BuildMI(FirstMBB, FirstMBB.begin(), DebugLoc(),
      46           6 :           TII->get(TargetOpcode::FENTRY_CALL));
      47           2 :   return true;
      48             : }
      49             : 
      50             : char FEntryInserter::ID = 0;
      51             : char &llvm::FEntryInserterID = FEntryInserter::ID;
      52      201968 : INITIALIZE_PASS(FEntryInserter, "fentry-insert", "Insert fentry calls", false,
      53             :                 false)

Generated by: LCOV version 1.13