blob: 983923cbb6a197d9b3b1d302d92fb8f3628b8335 [file] [log] [blame]
Chris Lattner5e693ed2009-07-28 03:13:23 +00001//===-- llvm/Target/TargetLoweringObjectFile.cpp - Object File 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// This file implements classes used to handle lowerings specific to common
11// object file formats.
12//
13//===----------------------------------------------------------------------===//
14
David Blaikieb3bde2e2017-11-17 01:07:10 +000015#include "llvm/CodeGen/TargetLoweringObjectFile.h"
Zachary Turner264b5d92017-06-07 03:48:56 +000016#include "llvm/BinaryFormat/Dwarf.h"
David Blaikieb3bde2e2017-11-17 01:07:10 +000017#include "llvm/CodeGen/TargetLowering.h"
18#include "llvm/CodeGen/TargetSubtargetInfo.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000019#include "llvm/IR/Constants.h"
20#include "llvm/IR/DataLayout.h"
21#include "llvm/IR/DerivedTypes.h"
22#include "llvm/IR/Function.h"
23#include "llvm/IR/GlobalVariable.h"
Rafael Espindola894843c2014-01-07 21:19:40 +000024#include "llvm/IR/Mangler.h"
Rafael Espindola117b20c2013-12-05 05:53:12 +000025#include "llvm/MC/MCAsmInfo.h"
Chris Lattner4d2c0f92009-07-31 18:48:30 +000026#include "llvm/MC/MCContext.h"
Chris Lattnerb8666022009-09-16 01:46:41 +000027#include "llvm/MC/MCExpr.h"
Chris Lattner03627cb2010-03-11 21:55:20 +000028#include "llvm/MC/MCStreamer.h"
Chris Lattnerccbeed22010-01-13 21:29:21 +000029#include "llvm/MC/MCSymbol.h"
Chris Lattnerd82510e2009-11-07 09:20:54 +000030#include "llvm/Support/ErrorHandling.h"
Chris Lattnerccbeed22010-01-13 21:29:21 +000031#include "llvm/Support/raw_ostream.h"
Chandler Carruth442f7842014-03-04 10:07:28 +000032#include "llvm/Target/TargetMachine.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000033#include "llvm/Target/TargetOptions.h"
Chris Lattner5e693ed2009-07-28 03:13:23 +000034using namespace llvm;
35
36//===----------------------------------------------------------------------===//
37// Generic Code
38//===----------------------------------------------------------------------===//
39
Evan Cheng76792992011-07-20 05:58:47 +000040/// Initialize - this method must be called before any actual lowering is
41/// done. This specifies the current context for codegen, and gives the
42/// lowering implementations a chance to set up their default sections.
43void TargetLoweringObjectFile::Initialize(MCContext &ctx,
44 const TargetMachine &TM) {
45 Ctx = &ctx;
Eric Liud07ad512016-09-16 11:50:57 +000046 // `Initialize` can be called more than once.
Gabor Horvath43b72d52017-05-01 16:18:42 +000047 delete Mang;
Eric Christopher4367c7f2016-09-16 07:33:15 +000048 Mang = new Mangler();
Rafael Espindola9f929952017-08-02 20:32:26 +000049 InitMCObjectFileInfo(TM.getTargetTriple(), TM.isPositionIndependent(), *Ctx,
50 TM.getCodeModel() == CodeModel::Large);
Chris Lattner5e693ed2009-07-28 03:13:23 +000051}
Saleem Abdulrasool0d3d6c42014-04-16 04:15:25 +000052
Chris Lattner5e693ed2009-07-28 03:13:23 +000053TargetLoweringObjectFile::~TargetLoweringObjectFile() {
Eric Christopher4367c7f2016-09-16 07:33:15 +000054 delete Mang;
Chris Lattner5e693ed2009-07-28 03:13:23 +000055}
56
Nick Lewycky50f02cb2011-12-02 22:16:29 +000057static bool isSuitableForBSS(const GlobalVariable *GV, bool NoZerosInBSS) {
Jay Foad60020682011-06-19 18:37:11 +000058 const Constant *C = GV->getInitializer();
Anton Korobeynikov1df58862009-09-09 08:41:20 +000059
Chris Lattner5e693ed2009-07-28 03:13:23 +000060 // Must have zero initializer.
61 if (!C->isNullValue())
62 return false;
Anton Korobeynikov1df58862009-09-09 08:41:20 +000063
Chris Lattner5e693ed2009-07-28 03:13:23 +000064 // Leave constant zeros in readonly constant sections, so they can be shared.
65 if (GV->isConstant())
66 return false;
Anton Korobeynikov1df58862009-09-09 08:41:20 +000067
Chris Lattner5e693ed2009-07-28 03:13:23 +000068 // If the global has an explicit section specified, don't put it in BSS.
David Majnemer483e4e02014-05-17 05:18:40 +000069 if (GV->hasSection())
Chris Lattner5e693ed2009-07-28 03:13:23 +000070 return false;
Anton Korobeynikov1df58862009-09-09 08:41:20 +000071
Chris Lattner5e693ed2009-07-28 03:13:23 +000072 // If -nozero-initialized-in-bss is specified, don't ever use BSS.
73 if (NoZerosInBSS)
74 return false;
Anton Korobeynikov1df58862009-09-09 08:41:20 +000075
Chris Lattner5e693ed2009-07-28 03:13:23 +000076 // Otherwise, put it in BSS!
77 return true;
78}
79
Chris Lattner81bbf442009-08-04 16:13:09 +000080/// IsNullTerminatedString - Return true if the specified constant (which is
81/// known to have a type that is an array of 1/2/4 byte elements) ends with a
Chris Lattner139822f2012-01-24 14:17:05 +000082/// nul value and contains no other nuls in it. Note that this is more general
83/// than ConstantDataSequential::isString because we allow 2 & 4 byte strings.
Chris Lattner81bbf442009-08-04 16:13:09 +000084static bool IsNullTerminatedString(const Constant *C) {
Chris Lattner139822f2012-01-24 14:17:05 +000085 // First check: is we have constant array terminated with zero
Chris Lattner139822f2012-01-24 14:17:05 +000086 if (const ConstantDataSequential *CDS = dyn_cast<ConstantDataSequential>(C)) {
87 unsigned NumElts = CDS->getNumElements();
88 assert(NumElts != 0 && "Can't have an empty CDS");
89
90 if (CDS->getElementAsInteger(NumElts-1) != 0)
91 return false; // Not null terminated.
92
93 // Verify that the null doesn't occur anywhere else in the string.
94 for (unsigned i = 0; i != NumElts-1; ++i)
95 if (CDS->getElementAsInteger(i) == 0)
96 return false;
97 return true;
98 }
Chris Lattner5e693ed2009-07-28 03:13:23 +000099
100 // Another possibility: [1 x i8] zeroinitializer
101 if (isa<ConstantAggregateZero>(C))
Chris Lattner139822f2012-01-24 14:17:05 +0000102 return cast<ArrayType>(C->getType())->getNumElements() == 1;
Chris Lattner5e693ed2009-07-28 03:13:23 +0000103
104 return false;
105}
106
Rafael Espindolaf4e6b292013-12-02 16:25:47 +0000107MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
Eric Christopher4367c7f2016-09-16 07:33:15 +0000108 const GlobalValue *GV, StringRef Suffix, const TargetMachine &TM) const {
Rafael Espindola117b20c2013-12-05 05:53:12 +0000109 assert(!Suffix.empty());
Rafael Espindola117b20c2013-12-05 05:53:12 +0000110
Rafael Espindolaf4e6b292013-12-02 16:25:47 +0000111 SmallString<60> NameStr;
Mehdi Amini5c0fa582015-07-16 06:04:17 +0000112 NameStr += GV->getParent()->getDataLayout().getPrivateGlobalPrefix();
Eric Christopher4367c7f2016-09-16 07:33:15 +0000113 TM.getNameWithPrefix(NameStr, GV, *Mang);
Rafael Espindolaf4e6b292013-12-02 16:25:47 +0000114 NameStr.append(Suffix.begin(), Suffix.end());
Jim Grosbach6f482002015-05-18 18:43:14 +0000115 return Ctx->getOrCreateSymbol(NameStr);
Rafael Espindolaf4e6b292013-12-02 16:25:47 +0000116}
Rafael Espindolae133ed82013-10-29 17:28:26 +0000117
Rafael Espindoladaeafb42014-02-19 17:23:20 +0000118MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol(
Eric Christopher4367c7f2016-09-16 07:33:15 +0000119 const GlobalValue *GV, const TargetMachine &TM,
Rafael Espindoladaeafb42014-02-19 17:23:20 +0000120 MachineModuleInfo *MMI) const {
Tim Northoverb64fb452016-11-22 16:17:20 +0000121 return TM.getSymbol(GV);
Rafael Espindolaa83b1772011-04-16 03:51:21 +0000122}
123
124void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
Mehdi Amini5c0fa582015-07-16 06:04:17 +0000125 const DataLayout &,
Rafael Espindolaa83b1772011-04-16 03:51:21 +0000126 const MCSymbol *Sym) const {
Rafael Espindolaa83b1772011-04-16 03:51:21 +0000127}
128
129
Chris Lattnercbc7b262009-08-05 04:25:40 +0000130/// getKindForGlobal - This is a top-level target-independent classifier for
Chris Lattnerc9c277b2009-08-01 21:11:14 +0000131/// a global variable. Given an global variable and information from TM, it
132/// classifies the global in a variety of ways that make various target
133/// implementations simpler. The target implementation is free to ignore this
134/// extra info of course.
Peter Collingbourne67335642016-10-24 19:23:39 +0000135SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalObject *GO,
Chris Lattnercbc7b262009-08-05 04:25:40 +0000136 const TargetMachine &TM){
Peter Collingbourne67335642016-10-24 19:23:39 +0000137 assert(!GO->isDeclaration() && !GO->hasAvailableExternallyLinkage() &&
Chris Lattnercbc7b262009-08-05 04:25:40 +0000138 "Can only be used for global definitions");
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000139
Chris Lattner5e693ed2009-07-28 03:13:23 +0000140 Reloc::Model ReloModel = TM.getRelocationModel();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000141
Chris Lattner5e693ed2009-07-28 03:13:23 +0000142 // Early exit - functions should be always in text sections.
Peter Collingbourne67335642016-10-24 19:23:39 +0000143 const auto *GVar = dyn_cast<GlobalVariable>(GO);
Craig Topper062a2ba2014-04-25 05:30:21 +0000144 if (!GVar)
Chris Lattnerf8d97102009-08-01 23:57:16 +0000145 return SectionKind::getText();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000146
Chris Lattner5e693ed2009-07-28 03:13:23 +0000147 // Handle thread-local data first.
148 if (GVar->isThreadLocal()) {
Nick Lewycky50f02cb2011-12-02 22:16:29 +0000149 if (isSuitableForBSS(GVar, TM.Options.NoZerosInBSS))
Chris Lattnerf8d97102009-08-01 23:57:16 +0000150 return SectionKind::getThreadBSS();
151 return SectionKind::getThreadData();
Chris Lattner5e693ed2009-07-28 03:13:23 +0000152 }
153
Chris Lattner5b585f82010-01-19 02:48:26 +0000154 // Variables with common linkage always get classified as common.
155 if (GVar->hasCommonLinkage())
156 return SectionKind::getCommon();
157
Chris Lattner5e693ed2009-07-28 03:13:23 +0000158 // Variable can be easily put to BSS section.
Nick Lewycky50f02cb2011-12-02 22:16:29 +0000159 if (isSuitableForBSS(GVar, TM.Options.NoZerosInBSS)) {
Chris Lattnerb2534212010-01-19 04:15:51 +0000160 if (GVar->hasLocalLinkage())
161 return SectionKind::getBSSLocal();
162 else if (GVar->hasExternalLinkage())
163 return SectionKind::getBSSExtern();
Chris Lattnerf8d97102009-08-01 23:57:16 +0000164 return SectionKind::getBSS();
Chris Lattnerb2534212010-01-19 04:15:51 +0000165 }
Chris Lattner5e693ed2009-07-28 03:13:23 +0000166
Jay Foad60020682011-06-19 18:37:11 +0000167 const Constant *C = GVar->getInitializer();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000168
Chris Lattner5e693ed2009-07-28 03:13:23 +0000169 // If the global is marked constant, we can put it into a mergable section,
170 // a mergable string section, or general .data if it contains relocations.
Chris Lattnerea4e9832011-01-18 01:23:44 +0000171 if (GVar->isConstant()) {
Chris Lattner5e693ed2009-07-28 03:13:23 +0000172 // If the initializer for the global contains something that requires a
Eric Christopherde9e92e2012-05-05 01:16:06 +0000173 // relocation, then we may have to drop this into a writable data section
Chris Lattner5e693ed2009-07-28 03:13:23 +0000174 // even though it is marked const.
Rafael Espindola65e49022015-11-17 00:51:23 +0000175 if (!C->needsRelocation()) {
Chris Lattnerea4e9832011-01-18 01:23:44 +0000176 // If the global is required to have a unique address, it can't be put
177 // into a mergable section: just drop it into the general read-only
178 // section instead.
Peter Collingbourne96efdd62016-06-14 21:01:22 +0000179 if (!GVar->hasGlobalUnnamedAddr())
Chris Lattnerea4e9832011-01-18 01:23:44 +0000180 return SectionKind::getReadOnly();
Rafael Espindola65e49022015-11-17 00:51:23 +0000181
Chris Lattner5e693ed2009-07-28 03:13:23 +0000182 // If initializer is a null-terminated string, put it in a "cstring"
Chris Lattner81bbf442009-08-04 16:13:09 +0000183 // section of the right width.
Chris Lattner229907c2011-07-18 04:54:35 +0000184 if (ArrayType *ATy = dyn_cast<ArrayType>(C->getType())) {
185 if (IntegerType *ITy =
Chris Lattner81bbf442009-08-04 16:13:09 +0000186 dyn_cast<IntegerType>(ATy->getElementType())) {
187 if ((ITy->getBitWidth() == 8 || ITy->getBitWidth() == 16 ||
188 ITy->getBitWidth() == 32) &&
189 IsNullTerminatedString(C)) {
190 if (ITy->getBitWidth() == 8)
191 return SectionKind::getMergeable1ByteCString();
192 if (ITy->getBitWidth() == 16)
193 return SectionKind::getMergeable2ByteCString();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000194
Chris Lattner81bbf442009-08-04 16:13:09 +0000195 assert(ITy->getBitWidth() == 32 && "Unknown width");
196 return SectionKind::getMergeable4ByteCString();
197 }
198 }
199 }
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000200
Chris Lattner5e693ed2009-07-28 03:13:23 +0000201 // Otherwise, just drop it into a mergable constant section. If we have
202 // a section for this size, use it, otherwise use the arbitrary sized
203 // mergable section.
Peter Collingbourne67335642016-10-24 19:23:39 +0000204 switch (
205 GVar->getParent()->getDataLayout().getTypeAllocSize(C->getType())) {
Chris Lattnerf8d97102009-08-01 23:57:16 +0000206 case 4: return SectionKind::getMergeableConst4();
207 case 8: return SectionKind::getMergeableConst8();
208 case 16: return SectionKind::getMergeableConst16();
David Majnemer964b70d2016-02-22 22:23:11 +0000209 case 32: return SectionKind::getMergeableConst32();
Rafael Espindola33804ca2015-01-29 14:12:41 +0000210 default:
211 return SectionKind::getReadOnly();
Chris Lattner5e693ed2009-07-28 03:13:23 +0000212 }
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000213
Rafael Espindola65e49022015-11-17 00:51:23 +0000214 } else {
Oliver Stannard8331aae2016-08-08 15:28:31 +0000215 // In static, ROPI and RWPI relocation models, the linker will resolve
216 // all addresses, so the relocation entries will actually be constants by
217 // the time the app starts up. However, we can't put this into a
218 // mergable section, because the linker doesn't take relocations into
219 // consideration when it tries to merge entries in the section.
220 if (ReloModel == Reloc::Static || ReloModel == Reloc::ROPI ||
221 ReloModel == Reloc::RWPI || ReloModel == Reloc::ROPI_RWPI)
Chris Lattnerf8d97102009-08-01 23:57:16 +0000222 return SectionKind::getReadOnly();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000223
Chris Lattner5e693ed2009-07-28 03:13:23 +0000224 // Otherwise, the dynamic linker needs to fix it up, put it in the
225 // writable data.rel section.
Chris Lattnerf8d97102009-08-01 23:57:16 +0000226 return SectionKind::getReadOnlyWithRel();
Chris Lattner5e693ed2009-07-28 03:13:23 +0000227 }
228 }
229
Rafael Espindolaa686f122016-06-24 22:19:54 +0000230 // Okay, this isn't a constant.
Rafael Espindola449711c2015-11-18 06:02:15 +0000231 return SectionKind::getData();
Chris Lattner5e693ed2009-07-28 03:13:23 +0000232}
233
Rafael Espindola0709a7b2015-05-21 19:20:38 +0000234/// This method computes the appropriate section to emit the specified global
235/// variable or function definition. This should not be passed external (or
236/// available externally) globals.
Eric Christopher4367c7f2016-09-16 07:33:15 +0000237MCSection *TargetLoweringObjectFile::SectionForGlobal(
Peter Collingbourne67335642016-10-24 19:23:39 +0000238 const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
Chris Lattner5e693ed2009-07-28 03:13:23 +0000239 // Select section name.
Peter Collingbourne67335642016-10-24 19:23:39 +0000240 if (GO->hasSection())
241 return getExplicitSectionGlobal(GO, Kind, TM);
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000242
Javed Absarb16d1462017-06-05 10:09:13 +0000243 if (auto *GVar = dyn_cast<GlobalVariable>(GO)) {
244 auto Attrs = GVar->getAttributes();
245 if ((Attrs.hasAttribute("bss-section") && Kind.isBSS()) ||
246 (Attrs.hasAttribute("data-section") && Kind.isData()) ||
247 (Attrs.hasAttribute("rodata-section") && Kind.isReadOnly())) {
248 return getExplicitSectionGlobal(GO, Kind, TM);
249 }
250 }
251
252 if (auto *F = dyn_cast<Function>(GO)) {
253 if (F->hasFnAttribute("implicit-section-name"))
254 return getExplicitSectionGlobal(GO, Kind, TM);
255 }
256
Chris Lattner5e693ed2009-07-28 03:13:23 +0000257 // Use default section depending on the 'type' of global
Peter Collingbourne67335642016-10-24 19:23:39 +0000258 return SelectSectionForGlobal(GO, Kind, TM);
Chris Lattner5e693ed2009-07-28 03:13:23 +0000259}
260
Rafael Espindola0709a7b2015-05-21 19:20:38 +0000261MCSection *TargetLoweringObjectFile::getSectionForJumpTable(
Eric Christopher4367c7f2016-09-16 07:33:15 +0000262 const Function &F, const TargetMachine &TM) const {
David Majnemera3ea4072016-02-21 01:30:30 +0000263 unsigned Align = 0;
Mehdi Amini5c0fa582015-07-16 06:04:17 +0000264 return getSectionForConstant(F.getParent()->getDataLayout(),
David Majnemera3ea4072016-02-21 01:30:30 +0000265 SectionKind::getReadOnly(), /*C=*/nullptr,
266 Align);
Rafael Espindola29786d42015-02-12 17:16:46 +0000267}
268
Rafael Espindoladf195192015-02-17 23:34:51 +0000269bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection(
270 bool UsesLabelDifference, const Function &F) const {
271 // In PIC mode, we need to emit the jump table to the same section as the
272 // function body itself, otherwise the label differences won't make sense.
273 // FIXME: Need a better predicate for this: what about custom entries?
274 if (UsesLabelDifference)
275 return true;
276
277 // We should also do if the section name is NULL or function is declared
278 // in discardable section
279 // FIXME: this isn't the right predicate, should be based on the MCSection
280 // for the function.
Davide Italiano76de68e2017-01-14 20:09:29 +0000281 return F.isWeakForLinker();
Rafael Espindoladf195192015-02-17 23:34:51 +0000282}
283
Rafael Espindola0709a7b2015-05-21 19:20:38 +0000284/// Given a mergable constant with the specified size and relocation
285/// information, return a section that it should be placed in.
Mehdi Amini5c0fa582015-07-16 06:04:17 +0000286MCSection *TargetLoweringObjectFile::getSectionForConstant(
David Majnemera3ea4072016-02-21 01:30:30 +0000287 const DataLayout &DL, SectionKind Kind, const Constant *C,
288 unsigned &Align) const {
Craig Topper062a2ba2014-04-25 05:30:21 +0000289 if (Kind.isReadOnly() && ReadOnlySection != nullptr)
Chris Lattner5e693ed2009-07-28 03:13:23 +0000290 return ReadOnlySection;
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000291
Chris Lattner5e693ed2009-07-28 03:13:23 +0000292 return DataSection;
293}
294
Anton Korobeynikove42af362012-11-14 01:47:00 +0000295/// getTTypeGlobalReference - Return an MCExpr to use for a
Anton Korobeynikovae4ccc12010-02-15 22:35:59 +0000296/// reference to the specified global variable from exception
297/// handling information.
Rafael Espindola15b26692014-02-09 14:50:44 +0000298const MCExpr *TargetLoweringObjectFile::getTTypeGlobalReference(
Eric Christopher4367c7f2016-09-16 07:33:15 +0000299 const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
300 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
Anton Korobeynikove42af362012-11-14 01:47:00 +0000301 const MCSymbolRefExpr *Ref =
Tim Northoverb64fb452016-11-22 16:17:20 +0000302 MCSymbolRefExpr::create(TM.getSymbol(GV), getContext());
Anton Korobeynikove42af362012-11-14 01:47:00 +0000303
304 return getTTypeReference(Ref, Encoding, Streamer);
Chris Lattnerb8666022009-09-16 01:46:41 +0000305}
Chris Lattner5e693ed2009-07-28 03:13:23 +0000306
Anton Korobeynikovae4ccc12010-02-15 22:35:59 +0000307const MCExpr *TargetLoweringObjectFile::
Anton Korobeynikove42af362012-11-14 01:47:00 +0000308getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
309 MCStreamer &Streamer) const {
Rafael Espindolaa01cdb02011-04-15 15:11:06 +0000310 switch (Encoding & 0x70) {
Anton Korobeynikovae4ccc12010-02-15 22:35:59 +0000311 default:
Chris Lattner2104b8d2010-04-07 22:58:41 +0000312 report_fatal_error("We do not support this DWARF encoding yet!");
Anton Korobeynikovae4ccc12010-02-15 22:35:59 +0000313 case dwarf::DW_EH_PE_absptr:
314 // Do nothing special
Anton Korobeynikove42af362012-11-14 01:47:00 +0000315 return Sym;
Chris Lattner03627cb2010-03-11 21:55:20 +0000316 case dwarf::DW_EH_PE_pcrel: {
317 // Emit a label to the streamer for the current position. This gives us
318 // .-foo addressing.
Jim Grosbach6f482002015-05-18 18:43:14 +0000319 MCSymbol *PCSym = getContext().createTempSymbol();
Chris Lattner03627cb2010-03-11 21:55:20 +0000320 Streamer.EmitLabel(PCSym);
Jim Grosbach13760bd2015-05-30 01:25:56 +0000321 const MCExpr *PC = MCSymbolRefExpr::create(PCSym, getContext());
322 return MCBinaryExpr::createSub(Sym, PC, getContext());
Chris Lattner03627cb2010-03-11 21:55:20 +0000323 }
324 }
Anton Korobeynikovae4ccc12010-02-15 22:35:59 +0000325}
David Blaikief2694972013-06-28 20:05:11 +0000326
Ulrich Weigand2b6fc8d2013-07-02 18:47:09 +0000327const MCExpr *TargetLoweringObjectFile::getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
David Blaikief2694972013-06-28 20:05:11 +0000328 // FIXME: It's not clear what, if any, default this should have - perhaps a
329 // null return could mean 'no location' & we should just do that here.
Jim Grosbach13760bd2015-05-30 01:25:56 +0000330 return MCSymbolRefExpr::create(Sym, *Ctx);
David Blaikief2694972013-06-28 20:05:11 +0000331}
David Majnemer7db449a2015-03-17 23:54:51 +0000332
333void TargetLoweringObjectFile::getNameWithPrefix(
Eric Christopher4367c7f2016-09-16 07:33:15 +0000334 SmallVectorImpl<char> &OutName, const GlobalValue *GV,
Peter Collingbourne94d77862015-11-03 23:40:03 +0000335 const TargetMachine &TM) const {
Eric Christopher4367c7f2016-09-16 07:33:15 +0000336 Mang->getNameWithPrefix(OutName, GV, /*CannotUsePrivateLabel=*/false);
David Majnemer7db449a2015-03-17 23:54:51 +0000337}