Coverage Report

Created: 2019-07-24 05:18

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