Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/CodeGen/FEntryInserter.cpp
Line
Count
Source
1
//===-- FEntryInsertion.cpp - Patchable prologues for LLVM -------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file edits function bodies to insert fentry calls.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm/CodeGen/MachineFunction.h"
14
#include "llvm/CodeGen/MachineFunctionPass.h"
15
#include "llvm/CodeGen/MachineInstrBuilder.h"
16
#include "llvm/CodeGen/Passes.h"
17
#include "llvm/CodeGen/TargetFrameLowering.h"
18
#include "llvm/CodeGen/TargetInstrInfo.h"
19
#include "llvm/CodeGen/TargetSubtargetInfo.h"
20
#include "llvm/IR/Function.h"
21
#include "llvm/IR/Module.h"
22
23
using namespace llvm;
24
25
namespace {
26
struct FEntryInserter : public MachineFunctionPass {
27
  static char ID; // Pass identification, replacement for typeid
28
36.3k
  FEntryInserter() : MachineFunctionPass(ID) {
29
36.3k
    initializeFEntryInserterPass(*PassRegistry::getPassRegistry());
30
36.3k
  }
31
32
  bool runOnMachineFunction(MachineFunction &F) override;
33
};
34
}
35
36
498k
bool FEntryInserter::runOnMachineFunction(MachineFunction &MF) {
37
498k
  const std::string FEntryName =
38
498k
      MF.getFunction().getFnAttribute("fentry-call").getValueAsString();
39
498k
  if (FEntryName != "true")
40
498k
    return false;
41
18.4E
42
18.4E
  auto &FirstMBB = *MF.begin();
43
18.4E
  auto *TII = MF.getSubtarget().getInstrInfo();
44
18.4E
  BuildMI(FirstMBB, FirstMBB.begin(), DebugLoc(),
45
18.4E
          TII->get(TargetOpcode::FENTRY_CALL));
46
18.4E
  return true;
47
18.4E
}
48
49
char FEntryInserter::ID = 0;
50
char &llvm::FEntryInserterID = FEntryInserter::ID;
51
INITIALIZE_PASS(FEntryInserter, "fentry-insert", "Insert fentry calls", false,
52
                false)