Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/X86/X86TargetObjectFile.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- X86TargetObjectFile.cpp - X86 Object Info -------------------------===//
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 "X86TargetObjectFile.h"
10
#include "llvm/ADT/StringExtras.h"
11
#include "llvm/BinaryFormat/COFF.h"
12
#include "llvm/BinaryFormat/Dwarf.h"
13
#include "llvm/CodeGen/TargetLowering.h"
14
#include "llvm/IR/Mangler.h"
15
#include "llvm/IR/Operator.h"
16
#include "llvm/MC/MCContext.h"
17
#include "llvm/MC/MCExpr.h"
18
#include "llvm/MC/MCSectionCOFF.h"
19
#include "llvm/MC/MCSectionELF.h"
20
#include "llvm/MC/MCValue.h"
21
22
using namespace llvm;
23
using namespace dwarf;
24
25
const MCExpr *X86_64MachoTargetObjectFile::getTTypeGlobalReference(
26
    const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
27
11
    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
28
11
29
11
  // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
30
11
  // is an indirect pc-relative reference.
31
11
  if ((Encoding & DW_EH_PE_indirect) && (Encoding & DW_EH_PE_pcrel)) {
32
11
    const MCSymbol *Sym = TM.getSymbol(GV);
33
11
    const MCExpr *Res =
34
11
      MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
35
11
    const MCExpr *Four = MCConstantExpr::create(4, getContext());
36
11
    return MCBinaryExpr::createAdd(Res, Four, getContext());
37
11
  }
38
0
39
0
  return TargetLoweringObjectFileMachO::getTTypeGlobalReference(
40
0
      GV, Encoding, TM, MMI, Streamer);
41
0
}
42
43
MCSymbol *X86_64MachoTargetObjectFile::getCFIPersonalitySymbol(
44
    const GlobalValue *GV, const TargetMachine &TM,
45
39
    MachineModuleInfo *MMI) const {
46
39
  return TM.getSymbol(GV);
47
39
}
48
49
const MCExpr *X86_64MachoTargetObjectFile::getIndirectSymViaGOTPCRel(
50
    const MCSymbol *Sym, const MCValue &MV, int64_t Offset,
51
5
    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
52
5
  // On Darwin/X86-64, we need to use foo@GOTPCREL+4 to access the got entry
53
5
  // from a data section. In case there's an additional offset, then use
54
5
  // foo@GOTPCREL+4+<offset>.
55
5
  unsigned FinalOff = Offset+MV.getConstant()+4;
56
5
  const MCExpr *Res =
57
5
    MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
58
5
  const MCExpr *Off = MCConstantExpr::create(FinalOff, getContext());
59
5
  return MCBinaryExpr::createAdd(Res, Off, getContext());
60
5
}
61
62
const MCExpr *X86ELFTargetObjectFile::getDebugThreadLocalSymbol(
63
16
    const MCSymbol *Sym) const {
64
16
  return MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_DTPOFF, getContext());
65
16
}
66
67
void
68
X86FreeBSDTargetObjectFile::Initialize(MCContext &Ctx,
69
25
                                       const TargetMachine &TM) {
70
25
  TargetLoweringObjectFileELF::Initialize(Ctx, TM);
71
25
  InitializeELF(TM.Options.UseInitArray);
72
25
}
73
74
void
75
X86FuchsiaTargetObjectFile::Initialize(MCContext &Ctx,
76
5
                                       const TargetMachine &TM) {
77
5
  TargetLoweringObjectFileELF::Initialize(Ctx, TM);
78
5
  InitializeELF(TM.Options.UseInitArray);
79
5
}
80
81
void
82
X86LinuxNaClTargetObjectFile::Initialize(MCContext &Ctx,
83
2.37k
                                         const TargetMachine &TM) {
84
2.37k
  TargetLoweringObjectFileELF::Initialize(Ctx, TM);
85
2.37k
  InitializeELF(TM.Options.UseInitArray);
86
2.37k
}
87
88
void X86SolarisTargetObjectFile::Initialize(MCContext &Ctx,
89
5
                                            const TargetMachine &TM) {
90
5
  TargetLoweringObjectFileELF::Initialize(Ctx, TM);
91
5
  InitializeELF(TM.Options.UseInitArray);
92
5
}