Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/X86/MCTargetDesc/X86WinCOFFStreamer.cpp
Line
Count
Source
1
//===-- X86WinCOFFStreamer.cpp - X86 Target WinCOFF Streamer ----*- C++ -*-===//
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
#include "X86MCTargetDesc.h"
10
#include "X86TargetStreamer.h"
11
#include "llvm/MC/MCAsmBackend.h"
12
#include "llvm/MC/MCCodeEmitter.h"
13
#include "llvm/MC/MCObjectWriter.h"
14
#include "llvm/MC/MCWin64EH.h"
15
#include "llvm/MC/MCWinCOFFStreamer.h"
16
17
using namespace llvm;
18
19
namespace {
20
class X86WinCOFFStreamer : public MCWinCOFFStreamer {
21
  Win64EH::UnwindEmitter EHStreamer;
22
public:
23
  X86WinCOFFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> AB,
24
                     std::unique_ptr<MCCodeEmitter> CE,
25
                     std::unique_ptr<MCObjectWriter> OW)
26
533
      : MCWinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW)) {}
27
28
  void EmitWinEHHandlerData(SMLoc Loc) override;
29
  void EmitWindowsUnwindTables() override;
30
  void EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) override;
31
  void FinishImpl() override;
32
};
33
34
191
void X86WinCOFFStreamer::EmitWinEHHandlerData(SMLoc Loc) {
35
191
  MCStreamer::EmitWinEHHandlerData(Loc);
36
191
37
191
  // We have to emit the unwind info now, because this directive
38
191
  // actually switches to the .xdata section!
39
191
  EHStreamer.EmitUnwindInfo(*this, getCurrentWinFrameInfo());
40
191
}
41
42
525
void X86WinCOFFStreamer::EmitWindowsUnwindTables() {
43
525
  if (!getNumWinFrameInfos())
44
447
    return;
45
78
  EHStreamer.Emit(*this);
46
78
}
47
48
82
void X86WinCOFFStreamer::EmitCVFPOData(const MCSymbol *ProcSym, SMLoc Loc) {
49
82
  X86TargetStreamer *XTS =
50
82
      static_cast<X86TargetStreamer *>(getTargetStreamer());
51
82
  XTS->emitFPOData(ProcSym, Loc);
52
82
}
53
54
525
void X86WinCOFFStreamer::FinishImpl() {
55
525
  EmitFrames(nullptr);
56
525
  EmitWindowsUnwindTables();
57
525
58
525
  MCWinCOFFStreamer::FinishImpl();
59
525
}
60
}
61
62
MCStreamer *llvm::createX86WinCOFFStreamer(MCContext &C,
63
                                           std::unique_ptr<MCAsmBackend> &&AB,
64
                                           std::unique_ptr<MCObjectWriter> &&OW,
65
                                           std::unique_ptr<MCCodeEmitter> &&CE,
66
                                           bool RelaxAll,
67
533
                                           bool IncrementalLinkerCompatible) {
68
533
  X86WinCOFFStreamer *S =
69
533
      new X86WinCOFFStreamer(C, std::move(AB), std::move(CE), std::move(OW));
70
533
  S->getAssembler().setRelaxAll(RelaxAll);
71
533
  S->getAssembler().setIncrementalLinkerCompatible(IncrementalLinkerCompatible);
72
533
  return S;
73
533
}
74