blob: a895dda059f2ac38ae2b299cd9f4376863d69fd0 [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
15#include "llvm/Target/TargetLoweringObjectFile.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000016#include "llvm/IR/Constants.h"
17#include "llvm/IR/DataLayout.h"
18#include "llvm/IR/DerivedTypes.h"
19#include "llvm/IR/Function.h"
20#include "llvm/IR/GlobalVariable.h"
Rafael Espindola117b20c2013-12-05 05:53:12 +000021#include "llvm/MC/MCAsmInfo.h"
Chris Lattner4d2c0f92009-07-31 18:48:30 +000022#include "llvm/MC/MCContext.h"
Chris Lattnerb8666022009-09-16 01:46:41 +000023#include "llvm/MC/MCExpr.h"
Chris Lattner03627cb2010-03-11 21:55:20 +000024#include "llvm/MC/MCStreamer.h"
Chris Lattnerccbeed22010-01-13 21:29:21 +000025#include "llvm/MC/MCSymbol.h"
Anton Korobeynikovae4ccc12010-02-15 22:35:59 +000026#include "llvm/Support/Dwarf.h"
Chris Lattnerd82510e2009-11-07 09:20:54 +000027#include "llvm/Support/ErrorHandling.h"
Chris Lattnerccbeed22010-01-13 21:29:21 +000028#include "llvm/Support/raw_ostream.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000029#include "llvm/Target/Mangler.h"
30#include "llvm/Target/TargetMachine.h"
31#include "llvm/Target/TargetOptions.h"
Chris Lattner5e693ed2009-07-28 03:13:23 +000032using namespace llvm;
33
34//===----------------------------------------------------------------------===//
35// Generic Code
36//===----------------------------------------------------------------------===//
37
Evan Cheng76792992011-07-20 05:58:47 +000038/// Initialize - this method must be called before any actual lowering is
39/// done. This specifies the current context for codegen, and gives the
40/// lowering implementations a chance to set up their default sections.
41void TargetLoweringObjectFile::Initialize(MCContext &ctx,
42 const TargetMachine &TM) {
43 Ctx = &ctx;
Rafael Espindola58873562014-01-03 19:21:54 +000044 DL = TM.getDataLayout();
Evan Chengbbf3b0d2011-07-20 19:50:42 +000045 InitMCObjectFileInfo(TM.getTargetTriple(),
46 TM.getRelocationModel(), TM.getCodeModel(), *Ctx);
Chris Lattner5e693ed2009-07-28 03:13:23 +000047}
Evan Cheng76792992011-07-20 05:58:47 +000048
Chris Lattner5e693ed2009-07-28 03:13:23 +000049TargetLoweringObjectFile::~TargetLoweringObjectFile() {
50}
51
Nick Lewycky50f02cb2011-12-02 22:16:29 +000052static bool isSuitableForBSS(const GlobalVariable *GV, bool NoZerosInBSS) {
Jay Foad60020682011-06-19 18:37:11 +000053 const Constant *C = GV->getInitializer();
Anton Korobeynikov1df58862009-09-09 08:41:20 +000054
Chris Lattner5e693ed2009-07-28 03:13:23 +000055 // Must have zero initializer.
56 if (!C->isNullValue())
57 return false;
Anton Korobeynikov1df58862009-09-09 08:41:20 +000058
Chris Lattner5e693ed2009-07-28 03:13:23 +000059 // Leave constant zeros in readonly constant sections, so they can be shared.
60 if (GV->isConstant())
61 return false;
Anton Korobeynikov1df58862009-09-09 08:41:20 +000062
Chris Lattner5e693ed2009-07-28 03:13:23 +000063 // If the global has an explicit section specified, don't put it in BSS.
64 if (!GV->getSection().empty())
65 return false;
Anton Korobeynikov1df58862009-09-09 08:41:20 +000066
Chris Lattner5e693ed2009-07-28 03:13:23 +000067 // If -nozero-initialized-in-bss is specified, don't ever use BSS.
68 if (NoZerosInBSS)
69 return false;
Anton Korobeynikov1df58862009-09-09 08:41:20 +000070
Chris Lattner5e693ed2009-07-28 03:13:23 +000071 // Otherwise, put it in BSS!
72 return true;
73}
74
Chris Lattner81bbf442009-08-04 16:13:09 +000075/// IsNullTerminatedString - Return true if the specified constant (which is
76/// 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 +000077/// nul value and contains no other nuls in it. Note that this is more general
78/// than ConstantDataSequential::isString because we allow 2 & 4 byte strings.
Chris Lattner81bbf442009-08-04 16:13:09 +000079static bool IsNullTerminatedString(const Constant *C) {
Chris Lattner139822f2012-01-24 14:17:05 +000080 // First check: is we have constant array terminated with zero
Chris Lattner139822f2012-01-24 14:17:05 +000081 if (const ConstantDataSequential *CDS = dyn_cast<ConstantDataSequential>(C)) {
82 unsigned NumElts = CDS->getNumElements();
83 assert(NumElts != 0 && "Can't have an empty CDS");
84
85 if (CDS->getElementAsInteger(NumElts-1) != 0)
86 return false; // Not null terminated.
87
88 // Verify that the null doesn't occur anywhere else in the string.
89 for (unsigned i = 0; i != NumElts-1; ++i)
90 if (CDS->getElementAsInteger(i) == 0)
91 return false;
92 return true;
93 }
Chris Lattner5e693ed2009-07-28 03:13:23 +000094
95 // Another possibility: [1 x i8] zeroinitializer
96 if (isa<ConstantAggregateZero>(C))
Chris Lattner139822f2012-01-24 14:17:05 +000097 return cast<ArrayType>(C->getType())->getNumElements() == 1;
Chris Lattner5e693ed2009-07-28 03:13:23 +000098
99 return false;
100}
101
Rafael Espindolae133ed82013-10-29 17:28:26 +0000102/// Return the MCSymbol for the specified global value. This
103/// symbol is the main label that is the address of the global.
104MCSymbol *TargetLoweringObjectFile::getSymbol(Mangler &M,
105 const GlobalValue *GV) const {
106 SmallString<60> NameStr;
Rafael Espindola117b20c2013-12-05 05:53:12 +0000107 M.getNameWithPrefix(NameStr, GV);
Rafael Espindolae133ed82013-10-29 17:28:26 +0000108 return Ctx->GetOrCreateSymbol(NameStr.str());
109}
110
Rafael Espindolaf4e6b292013-12-02 16:25:47 +0000111MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
112 Mangler &M, const GlobalValue *GV, StringRef Suffix) const {
Rafael Espindola117b20c2013-12-05 05:53:12 +0000113 assert(!Suffix.empty());
114 assert(!GV->hasPrivateLinkage());
115 assert(!GV->hasLinkerPrivateLinkage());
116 assert(!GV->hasLinkerPrivateWeakLinkage());
117
Rafael Espindolaf4e6b292013-12-02 16:25:47 +0000118 SmallString<60> NameStr;
Rafael Espindola58873562014-01-03 19:21:54 +0000119 NameStr += DL->getPrivateGlobalPrefix();
Rafael Espindola117b20c2013-12-05 05:53:12 +0000120 M.getNameWithPrefix(NameStr, GV);
Rafael Espindolaf4e6b292013-12-02 16:25:47 +0000121 NameStr.append(Suffix.begin(), Suffix.end());
122 return Ctx->GetOrCreateSymbol(NameStr.str());
123}
Rafael Espindolae133ed82013-10-29 17:28:26 +0000124
Rafael Espindola08704342011-04-27 23:08:15 +0000125MCSymbol *TargetLoweringObjectFile::
Rafael Espindolace83fc32011-04-27 23:17:57 +0000126getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
Rafael Espindola08704342011-04-27 23:08:15 +0000127 MachineModuleInfo *MMI) const {
Rafael Espindolae133ed82013-10-29 17:28:26 +0000128 return getSymbol(*Mang, GV);
Rafael Espindolaa83b1772011-04-16 03:51:21 +0000129}
130
131void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
132 const TargetMachine &TM,
133 const MCSymbol *Sym) const {
Rafael Espindolaa83b1772011-04-16 03:51:21 +0000134}
135
136
Chris Lattnercbc7b262009-08-05 04:25:40 +0000137/// getKindForGlobal - This is a top-level target-independent classifier for
Chris Lattnerc9c277b2009-08-01 21:11:14 +0000138/// a global variable. Given an global variable and information from TM, it
139/// classifies the global in a variety of ways that make various target
140/// implementations simpler. The target implementation is free to ignore this
141/// extra info of course.
Chris Lattnercbc7b262009-08-05 04:25:40 +0000142SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV,
143 const TargetMachine &TM){
144 assert(!GV->isDeclaration() && !GV->hasAvailableExternallyLinkage() &&
145 "Can only be used for global definitions");
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000146
Chris Lattner5e693ed2009-07-28 03:13:23 +0000147 Reloc::Model ReloModel = TM.getRelocationModel();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000148
Chris Lattner5e693ed2009-07-28 03:13:23 +0000149 // Early exit - functions should be always in text sections.
150 const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
151 if (GVar == 0)
Chris Lattnerf8d97102009-08-01 23:57:16 +0000152 return SectionKind::getText();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000153
Chris Lattner5e693ed2009-07-28 03:13:23 +0000154 // Handle thread-local data first.
155 if (GVar->isThreadLocal()) {
Nick Lewycky50f02cb2011-12-02 22:16:29 +0000156 if (isSuitableForBSS(GVar, TM.Options.NoZerosInBSS))
Chris Lattnerf8d97102009-08-01 23:57:16 +0000157 return SectionKind::getThreadBSS();
158 return SectionKind::getThreadData();
Chris Lattner5e693ed2009-07-28 03:13:23 +0000159 }
160
Chris Lattner5b585f82010-01-19 02:48:26 +0000161 // Variables with common linkage always get classified as common.
162 if (GVar->hasCommonLinkage())
163 return SectionKind::getCommon();
164
Chris Lattner5e693ed2009-07-28 03:13:23 +0000165 // Variable can be easily put to BSS section.
Nick Lewycky50f02cb2011-12-02 22:16:29 +0000166 if (isSuitableForBSS(GVar, TM.Options.NoZerosInBSS)) {
Chris Lattnerb2534212010-01-19 04:15:51 +0000167 if (GVar->hasLocalLinkage())
168 return SectionKind::getBSSLocal();
169 else if (GVar->hasExternalLinkage())
170 return SectionKind::getBSSExtern();
Chris Lattnerf8d97102009-08-01 23:57:16 +0000171 return SectionKind::getBSS();
Chris Lattnerb2534212010-01-19 04:15:51 +0000172 }
Chris Lattner5e693ed2009-07-28 03:13:23 +0000173
Jay Foad60020682011-06-19 18:37:11 +0000174 const Constant *C = GVar->getInitializer();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000175
Chris Lattner5e693ed2009-07-28 03:13:23 +0000176 // If the global is marked constant, we can put it into a mergable section,
177 // a mergable string section, or general .data if it contains relocations.
Chris Lattnerea4e9832011-01-18 01:23:44 +0000178 if (GVar->isConstant()) {
Chris Lattner5e693ed2009-07-28 03:13:23 +0000179 // If the initializer for the global contains something that requires a
Eric Christopherde9e92e2012-05-05 01:16:06 +0000180 // relocation, then we may have to drop this into a writable data section
Chris Lattner5e693ed2009-07-28 03:13:23 +0000181 // even though it is marked const.
182 switch (C->getRelocationInfo()) {
Chris Lattner5e693ed2009-07-28 03:13:23 +0000183 case Constant::NoRelocation:
Chris Lattnerea4e9832011-01-18 01:23:44 +0000184 // If the global is required to have a unique address, it can't be put
185 // into a mergable section: just drop it into the general read-only
186 // section instead.
187 if (!GVar->hasUnnamedAddr())
188 return SectionKind::getReadOnly();
189
Chris Lattner5e693ed2009-07-28 03:13:23 +0000190 // If initializer is a null-terminated string, put it in a "cstring"
Chris Lattner81bbf442009-08-04 16:13:09 +0000191 // section of the right width.
Chris Lattner229907c2011-07-18 04:54:35 +0000192 if (ArrayType *ATy = dyn_cast<ArrayType>(C->getType())) {
193 if (IntegerType *ITy =
Chris Lattner81bbf442009-08-04 16:13:09 +0000194 dyn_cast<IntegerType>(ATy->getElementType())) {
195 if ((ITy->getBitWidth() == 8 || ITy->getBitWidth() == 16 ||
196 ITy->getBitWidth() == 32) &&
197 IsNullTerminatedString(C)) {
198 if (ITy->getBitWidth() == 8)
199 return SectionKind::getMergeable1ByteCString();
200 if (ITy->getBitWidth() == 16)
201 return SectionKind::getMergeable2ByteCString();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000202
Chris Lattner81bbf442009-08-04 16:13:09 +0000203 assert(ITy->getBitWidth() == 32 && "Unknown width");
204 return SectionKind::getMergeable4ByteCString();
205 }
206 }
207 }
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000208
Chris Lattner5e693ed2009-07-28 03:13:23 +0000209 // Otherwise, just drop it into a mergable constant section. If we have
210 // a section for this size, use it, otherwise use the arbitrary sized
211 // mergable section.
Micah Villmowcdfe20b2012-10-08 16:38:25 +0000212 switch (TM.getDataLayout()->getTypeAllocSize(C->getType())) {
Chris Lattnerf8d97102009-08-01 23:57:16 +0000213 case 4: return SectionKind::getMergeableConst4();
214 case 8: return SectionKind::getMergeableConst8();
215 case 16: return SectionKind::getMergeableConst16();
216 default: return SectionKind::getMergeableConst();
Chris Lattner5e693ed2009-07-28 03:13:23 +0000217 }
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000218
Chris Lattner5e693ed2009-07-28 03:13:23 +0000219 case Constant::LocalRelocation:
220 // In static relocation model, the linker will resolve all addresses, so
221 // the relocation entries will actually be constants by the time the app
222 // starts up. However, we can't put this into a mergable section, because
223 // the linker doesn't take relocations into consideration when it tries to
224 // merge entries in the section.
225 if (ReloModel == Reloc::Static)
Chris Lattnerf8d97102009-08-01 23:57:16 +0000226 return SectionKind::getReadOnly();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000227
Chris Lattner5e693ed2009-07-28 03:13:23 +0000228 // Otherwise, the dynamic linker needs to fix it up, put it in the
229 // writable data.rel.local section.
Chris Lattnerf8d97102009-08-01 23:57:16 +0000230 return SectionKind::getReadOnlyWithRelLocal();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000231
Chris Lattner5e693ed2009-07-28 03:13:23 +0000232 case Constant::GlobalRelocations:
233 // In static relocation model, the linker will resolve all addresses, so
234 // the relocation entries will actually be constants by the time the app
235 // starts up. However, we can't put this into a mergable section, because
236 // the linker doesn't take relocations into consideration when it tries to
237 // merge entries in the section.
238 if (ReloModel == Reloc::Static)
Chris Lattnerf8d97102009-08-01 23:57:16 +0000239 return SectionKind::getReadOnly();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000240
Chris Lattner5e693ed2009-07-28 03:13:23 +0000241 // Otherwise, the dynamic linker needs to fix it up, put it in the
242 // writable data.rel section.
Chris Lattnerf8d97102009-08-01 23:57:16 +0000243 return SectionKind::getReadOnlyWithRel();
Chris Lattner5e693ed2009-07-28 03:13:23 +0000244 }
245 }
246
247 // Okay, this isn't a constant. If the initializer for the global is going
248 // to require a runtime relocation by the dynamic linker, put it into a more
249 // specific section to improve startup time of the app. This coalesces these
250 // globals together onto fewer pages, improving the locality of the dynamic
251 // linker.
252 if (ReloModel == Reloc::Static)
Chris Lattnerf8d97102009-08-01 23:57:16 +0000253 return SectionKind::getDataNoRel();
Chris Lattner5e693ed2009-07-28 03:13:23 +0000254
255 switch (C->getRelocationInfo()) {
Chris Lattner5e693ed2009-07-28 03:13:23 +0000256 case Constant::NoRelocation:
Chris Lattnerf8d97102009-08-01 23:57:16 +0000257 return SectionKind::getDataNoRel();
Chris Lattner5e693ed2009-07-28 03:13:23 +0000258 case Constant::LocalRelocation:
Chris Lattnerf8d97102009-08-01 23:57:16 +0000259 return SectionKind::getDataRelLocal();
Chris Lattner5e693ed2009-07-28 03:13:23 +0000260 case Constant::GlobalRelocations:
Chris Lattnerf8d97102009-08-01 23:57:16 +0000261 return SectionKind::getDataRel();
Chris Lattner5e693ed2009-07-28 03:13:23 +0000262 }
Chandler Carruthf3e85022012-01-10 18:08:01 +0000263 llvm_unreachable("Invalid relocation");
Chris Lattner5e693ed2009-07-28 03:13:23 +0000264}
265
266/// SectionForGlobal - This method computes the appropriate section to emit
267/// the specified global variable or function definition. This should not
268/// be passed external (or available externally) globals.
Chris Lattner4d2c0f92009-07-31 18:48:30 +0000269const MCSection *TargetLoweringObjectFile::
Chris Lattnercbc7b262009-08-05 04:25:40 +0000270SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang,
Chris Lattner50343292009-07-29 05:09:30 +0000271 const TargetMachine &TM) const {
Chris Lattner5e693ed2009-07-28 03:13:23 +0000272 // Select section name.
Chris Lattner1ff90132009-08-06 16:39:58 +0000273 if (GV->hasSection())
274 return getExplicitSectionGlobal(GV, Kind, Mang, TM);
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000275
276
Chris Lattner5e693ed2009-07-28 03:13:23 +0000277 // Use default section depending on the 'type' of global
Chris Lattner26fb2772009-08-01 21:46:23 +0000278 return SelectSectionForGlobal(GV, Kind, Mang, TM);
Chris Lattner5e693ed2009-07-28 03:13:23 +0000279}
280
Chris Lattnercbc7b262009-08-05 04:25:40 +0000281
Chris Lattner5e693ed2009-07-28 03:13:23 +0000282// Lame default implementation. Calculate the section name for global.
Chris Lattner4d2c0f92009-07-31 18:48:30 +0000283const MCSection *
Chris Lattner5e693ed2009-07-28 03:13:23 +0000284TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
Chris Lattner26fb2772009-08-01 21:46:23 +0000285 SectionKind Kind,
Chris Lattner50343292009-07-29 05:09:30 +0000286 Mangler *Mang,
Chris Lattner5e693ed2009-07-28 03:13:23 +0000287 const TargetMachine &TM) const{
Chris Lattner26fb2772009-08-01 21:46:23 +0000288 assert(!Kind.isThreadLocal() && "Doesn't support TLS");
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000289
Chris Lattner26fb2772009-08-01 21:46:23 +0000290 if (Kind.isText())
Chris Lattner5e693ed2009-07-28 03:13:23 +0000291 return getTextSection();
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000292
Chris Lattnerd5c01132009-08-01 21:56:13 +0000293 if (Kind.isBSS() && BSSSection != 0)
294 return BSSSection;
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000295
Chris Lattner26fb2772009-08-01 21:46:23 +0000296 if (Kind.isReadOnly() && ReadOnlySection != 0)
Chris Lattner5e693ed2009-07-28 03:13:23 +0000297 return ReadOnlySection;
298
299 return getDataSection();
300}
301
Chris Lattner0c402662009-08-01 23:46:12 +0000302/// getSectionForConstant - Given a mergable constant with the
Chris Lattner5e693ed2009-07-28 03:13:23 +0000303/// specified size and relocation information, return a section that it
304/// should be placed in.
Chris Lattner4d2c0f92009-07-31 18:48:30 +0000305const MCSection *
Chris Lattner0c402662009-08-01 23:46:12 +0000306TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const {
Chris Lattner5e693ed2009-07-28 03:13:23 +0000307 if (Kind.isReadOnly() && ReadOnlySection != 0)
308 return ReadOnlySection;
Anton Korobeynikov1df58862009-09-09 08:41:20 +0000309
Chris Lattner5e693ed2009-07-28 03:13:23 +0000310 return DataSection;
311}
312
Anton Korobeynikove42af362012-11-14 01:47:00 +0000313/// getTTypeGlobalReference - Return an MCExpr to use for a
Anton Korobeynikovae4ccc12010-02-15 22:35:59 +0000314/// reference to the specified global variable from exception
315/// handling information.
Chris Lattnerb8666022009-09-16 01:46:41 +0000316const MCExpr *TargetLoweringObjectFile::
Anton Korobeynikove42af362012-11-14 01:47:00 +0000317getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
318 MachineModuleInfo *MMI, unsigned Encoding,
319 MCStreamer &Streamer) const {
320 const MCSymbolRefExpr *Ref =
Rafael Espindolae133ed82013-10-29 17:28:26 +0000321 MCSymbolRefExpr::Create(getSymbol(*Mang, GV), getContext());
Anton Korobeynikove42af362012-11-14 01:47:00 +0000322
323 return getTTypeReference(Ref, Encoding, Streamer);
Chris Lattnerb8666022009-09-16 01:46:41 +0000324}
Chris Lattner5e693ed2009-07-28 03:13:23 +0000325
Anton Korobeynikovae4ccc12010-02-15 22:35:59 +0000326const MCExpr *TargetLoweringObjectFile::
Anton Korobeynikove42af362012-11-14 01:47:00 +0000327getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
328 MCStreamer &Streamer) const {
Rafael Espindolaa01cdb02011-04-15 15:11:06 +0000329 switch (Encoding & 0x70) {
Anton Korobeynikovae4ccc12010-02-15 22:35:59 +0000330 default:
Chris Lattner2104b8d2010-04-07 22:58:41 +0000331 report_fatal_error("We do not support this DWARF encoding yet!");
Anton Korobeynikovae4ccc12010-02-15 22:35:59 +0000332 case dwarf::DW_EH_PE_absptr:
333 // Do nothing special
Anton Korobeynikove42af362012-11-14 01:47:00 +0000334 return Sym;
Chris Lattner03627cb2010-03-11 21:55:20 +0000335 case dwarf::DW_EH_PE_pcrel: {
336 // Emit a label to the streamer for the current position. This gives us
337 // .-foo addressing.
Chris Lattneraed00fa2010-03-17 05:41:18 +0000338 MCSymbol *PCSym = getContext().CreateTempSymbol();
Chris Lattner03627cb2010-03-11 21:55:20 +0000339 Streamer.EmitLabel(PCSym);
340 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, getContext());
Anton Korobeynikove42af362012-11-14 01:47:00 +0000341 return MCBinaryExpr::CreateSub(Sym, PC, getContext());
Chris Lattner03627cb2010-03-11 21:55:20 +0000342 }
343 }
Anton Korobeynikovae4ccc12010-02-15 22:35:59 +0000344}
David Blaikief2694972013-06-28 20:05:11 +0000345
Ulrich Weigand2b6fc8d2013-07-02 18:47:09 +0000346const MCExpr *TargetLoweringObjectFile::getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
David Blaikief2694972013-06-28 20:05:11 +0000347 // FIXME: It's not clear what, if any, default this should have - perhaps a
348 // null return could mean 'no location' & we should just do that here.
349 return MCSymbolRefExpr::Create(Sym, *Ctx);
350}