Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- CodeGen/AsmPrinter/WinCFGuard.cpp - Control Flow Guard Impl ------===//
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 contains support for writing Win64 exception info into asm files.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "WinCFGuard.h"
14
#include "llvm/CodeGen/AsmPrinter.h"
15
#include "llvm/CodeGen/MachineFunction.h"
16
#include "llvm/CodeGen/MachineModuleInfo.h"
17
#include "llvm/CodeGen/MachineOperand.h"
18
#include "llvm/IR/Constants.h"
19
#include "llvm/IR/Metadata.h"
20
#include "llvm/MC/MCAsmInfo.h"
21
#include "llvm/MC/MCObjectFileInfo.h"
22
#include "llvm/MC/MCStreamer.h"
23
24
#include <vector>
25
26
using namespace llvm;
27
28
1
WinCFGuard::WinCFGuard(AsmPrinter *A) : AsmPrinterHandler(), Asm(A) {}
29
30
1
WinCFGuard::~WinCFGuard() {}
31
32
1
void WinCFGuard::endModule() {
33
1
  const Module *M = Asm->MMI->getModule();
34
1
  std::vector<const Function *> Functions;
35
1
  for (const Function &F : *M)
36
9
    if (F.hasAddressTaken())
37
4
      Functions.push_back(&F);
38
1
  if (Functions.empty())
39
0
    return;
40
1
  auto &OS = *Asm->OutStreamer;
41
1
  OS.SwitchSection(Asm->OutContext.getObjectFileInfo()->getGFIDsSection());
42
1
  for (const Function *F : Functions)
43
4
    OS.EmitCOFFSymbolIndex(Asm->getSymbol(F));
44
1
}