Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- AArch64TargetObjectFile.cpp - AArch64 Object Info -----------------===//
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
#include "AArch64TargetObjectFile.h"
11
#include "AArch64TargetMachine.h"
12
#include "llvm/BinaryFormat/Dwarf.h"
13
#include "llvm/IR/Mangler.h"
14
#include "llvm/MC/MCContext.h"
15
#include "llvm/MC/MCExpr.h"
16
#include "llvm/MC/MCStreamer.h"
17
#include "llvm/MC/MCValue.h"
18
using namespace llvm;
19
using namespace dwarf;
20
21
void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx,
22
694
                                             const TargetMachine &TM) {
23
694
  TargetLoweringObjectFileELF::Initialize(Ctx, TM);
24
694
  InitializeELF(TM.Options.UseInitArray);
25
694
}
26
27
AArch64_MachoTargetObjectFile::AArch64_MachoTargetObjectFile()
28
13.3k
  : TargetLoweringObjectFileMachO() {
29
13.3k
  SupportGOTPCRelWithOffset = false;
30
13.3k
}
31
32
const MCExpr *AArch64_MachoTargetObjectFile::getTTypeGlobalReference(
33
    const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
34
252
    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
35
252
  // On Darwin, we can reference dwarf symbols with foo@GOT-., which
36
252
  // is an indirect pc-relative reference. The default implementation
37
252
  // won't reference using the GOT, so we need this target-specific
38
252
  // version.
39
252
  if (
Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)252
) {
40
252
    const MCSymbol *Sym = TM.getSymbol(GV);
41
252
    const MCExpr *Res =
42
252
        MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, getContext());
43
252
    MCSymbol *PCSym = getContext().createTempSymbol();
44
252
    Streamer.EmitLabel(PCSym);
45
252
    const MCExpr *PC = MCSymbolRefExpr::create(PCSym, getContext());
46
252
    return MCBinaryExpr::createSub(Res, PC, getContext());
47
252
  }
48
0
49
0
  return TargetLoweringObjectFileMachO::getTTypeGlobalReference(
50
0
      GV, Encoding, TM, MMI, Streamer);
51
0
}
52
53
MCSymbol *AArch64_MachoTargetObjectFile::getCFIPersonalitySymbol(
54
    const GlobalValue *GV, const TargetMachine &TM,
55
2.67k
    MachineModuleInfo *MMI) const {
56
2.67k
  return TM.getSymbol(GV);
57
2.67k
}
58
59
const MCExpr *AArch64_MachoTargetObjectFile::getIndirectSymViaGOTPCRel(
60
    const MCSymbol *Sym, const MCValue &MV, int64_t Offset,
61
3
    MachineModuleInfo *MMI, MCStreamer &Streamer) const {
62
3
  assert((Offset+MV.getConstant() == 0) &&
63
3
         "Arch64 does not support GOT PC rel with extra offset");
64
3
  // On ARM64 Darwin, we can reference symbols with foo@GOT-., which
65
3
  // is an indirect pc-relative reference.
66
3
  const MCExpr *Res =
67
3
      MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, getContext());
68
3
  MCSymbol *PCSym = getContext().createTempSymbol();
69
3
  Streamer.EmitLabel(PCSym);
70
3
  const MCExpr *PC = MCSymbolRefExpr::create(PCSym, getContext());
71
3
  return MCBinaryExpr::createSub(Res, PC, getContext());
72
3
}
73
74
void AArch64_MachoTargetObjectFile::getNameWithPrefix(
75
    SmallVectorImpl<char> &OutName, const GlobalValue *GV,
76
2.87M
    const TargetMachine &TM) const {
77
2.87M
  // AArch64 does not use section-relative relocations so any global symbol must
78
2.87M
  // be accessed via at least a linker-private symbol.
79
2.87M
  getMangler().getNameWithPrefix(OutName, GV, /* CannotUsePrivateLabel */ true);
80
2.87M
}