1f22ef01cSRoman Divacky //===-- llvm/Target/TargetLoweringObjectFile.cpp - Object File Info -------===//
2f22ef01cSRoman Divacky //
3f22ef01cSRoman Divacky //                     The LLVM Compiler Infrastructure
4f22ef01cSRoman Divacky //
5f22ef01cSRoman Divacky // This file is distributed under the University of Illinois Open Source
6f22ef01cSRoman Divacky // License. See LICENSE.TXT for details.
7f22ef01cSRoman Divacky //
8f22ef01cSRoman Divacky //===----------------------------------------------------------------------===//
9f22ef01cSRoman Divacky //
10f22ef01cSRoman Divacky // This file implements classes used to handle lowerings specific to common
11f22ef01cSRoman Divacky // object file formats.
12f22ef01cSRoman Divacky //
13f22ef01cSRoman Divacky //===----------------------------------------------------------------------===//
14f22ef01cSRoman Divacky 
15f22ef01cSRoman Divacky #include "llvm/Target/TargetLoweringObjectFile.h"
16139f7f9bSDimitry Andric #include "llvm/IR/Constants.h"
17139f7f9bSDimitry Andric #include "llvm/IR/DataLayout.h"
18139f7f9bSDimitry Andric #include "llvm/IR/DerivedTypes.h"
19139f7f9bSDimitry Andric #include "llvm/IR/Function.h"
20139f7f9bSDimitry Andric #include "llvm/IR/GlobalVariable.h"
2191bc56edSDimitry Andric #include "llvm/IR/Mangler.h"
2291bc56edSDimitry Andric #include "llvm/MC/MCAsmInfo.h"
23f22ef01cSRoman Divacky #include "llvm/MC/MCContext.h"
24f22ef01cSRoman Divacky #include "llvm/MC/MCExpr.h"
25f22ef01cSRoman Divacky #include "llvm/MC/MCStreamer.h"
26f22ef01cSRoman Divacky #include "llvm/MC/MCSymbol.h"
27f22ef01cSRoman Divacky #include "llvm/Support/Dwarf.h"
28f22ef01cSRoman Divacky #include "llvm/Support/ErrorHandling.h"
29f22ef01cSRoman Divacky #include "llvm/Support/raw_ostream.h"
3091bc56edSDimitry Andric #include "llvm/Target/TargetLowering.h"
31139f7f9bSDimitry Andric #include "llvm/Target/TargetMachine.h"
32139f7f9bSDimitry Andric #include "llvm/Target/TargetOptions.h"
33f22ef01cSRoman Divacky using namespace llvm;
34f22ef01cSRoman Divacky 
35f22ef01cSRoman Divacky //===----------------------------------------------------------------------===//
36f22ef01cSRoman Divacky //                              Generic Code
37f22ef01cSRoman Divacky //===----------------------------------------------------------------------===//
38f22ef01cSRoman Divacky 
396122f3e6SDimitry Andric /// Initialize - this method must be called before any actual lowering is
406122f3e6SDimitry Andric /// done.  This specifies the current context for codegen, and gives the
416122f3e6SDimitry Andric /// lowering implementations a chance to set up their default sections.
426122f3e6SDimitry Andric void TargetLoweringObjectFile::Initialize(MCContext &ctx,
436122f3e6SDimitry Andric                                           const TargetMachine &TM) {
446122f3e6SDimitry Andric   Ctx = &ctx;
4591bc56edSDimitry Andric   DL = TM.getDataLayout();
466122f3e6SDimitry Andric   InitMCObjectFileInfo(TM.getTargetTriple(),
476122f3e6SDimitry Andric                        TM.getRelocationModel(), TM.getCodeModel(), *Ctx);
48f22ef01cSRoman Divacky }
49f22ef01cSRoman Divacky 
50f22ef01cSRoman Divacky TargetLoweringObjectFile::~TargetLoweringObjectFile() {
51f22ef01cSRoman Divacky }
52f22ef01cSRoman Divacky 
53dff0c46cSDimitry Andric static bool isSuitableForBSS(const GlobalVariable *GV, bool NoZerosInBSS) {
5417a519f9SDimitry Andric   const Constant *C = GV->getInitializer();
55f22ef01cSRoman Divacky 
56f22ef01cSRoman Divacky   // Must have zero initializer.
57f22ef01cSRoman Divacky   if (!C->isNullValue())
58f22ef01cSRoman Divacky     return false;
59f22ef01cSRoman Divacky 
60f22ef01cSRoman Divacky   // Leave constant zeros in readonly constant sections, so they can be shared.
61f22ef01cSRoman Divacky   if (GV->isConstant())
62f22ef01cSRoman Divacky     return false;
63f22ef01cSRoman Divacky 
64f22ef01cSRoman Divacky   // If the global has an explicit section specified, don't put it in BSS.
6591bc56edSDimitry Andric   if (GV->hasSection())
66f22ef01cSRoman Divacky     return false;
67f22ef01cSRoman Divacky 
68f22ef01cSRoman Divacky   // If -nozero-initialized-in-bss is specified, don't ever use BSS.
69f22ef01cSRoman Divacky   if (NoZerosInBSS)
70f22ef01cSRoman Divacky     return false;
71f22ef01cSRoman Divacky 
72f22ef01cSRoman Divacky   // Otherwise, put it in BSS!
73f22ef01cSRoman Divacky   return true;
74f22ef01cSRoman Divacky }
75f22ef01cSRoman Divacky 
76f22ef01cSRoman Divacky /// IsNullTerminatedString - Return true if the specified constant (which is
77f22ef01cSRoman Divacky /// known to have a type that is an array of 1/2/4 byte elements) ends with a
78dff0c46cSDimitry Andric /// nul value and contains no other nuls in it.  Note that this is more general
79dff0c46cSDimitry Andric /// than ConstantDataSequential::isString because we allow 2 & 4 byte strings.
80f22ef01cSRoman Divacky static bool IsNullTerminatedString(const Constant *C) {
81dff0c46cSDimitry Andric   // First check: is we have constant array terminated with zero
82dff0c46cSDimitry Andric   if (const ConstantDataSequential *CDS = dyn_cast<ConstantDataSequential>(C)) {
83dff0c46cSDimitry Andric     unsigned NumElts = CDS->getNumElements();
84dff0c46cSDimitry Andric     assert(NumElts != 0 && "Can't have an empty CDS");
85f22ef01cSRoman Divacky 
86dff0c46cSDimitry Andric     if (CDS->getElementAsInteger(NumElts-1) != 0)
87f22ef01cSRoman Divacky       return false; // Not null terminated.
88f22ef01cSRoman Divacky 
89f22ef01cSRoman Divacky     // Verify that the null doesn't occur anywhere else in the string.
90dff0c46cSDimitry Andric     for (unsigned i = 0; i != NumElts-1; ++i)
91dff0c46cSDimitry Andric       if (CDS->getElementAsInteger(i) == 0)
92f22ef01cSRoman Divacky         return false;
93f22ef01cSRoman Divacky     return true;
94f22ef01cSRoman Divacky   }
95f22ef01cSRoman Divacky 
96f22ef01cSRoman Divacky   // Another possibility: [1 x i8] zeroinitializer
97f22ef01cSRoman Divacky   if (isa<ConstantAggregateZero>(C))
98dff0c46cSDimitry Andric     return cast<ArrayType>(C->getType())->getNumElements() == 1;
99f22ef01cSRoman Divacky 
100f22ef01cSRoman Divacky   return false;
101f22ef01cSRoman Divacky }
102f22ef01cSRoman Divacky 
10391bc56edSDimitry Andric MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
10491bc56edSDimitry Andric     const GlobalValue *GV, StringRef Suffix, Mangler &Mang,
10591bc56edSDimitry Andric     const TargetMachine &TM) const {
10691bc56edSDimitry Andric   assert(!Suffix.empty());
10791bc56edSDimitry Andric 
108f785676fSDimitry Andric   SmallString<60> NameStr;
10991bc56edSDimitry Andric   NameStr += DL->getPrivateGlobalPrefix();
11091bc56edSDimitry Andric   TM.getNameWithPrefix(NameStr, GV, Mang);
11191bc56edSDimitry Andric   NameStr.append(Suffix.begin(), Suffix.end());
112f785676fSDimitry Andric   return Ctx->GetOrCreateSymbol(NameStr.str());
113f785676fSDimitry Andric }
114f785676fSDimitry Andric 
11591bc56edSDimitry Andric MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol(
11691bc56edSDimitry Andric     const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
1173b0f4066SDimitry Andric     MachineModuleInfo *MMI) const {
11891bc56edSDimitry Andric   return TM.getSymbol(GV, Mang);
1193b0f4066SDimitry Andric }
1203b0f4066SDimitry Andric 
1213b0f4066SDimitry Andric void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
1223b0f4066SDimitry Andric                                                     const TargetMachine &TM,
1233b0f4066SDimitry Andric                                                     const MCSymbol *Sym) const {
1243b0f4066SDimitry Andric }
1253b0f4066SDimitry Andric 
1263b0f4066SDimitry Andric 
127f22ef01cSRoman Divacky /// getKindForGlobal - This is a top-level target-independent classifier for
128f22ef01cSRoman Divacky /// a global variable.  Given an global variable and information from TM, it
129f22ef01cSRoman Divacky /// classifies the global in a variety of ways that make various target
130f22ef01cSRoman Divacky /// implementations simpler.  The target implementation is free to ignore this
131f22ef01cSRoman Divacky /// extra info of course.
132f22ef01cSRoman Divacky SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV,
133f22ef01cSRoman Divacky                                                        const TargetMachine &TM){
134f22ef01cSRoman Divacky   assert(!GV->isDeclaration() && !GV->hasAvailableExternallyLinkage() &&
135f22ef01cSRoman Divacky          "Can only be used for global definitions");
136f22ef01cSRoman Divacky 
137f22ef01cSRoman Divacky   Reloc::Model ReloModel = TM.getRelocationModel();
138f22ef01cSRoman Divacky 
139f22ef01cSRoman Divacky   // Early exit - functions should be always in text sections.
140f22ef01cSRoman Divacky   const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
14191bc56edSDimitry Andric   if (!GVar)
142f22ef01cSRoman Divacky     return SectionKind::getText();
143f22ef01cSRoman Divacky 
144f22ef01cSRoman Divacky   // Handle thread-local data first.
145f22ef01cSRoman Divacky   if (GVar->isThreadLocal()) {
146dff0c46cSDimitry Andric     if (isSuitableForBSS(GVar, TM.Options.NoZerosInBSS))
147f22ef01cSRoman Divacky       return SectionKind::getThreadBSS();
148f22ef01cSRoman Divacky     return SectionKind::getThreadData();
149f22ef01cSRoman Divacky   }
150f22ef01cSRoman Divacky 
151f22ef01cSRoman Divacky   // Variables with common linkage always get classified as common.
152f22ef01cSRoman Divacky   if (GVar->hasCommonLinkage())
153f22ef01cSRoman Divacky     return SectionKind::getCommon();
154f22ef01cSRoman Divacky 
155f22ef01cSRoman Divacky   // Variable can be easily put to BSS section.
156dff0c46cSDimitry Andric   if (isSuitableForBSS(GVar, TM.Options.NoZerosInBSS)) {
157f22ef01cSRoman Divacky     if (GVar->hasLocalLinkage())
158f22ef01cSRoman Divacky       return SectionKind::getBSSLocal();
159f22ef01cSRoman Divacky     else if (GVar->hasExternalLinkage())
160f22ef01cSRoman Divacky       return SectionKind::getBSSExtern();
161f22ef01cSRoman Divacky     return SectionKind::getBSS();
162f22ef01cSRoman Divacky   }
163f22ef01cSRoman Divacky 
16417a519f9SDimitry Andric   const Constant *C = GVar->getInitializer();
165f22ef01cSRoman Divacky 
166f22ef01cSRoman Divacky   // If the global is marked constant, we can put it into a mergable section,
167f22ef01cSRoman Divacky   // a mergable string section, or general .data if it contains relocations.
168f22ef01cSRoman Divacky   if (GVar->isConstant()) {
169f22ef01cSRoman Divacky     // If the initializer for the global contains something that requires a
1707ae0e2c9SDimitry Andric     // relocation, then we may have to drop this into a writable data section
171f22ef01cSRoman Divacky     // even though it is marked const.
172f22ef01cSRoman Divacky     switch (C->getRelocationInfo()) {
173f22ef01cSRoman Divacky     case Constant::NoRelocation:
1742754fe60SDimitry Andric       // If the global is required to have a unique address, it can't be put
1752754fe60SDimitry Andric       // into a mergable section: just drop it into the general read-only
1762754fe60SDimitry Andric       // section instead.
1772754fe60SDimitry Andric       if (!GVar->hasUnnamedAddr())
1782754fe60SDimitry Andric         return SectionKind::getReadOnly();
1792754fe60SDimitry Andric 
180f22ef01cSRoman Divacky       // If initializer is a null-terminated string, put it in a "cstring"
181f22ef01cSRoman Divacky       // section of the right width.
1826122f3e6SDimitry Andric       if (ArrayType *ATy = dyn_cast<ArrayType>(C->getType())) {
1836122f3e6SDimitry Andric         if (IntegerType *ITy =
184f22ef01cSRoman Divacky               dyn_cast<IntegerType>(ATy->getElementType())) {
185f22ef01cSRoman Divacky           if ((ITy->getBitWidth() == 8 || ITy->getBitWidth() == 16 ||
186f22ef01cSRoman Divacky                ITy->getBitWidth() == 32) &&
187f22ef01cSRoman Divacky               IsNullTerminatedString(C)) {
188f22ef01cSRoman Divacky             if (ITy->getBitWidth() == 8)
189f22ef01cSRoman Divacky               return SectionKind::getMergeable1ByteCString();
190f22ef01cSRoman Divacky             if (ITy->getBitWidth() == 16)
191f22ef01cSRoman Divacky               return SectionKind::getMergeable2ByteCString();
192f22ef01cSRoman Divacky 
193f22ef01cSRoman Divacky             assert(ITy->getBitWidth() == 32 && "Unknown width");
194f22ef01cSRoman Divacky             return SectionKind::getMergeable4ByteCString();
195f22ef01cSRoman Divacky           }
196f22ef01cSRoman Divacky         }
197f22ef01cSRoman Divacky       }
198f22ef01cSRoman Divacky 
199f22ef01cSRoman Divacky       // Otherwise, just drop it into a mergable constant section.  If we have
200f22ef01cSRoman Divacky       // a section for this size, use it, otherwise use the arbitrary sized
201f22ef01cSRoman Divacky       // mergable section.
2023861d79fSDimitry Andric       switch (TM.getDataLayout()->getTypeAllocSize(C->getType())) {
203f22ef01cSRoman Divacky       case 4:  return SectionKind::getMergeableConst4();
204f22ef01cSRoman Divacky       case 8:  return SectionKind::getMergeableConst8();
205f22ef01cSRoman Divacky       case 16: return SectionKind::getMergeableConst16();
206f22ef01cSRoman Divacky       default: return SectionKind::getMergeableConst();
207f22ef01cSRoman Divacky       }
208f22ef01cSRoman Divacky 
209f22ef01cSRoman Divacky     case Constant::LocalRelocation:
210f22ef01cSRoman Divacky       // In static relocation model, the linker will resolve all addresses, so
211f22ef01cSRoman Divacky       // the relocation entries will actually be constants by the time the app
212f22ef01cSRoman Divacky       // starts up.  However, we can't put this into a mergable section, because
213f22ef01cSRoman Divacky       // the linker doesn't take relocations into consideration when it tries to
214f22ef01cSRoman Divacky       // merge entries in the section.
215f22ef01cSRoman Divacky       if (ReloModel == Reloc::Static)
216f22ef01cSRoman Divacky         return SectionKind::getReadOnly();
217f22ef01cSRoman Divacky 
218f22ef01cSRoman Divacky       // Otherwise, the dynamic linker needs to fix it up, put it in the
219f22ef01cSRoman Divacky       // writable data.rel.local section.
220f22ef01cSRoman Divacky       return SectionKind::getReadOnlyWithRelLocal();
221f22ef01cSRoman Divacky 
222f22ef01cSRoman Divacky     case Constant::GlobalRelocations:
223f22ef01cSRoman Divacky       // In static relocation model, the linker will resolve all addresses, so
224f22ef01cSRoman Divacky       // the relocation entries will actually be constants by the time the app
225f22ef01cSRoman Divacky       // starts up.  However, we can't put this into a mergable section, because
226f22ef01cSRoman Divacky       // the linker doesn't take relocations into consideration when it tries to
227f22ef01cSRoman Divacky       // merge entries in the section.
228f22ef01cSRoman Divacky       if (ReloModel == Reloc::Static)
229f22ef01cSRoman Divacky         return SectionKind::getReadOnly();
230f22ef01cSRoman Divacky 
231f22ef01cSRoman Divacky       // Otherwise, the dynamic linker needs to fix it up, put it in the
232f22ef01cSRoman Divacky       // writable data.rel section.
233f22ef01cSRoman Divacky       return SectionKind::getReadOnlyWithRel();
234f22ef01cSRoman Divacky     }
235f22ef01cSRoman Divacky   }
236f22ef01cSRoman Divacky 
237f22ef01cSRoman Divacky   // Okay, this isn't a constant.  If the initializer for the global is going
238f22ef01cSRoman Divacky   // to require a runtime relocation by the dynamic linker, put it into a more
239f22ef01cSRoman Divacky   // specific section to improve startup time of the app.  This coalesces these
240f22ef01cSRoman Divacky   // globals together onto fewer pages, improving the locality of the dynamic
241f22ef01cSRoman Divacky   // linker.
242f22ef01cSRoman Divacky   if (ReloModel == Reloc::Static)
243f22ef01cSRoman Divacky     return SectionKind::getDataNoRel();
244f22ef01cSRoman Divacky 
245f22ef01cSRoman Divacky   switch (C->getRelocationInfo()) {
246f22ef01cSRoman Divacky   case Constant::NoRelocation:
247f22ef01cSRoman Divacky     return SectionKind::getDataNoRel();
248f22ef01cSRoman Divacky   case Constant::LocalRelocation:
249f22ef01cSRoman Divacky     return SectionKind::getDataRelLocal();
250f22ef01cSRoman Divacky   case Constant::GlobalRelocations:
251f22ef01cSRoman Divacky     return SectionKind::getDataRel();
252f22ef01cSRoman Divacky   }
253dff0c46cSDimitry Andric   llvm_unreachable("Invalid relocation");
254f22ef01cSRoman Divacky }
255f22ef01cSRoman Divacky 
256f22ef01cSRoman Divacky /// SectionForGlobal - This method computes the appropriate section to emit
257f22ef01cSRoman Divacky /// the specified global variable or function definition.  This should not
258f22ef01cSRoman Divacky /// be passed external (or available externally) globals.
259f22ef01cSRoman Divacky const MCSection *TargetLoweringObjectFile::
26091bc56edSDimitry Andric SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
261f22ef01cSRoman Divacky                  const TargetMachine &TM) const {
262f22ef01cSRoman Divacky   // Select section name.
263f22ef01cSRoman Divacky   if (GV->hasSection())
264f22ef01cSRoman Divacky     return getExplicitSectionGlobal(GV, Kind, Mang, TM);
265f22ef01cSRoman Divacky 
266f22ef01cSRoman Divacky 
267f22ef01cSRoman Divacky   // Use default section depending on the 'type' of global
268f22ef01cSRoman Divacky   return SelectSectionForGlobal(GV, Kind, Mang, TM);
269f22ef01cSRoman Divacky }
270f22ef01cSRoman Divacky 
27191bc56edSDimitry Andric bool TargetLoweringObjectFile::isSectionAtomizableBySymbols(
27291bc56edSDimitry Andric     const MCSection &Section) const {
27391bc56edSDimitry Andric   return false;
27491bc56edSDimitry Andric }
275f22ef01cSRoman Divacky 
276f22ef01cSRoman Divacky // Lame default implementation. Calculate the section name for global.
277f22ef01cSRoman Divacky const MCSection *
278f22ef01cSRoman Divacky TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
279f22ef01cSRoman Divacky                                                  SectionKind Kind,
28091bc56edSDimitry Andric                                                  Mangler &Mang,
281f22ef01cSRoman Divacky                                                  const TargetMachine &TM) const{
282f22ef01cSRoman Divacky   assert(!Kind.isThreadLocal() && "Doesn't support TLS");
283f22ef01cSRoman Divacky 
284f22ef01cSRoman Divacky   if (Kind.isText())
285f22ef01cSRoman Divacky     return getTextSection();
286f22ef01cSRoman Divacky 
28791bc56edSDimitry Andric   if (Kind.isBSS() && BSSSection != nullptr)
288f22ef01cSRoman Divacky     return BSSSection;
289f22ef01cSRoman Divacky 
29091bc56edSDimitry Andric   if (Kind.isReadOnly() && ReadOnlySection != nullptr)
291f22ef01cSRoman Divacky     return ReadOnlySection;
292f22ef01cSRoman Divacky 
293f22ef01cSRoman Divacky   return getDataSection();
294f22ef01cSRoman Divacky }
295f22ef01cSRoman Divacky 
296f22ef01cSRoman Divacky /// getSectionForConstant - Given a mergable constant with the
297f22ef01cSRoman Divacky /// specified size and relocation information, return a section that it
298f22ef01cSRoman Divacky /// should be placed in.
299f22ef01cSRoman Divacky const MCSection *
30091bc56edSDimitry Andric TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind,
30191bc56edSDimitry Andric                                                 const Constant *C) const {
30291bc56edSDimitry Andric   if (Kind.isReadOnly() && ReadOnlySection != nullptr)
303f22ef01cSRoman Divacky     return ReadOnlySection;
304f22ef01cSRoman Divacky 
305f22ef01cSRoman Divacky   return DataSection;
306f22ef01cSRoman Divacky }
307f22ef01cSRoman Divacky 
308139f7f9bSDimitry Andric /// getTTypeGlobalReference - Return an MCExpr to use for a
309f22ef01cSRoman Divacky /// reference to the specified global variable from exception
310f22ef01cSRoman Divacky /// handling information.
31191bc56edSDimitry Andric const MCExpr *TargetLoweringObjectFile::getTTypeGlobalReference(
31291bc56edSDimitry Andric     const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
31391bc56edSDimitry Andric     const TargetMachine &TM, MachineModuleInfo *MMI,
314f22ef01cSRoman Divacky     MCStreamer &Streamer) const {
315139f7f9bSDimitry Andric   const MCSymbolRefExpr *Ref =
31691bc56edSDimitry Andric       MCSymbolRefExpr::Create(TM.getSymbol(GV, Mang), getContext());
317139f7f9bSDimitry Andric 
318139f7f9bSDimitry Andric   return getTTypeReference(Ref, Encoding, Streamer);
319f22ef01cSRoman Divacky }
320f22ef01cSRoman Divacky 
321f22ef01cSRoman Divacky const MCExpr *TargetLoweringObjectFile::
322139f7f9bSDimitry Andric getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
323f22ef01cSRoman Divacky                   MCStreamer &Streamer) const {
3243b0f4066SDimitry Andric   switch (Encoding & 0x70) {
325f22ef01cSRoman Divacky   default:
326f22ef01cSRoman Divacky     report_fatal_error("We do not support this DWARF encoding yet!");
327f22ef01cSRoman Divacky   case dwarf::DW_EH_PE_absptr:
328f22ef01cSRoman Divacky     // Do nothing special
329139f7f9bSDimitry Andric     return Sym;
330f22ef01cSRoman Divacky   case dwarf::DW_EH_PE_pcrel: {
331f22ef01cSRoman Divacky     // Emit a label to the streamer for the current position.  This gives us
332f22ef01cSRoman Divacky     // .-foo addressing.
333f22ef01cSRoman Divacky     MCSymbol *PCSym = getContext().CreateTempSymbol();
334f22ef01cSRoman Divacky     Streamer.EmitLabel(PCSym);
335f22ef01cSRoman Divacky     const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, getContext());
336139f7f9bSDimitry Andric     return MCBinaryExpr::CreateSub(Sym, PC, getContext());
337f22ef01cSRoman Divacky   }
338f22ef01cSRoman Divacky   }
339f22ef01cSRoman Divacky }
340f785676fSDimitry Andric 
341f785676fSDimitry Andric const MCExpr *TargetLoweringObjectFile::getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
342f785676fSDimitry Andric   // FIXME: It's not clear what, if any, default this should have - perhaps a
343f785676fSDimitry Andric   // null return could mean 'no location' & we should just do that here.
344f785676fSDimitry Andric   return MCSymbolRefExpr::Create(Sym, *Ctx);
345f785676fSDimitry Andric }
346