LLVM 24.0.0git
TargetLoweringObjectFile.cpp
Go to the documentation of this file.
1//===-- llvm/Target/TargetLoweringObjectFile.cpp - Object File 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// This file implements classes used to handle lowerings specific to common
10// object file formats.
11//
12//===----------------------------------------------------------------------===//
13
16#include "llvm/IR/Attributes.h"
17#include "llvm/IR/Constants.h"
18#include "llvm/IR/DataLayout.h"
20#include "llvm/IR/Function.h"
21#include "llvm/IR/GlobalValue.h"
23#include "llvm/IR/Mangler.h"
24#include "llvm/IR/Module.h"
25#include "llvm/MC/MCAsmInfo.h"
26#include "llvm/MC/MCContext.h"
27#include "llvm/MC/MCExpr.h"
28#include "llvm/MC/MCStreamer.h"
29#include "llvm/MC/SectionKind.h"
33using namespace llvm;
34
35//===----------------------------------------------------------------------===//
36// Generic Code
37//===----------------------------------------------------------------------===//
38
39/// Initialize - this method must be called before any actual lowering is
40/// done. This specifies the current context for codegen, and gives the
41/// lowering implementations a chance to set up their default sections.
43 const TargetMachine &TM) {
44 // `Initialize` can be called more than once.
45 delete Mang;
46 Mang = new Mangler();
47 initMCObjectFileInfo(ctx, TM.isPositionIndependent(),
48 TM.getCodeModel() == CodeModel::Large);
49
50 // Reset various EH DWARF encodings.
53
54 this->TM = &TM;
55}
56
60
62 // If target does not have LEB128 directives, we would need the
63 // call site encoding to be udata4 so that the alternative path
64 // for not having LEB128 directives could work.
65 if (!getContext().getAsmInfo().hasLEB128Directives())
67 return CallSiteEncoding;
68}
69
70static bool isNullOrUndef(const Constant *C) {
71 // Check that the constant isn't all zeros or undefs.
72 if (C->isNullValue() || isa<UndefValue>(C))
73 return true;
75 return false;
76 for (const auto *Operand : C->operand_values()) {
77 if (!isNullOrUndef(cast<Constant>(Operand)))
78 return false;
79 }
80 return true;
81}
82
83static bool isSuitableForBSS(const GlobalVariable *GV) {
84 const Constant *C = GV->getInitializer();
85
86 // Must have zero initializer.
87 if (!isNullOrUndef(C))
88 return false;
89
90 // Leave constant zeros in readonly constant sections, so they can be shared.
91 if (GV->isConstant())
92 return false;
93
94 // If the global has an explicit section specified, don't put it in BSS.
95 if (GV->hasSection())
96 return false;
97
98 // Otherwise, put it in BSS!
99 return true;
100}
101
102/// IsNullTerminatedString - Return true if the specified constant (which is
103/// known to have a type that is an array of 1/2/4 byte elements) ends with a
104/// nul value and contains no other nuls in it. Note that this is more general
105/// than ConstantDataSequential::isString because we allow 2 & 4 byte strings.
106static bool IsNullTerminatedString(const Constant *C) {
107 // First check: is we have constant array terminated with zero
109 uint64_t NumElts = CDS->getNumElements();
110 assert(NumElts != 0 && "Can't have an empty CDS");
111
112 if (CDS->getElementAsInteger(NumElts-1) != 0)
113 return false; // Not null terminated.
114
115 // Verify that the null doesn't occur anywhere else in the string.
116 for (uint64_t i = 0; i != NumElts - 1; ++i)
117 if (CDS->getElementAsInteger(i) == 0)
118 return false;
119 return true;
120 }
121
122 // Another possibility: [1 x i8] zeroinitializer
124 return cast<ArrayType>(C->getType())->getNumElements() == 1;
125
126 return false;
127}
128
130 const GlobalValue *GV, StringRef Suffix, const TargetMachine &TM) const {
131 assert(!Suffix.empty());
132
133 SmallString<60> NameStr;
134 NameStr += GV->getDataLayout().getInternalSymbolPrefix();
135 TM.getNameWithPrefix(NameStr, GV, *Mang);
136 NameStr.append(Suffix.begin(), Suffix.end());
137 return getContext().getOrCreateSymbol(NameStr);
138}
139
141 const GlobalValue *GV, const TargetMachine &TM,
142 MachineModuleInfo *MMI) const {
143 return TM.getSymbol(GV);
144}
145
147 MCStreamer &Streamer, const DataLayout &, const MCSymbol *Sym,
148 const MachineModuleInfo *MMI) const {}
149
151 Module &M) const {
154 M.getModuleFlagsMetadata(ModuleFlags);
155
156 MDNode *CGProfile = nullptr;
157
158 for (const auto &MFE : ModuleFlags) {
159 StringRef Key = MFE.Key->getString();
160 if (Key == "CG Profile") {
161 CGProfile = cast<MDNode>(MFE.Val);
162 break;
163 }
164 }
165
166 if (!CGProfile)
167 return;
168
169 auto GetSym = [this](const MDOperand &MDO) -> MCSymbol * {
170 if (!MDO)
171 return nullptr;
172 auto *V = cast<ValueAsMetadata>(MDO);
173 const Function *F = cast<Function>(V->getValue()->stripPointerCasts());
174 if (F->hasDLLImportStorageClass())
175 return nullptr;
176 return TM->getSymbol(F);
177 };
178
179 for (const auto &Edge : CGProfile->operands()) {
180 MDNode *E = cast<MDNode>(Edge);
181 const MCSymbol *From = GetSym(E->getOperand(0));
182 const MCSymbol *To = GetSym(E->getOperand(1));
183 // Skip null functions. This can happen if functions are dead stripped after
184 // the CGProfile pass has been run.
185 if (!From || !To)
186 continue;
187 uint64_t Count = cast<ConstantAsMetadata>(E->getOperand(2))
188 ->getValue()
189 ->getUniqueInteger()
190 .getZExtValue();
193 }
194}
195
197 MCStreamer &Streamer, Module &M,
198 std::function<void(MCStreamer &Streamer)> COMDATSymEmitter) const {
199 NamedMDNode *FuncInfo = M.getNamedMetadata(PseudoProbeDescMetadataName);
200 if (!FuncInfo)
201 return;
202
203 // Emit a descriptor for every function including functions that have an
204 // available external linkage. We may not want this for imported functions
205 // that has code in another thinLTO module but we don't have a good way to
206 // tell them apart from inline functions defined in header files. Therefore
207 // we put each descriptor in a separate comdat section and rely on the
208 // linker to deduplicate.
209 auto &C = getContext();
210 for (const auto *Operand : FuncInfo->operands()) {
211 const auto *MD = cast<MDNode>(Operand);
212 auto *GUID = mdconst::extract<ConstantInt>(MD->getOperand(0));
213 auto *Hash = mdconst::extract<ConstantInt>(MD->getOperand(1));
214 auto *Name = cast<MDString>(MD->getOperand(2));
215 auto *S = C.getObjectFileInfo()->getPseudoProbeDescSection(
216 TM->getFunctionSections() ? Name->getString() : StringRef(),
217 Hash->getZExtValue());
218
219 Streamer.switchSection(S);
220
221 // emit COFF COMDAT symbol.
222 if (COMDATSymEmitter)
223 COMDATSymEmitter(Streamer);
224
225 Streamer.emitInt64(GUID->getZExtValue());
226 Streamer.emitInt64(Hash->getZExtValue());
227 Streamer.emitULEB128IntValue(Name->getString().size());
228 Streamer.emitBytes(Name->getString());
229 }
230}
231
232static bool containsConstantPtrAuth(const Constant *C) {
234 return true;
235
237 return false;
238
239 for (const Value *Op : C->operands())
241 return true;
242
243 return false;
244}
245
246/// getKindForGlobal - This is a top-level target-independent classifier for
247/// a global object. Given a global variable and information from the TM, this
248/// function classifies the global in a target independent manner. This function
249/// may be overridden by the target implementation.
251 const TargetMachine &TM){
253 "Can only be used for global definitions");
254
255 // Functions are classified as text sections.
256 if (isa<Function>(GO))
257 return SectionKind::getText();
258
259 // Basic blocks are classified as text sections.
260 if (isa<BasicBlock>(GO))
261 return SectionKind::getText();
262
263 // Global variables require more detailed analysis.
264 const auto *GVar = cast<GlobalVariable>(GO);
265
266 // Handle thread-local data first.
267 if (GVar->isThreadLocal()) {
268 if (isSuitableForBSS(GVar) && !TM.Options.NoZerosInBSS) {
269 // Zero-initialized TLS variables with local linkage always get classified
270 // as ThreadBSSLocal.
271 if (GVar->hasLocalLinkage()) {
273 }
275 }
277 }
278
279 // Variables with common linkage always get classified as common.
280 if (GVar->hasCommonLinkage())
281 return SectionKind::getCommon();
282
283 // Most non-mergeable zero data can be put in the BSS section unless otherwise
284 // specified.
285 if (isSuitableForBSS(GVar) && !TM.Options.NoZerosInBSS) {
286 if (GVar->hasLocalLinkage())
288 else if (GVar->hasExternalLinkage())
290 return SectionKind::getBSS();
291 }
292
293 // Global variables with '!exclude' should get the exclude section kind if
294 // they have an explicit section and no other metadata. Similarly,
295 // '!metadata_section_kind' forces the section kind to be 'metadata'.
296 if (GVar->hasSection()) {
297 if (MDNode *MD = GVar->getMetadata(LLVMContext::MD_exclude))
298 if (!MD->getNumOperands())
300 if (MDNode *MD = GVar->getMetadata(LLVMContext::MD_metadata_section_kind))
301 if (!MD->getNumOperands())
303 }
304
305 // If the global is marked constant, we can put it into a mergable section,
306 // a mergable string section, or general .data if it contains relocations.
307 if (GVar->isConstant()) {
308 // If the initializer for the global contains something that requires a
309 // relocation, then we may have to drop this into a writable data section
310 // even though it is marked const.
311 const Constant *C = GVar->getInitializer();
312 if (!C->needsRelocation()) {
313 // If the global is required to have a unique address, it can't be put
314 // into a mergable section: just drop it into the general read-only
315 // section instead.
316 if (!GVar->hasGlobalUnnamedAddr())
318
319 // If initializer is a null-terminated string, put it in a "cstring"
320 // section of the right width.
321 if (ArrayType *ATy = dyn_cast<ArrayType>(C->getType())) {
322 if (IntegerType *ITy =
323 dyn_cast<IntegerType>(ATy->getElementType())) {
324 if ((ITy->getBitWidth() == 8 || ITy->getBitWidth() == 16 ||
325 ITy->getBitWidth() == 32) &&
327 if (ITy->getBitWidth() == 8)
329 if (ITy->getBitWidth() == 16)
331
332 assert(ITy->getBitWidth() == 32 && "Unknown width");
334 }
335 }
336 }
337
338 // Otherwise, just drop it into a mergable constant section. If we have
339 // a section for this size, use it, otherwise use the arbitrary sized
340 // mergable section.
341 switch (
342 GVar->getDataLayout().getTypeAllocSize(C->getType())) {
343 case 4: return SectionKind::getMergeableConst4();
344 case 8: return SectionKind::getMergeableConst8();
345 case 16: return SectionKind::getMergeableConst16();
346 case 32: return SectionKind::getMergeableConst32();
347 default:
349 }
350
351 } else {
352 // The dynamic linker always needs to fix PtrAuth relocations up.
355
356 // In static, ROPI and RWPI relocation models, the linker will resolve
357 // all addresses, so the relocation entries will actually be constants by
358 // the time the app starts up. However, we can't put this into a
359 // mergable section, because the linker doesn't take relocations into
360 // consideration when it tries to merge entries in the section.
361 Reloc::Model ReloModel = TM.getRelocationModel();
362 if (ReloModel == Reloc::Static || ReloModel == Reloc::ROPI ||
363 ReloModel == Reloc::RWPI || ReloModel == Reloc::ROPI_RWPI ||
364 !C->needsDynamicRelocation())
366
367 // Otherwise, the dynamic linker needs to fix it up, put it in the
368 // writable data.rel section.
370 }
371 }
372
373 // Okay, this isn't a constant.
374 return SectionKind::getData();
375}
376
379 const TargetMachine &TM) {
380 // Check if '#pragma clang section' name is applicable.
381 // Note that pragma directive overrides -ffunction-section, -fdata-section
382 // and so section name is exactly as user specified and not uniqued.
384 if (GV && GV->hasImplicitSection()) {
385 SectionKind Kind = getKindForGlobal(GO, TM);
386 auto Attrs = GV->getAttributes();
387 if (Attrs.hasAttribute("bss-section") && Kind.isBSS())
388 return Attrs.getAttribute("bss-section").getValueAsString();
389 else if (Attrs.hasAttribute("rodata-section") && Kind.isReadOnly())
390 return Attrs.getAttribute("rodata-section").getValueAsString();
391 else if (Attrs.hasAttribute("relro-section") && Kind.isReadOnlyWithRel())
392 return Attrs.getAttribute("relro-section").getValueAsString();
393 else if (Attrs.hasAttribute("data-section") && Kind.isData())
394 return Attrs.getAttribute("data-section").getValueAsString();
395 }
396
397 return GO->getSection();
398}
399
400/// This method computes the appropriate section to emit the specified global
401/// variable or function definition. This should not be passed external (or
402/// available externally) globals.
404 const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
405 // Select section name.
406 if (GO->hasSection())
407 return getExplicitSectionGlobal(GO, Kind, TM);
408
409 if (auto *GVar = dyn_cast<GlobalVariable>(GO)) {
410 auto Attrs = GVar->getAttributes();
411 if ((Attrs.hasAttribute("bss-section") && Kind.isBSS()) ||
412 (Attrs.hasAttribute("data-section") && Kind.isData()) ||
413 (Attrs.hasAttribute("relro-section") && Kind.isReadOnlyWithRel()) ||
414 (Attrs.hasAttribute("rodata-section") && Kind.isReadOnly())) {
415 return getExplicitSectionGlobal(GO, Kind, TM);
416 }
417 }
418
419 // Use default section depending on the 'type' of global
420 return SelectSectionForGlobal(GO, Kind, TM);
421}
422
423/// This method computes the appropriate section to emit the specified global
424/// variable or function definition. This should not be passed external (or
425/// available externally) globals.
426MCSection *
431
433 const Function &F, const TargetMachine &TM) const {
434 return getSectionForJumpTable(F, TM, /*JTE=*/nullptr);
435}
436
438 const Function &F, const TargetMachine &TM,
439 const MachineJumpTableEntry *JTE) const {
440 Align Alignment(1);
441 return getSectionForConstant(F.getDataLayout(), SectionKind::getReadOnly(),
442 /*C=*/nullptr, Alignment, &F);
443}
444
446 bool UsesLabelDifference, const Function &F) const {
447 // In PIC mode, we need to emit the jump table to the same section as the
448 // function body itself, otherwise the label differences won't make sense.
449 // FIXME: Need a better predicate for this: what about custom entries?
450 if (UsesLabelDifference)
451 return true;
452
453 // We should also do if the section name is NULL or function is declared
454 // in discardable section
455 // FIXME: this isn't the right predicate, should be based on the MCSection
456 // for the function.
457 return F.isWeakForLinker();
458}
459
460/// Given a mergable constant with the specified size and relocation
461/// information, return a section that it should be placed in.
463 const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment,
464 const Function *F) const {
465 if (Kind.isReadOnly() && ReadOnlySection != nullptr)
466 return ReadOnlySection;
467
468 return DataSection;
469}
470
472 const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment,
473 const Function *F, StringRef SectionPrefix) const {
474 // Fallback to `getSectionForConstant` without `SectionPrefix` parameter if it
475 // is empty.
476 if (SectionPrefix.empty())
477 return getSectionForConstant(DL, Kind, C, Alignment, F);
479 "TargetLoweringObjectFile::getSectionForConstant that "
480 "accepts SectionPrefix is not implemented for the object file format");
481}
482
488
490 const Function &F, const TargetMachine &TM) const {
491 return nullptr;
492}
493
494/// getTTypeGlobalReference - Return an MCExpr to use for a
495/// reference to the specified global variable from exception
496/// handling information.
498 const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
499 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
500 const MCSymbolRefExpr *Ref =
501 MCSymbolRefExpr::create(TM.getSymbol(GV), getContext());
502
503 return getTTypeReference(Ref, Encoding, Streamer);
504}
505
507getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
508 MCStreamer &Streamer) const {
509 switch (Encoding & 0x70) {
510 default:
511 report_fatal_error("We do not support this DWARF encoding yet!");
513 // Do nothing special
514 return Sym;
516 // Emit a label to the streamer for the current position. This gives us
517 // .-foo addressing.
519 Streamer.emitLabel(PCSym);
520 const MCExpr *PC = MCSymbolRefExpr::create(PCSym, getContext());
521 return MCBinaryExpr::createSub(Sym, PC, getContext());
522 }
523 }
524}
525
527 // FIXME: It's not clear what, if any, default this should have - perhaps a
528 // null return could mean 'no location' & we should just do that here.
529 return MCSymbolRefExpr::create(Sym, getContext());
530}
531
533 SmallVectorImpl<char> &OutName, const GlobalValue *GV,
534 const TargetMachine &TM) const {
535 Mang->getNameWithPrefix(OutName, GV, /*CannotUsePrivateLabel=*/false);
536}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file contains constants used for implementing Dwarf debug support.
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition MD5.cpp:54
static bool isNullOrUndef(const Constant *C)
static bool IsNullTerminatedString(const Constant *C)
IsNullTerminatedString - Return true if the specified constant (which is known to have a type that is...
static bool isSuitableForBSS(const GlobalVariable *GV)
static bool containsConstantPtrAuth(const Constant *C)
Class to represent array types.
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
Definition Constants.h:755
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
StringRef getInternalSymbolPrefix() const
Definition DataLayout.h:308
StringRef getSection() const
Get the custom section of this global if it has one.
bool hasSection() const
Check if this global has a custom object file section.
bool isDeclarationForLinker() const
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
Definition Globals.cpp:205
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
AttributeSet getAttributes() const
Return the attribute set for this global.
bool hasImplicitSection() const
Check if section name is present.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
Class to represent integer types.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition MCExpr.h:427
Context object for machine code objects.
Definition MCContext.h:83
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
void initMCObjectFileInfo(MCContext &MCCtx, bool PIC, bool LargeCodeModel=false)
MCSection * ReadOnlySection
Section that is readonly and can contain arbitrary initialized data.
MCContext & getContext() const
MCSection * DataSection
Section directive for standard data.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:580
Streaming machine code generation interface.
Definition MCStreamer.h:222
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
unsigned emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
void emitInt64(uint64_t Value)
Definition MCStreamer.h:770
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
Represent a reference to a symbol from inside an expression.
Definition MCExpr.h:190
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:213
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
Metadata node.
Definition Metadata.h:1069
ArrayRef< MDOperand > operands() const
Definition Metadata.h:1424
Tracking metadata reference owned by Metadata.
Definition Metadata.h:891
This class contains meta information specific to a module.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A tuple of MDNodes.
Definition Metadata.h:1755
iterator_range< op_iterator > operands()
Definition Metadata.h:1851
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition SectionKind.h:22
static SectionKind getThreadData()
static SectionKind getBSSExtern()
static SectionKind getMetadata()
static SectionKind getMergeable2ByteCString()
static SectionKind getExclude()
static SectionKind getBSSLocal()
static SectionKind getMergeableConst4()
static SectionKind getCommon()
static SectionKind getText()
static SectionKind getThreadBSSLocal()
static SectionKind getReadOnlyWithRel()
static SectionKind getData()
static SectionKind getMergeableConst8()
static SectionKind getBSS()
static SectionKind getThreadBSS()
static SectionKind getMergeableConst16()
static SectionKind getMergeable4ByteCString()
static SectionKind getMergeable1ByteCString()
static SectionKind getReadOnly()
static SectionKind getMergeableConst32()
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:26
void append(StringRef RHS)
Append from a StringRef.
Definition SmallString.h:68
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
iterator begin() const
Definition StringRef.h:114
iterator end() const
Definition StringRef.h:116
void emitCGProfileMetadata(MCStreamer &Streamer, Module &M) const
Emit Call Graph Profile metadata.
virtual void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const
unsigned PersonalityEncoding
PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values for EH.
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...
virtual MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const
virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const
virtual MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const
virtual void Initialize(MCContext &ctx, const TargetMachine &TM)
This method must be called before any actual lowering is done.
virtual MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const =0
virtual MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment, const Function *F) const
Given a constant with the SectionKind, return a section that it should be placed in.
static StringRef getCustomSectionName(const GlobalObject *GO, const TargetMachine &TM)
Return the section name specified by 'pragma clang section' or the section attribute.
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix, const TargetMachine &TM) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
virtual MCSection * getSectionForMachineBasicBlock(const Function &F, const MachineBasicBlock &MBB, const TargetMachine &TM) const
virtual const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const
Create a symbol reference to describe the given TLS variable when emitting the address in debug info.
virtual const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const
Return an MCExpr to use for a reference to the specified global variable from exception handling info...
virtual MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const =0
Targets should implement this method to assign a section to globals with an explicit section specfied...
void emitPseudoProbeDescMetadata(MCStreamer &Streamer, Module &M, std::function< void(MCStreamer &Streamer)> COMDATSymEmitter=nullptr) const
Emit pseudo_probe_desc metadata.
const MCExpr * getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, MCStreamer &Streamer) const
virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM, const MCSymbol *Sym, const MachineModuleInfo *MMI) const
virtual MCSection * getUniqueSectionForFunction(const Function &F, const TargetMachine &TM) const
MCSection * SectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const
This method computes the appropriate section to emit the specified global variable or function defini...
Primary interface to the complete machine description for the target machine.
LLVM Value Representation.
Definition Value.h:75
@ DW_EH_PE_pcrel
Definition Dwarf.h:962
@ DW_EH_PE_absptr
Definition Dwarf.h:951
@ DW_EH_PE_udata4
Definition Dwarf.h:955
@ DW_EH_PE_uleb128
Definition Dwarf.h:953
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
Definition Metadata.h:668
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
@ Ref
The access may reference the value stored in memory.
Definition ModRef.h:32
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition InstrProf.h:145
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
constexpr const char * PseudoProbeDescMetadataName
Definition PseudoProbe.h:26
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
MachineJumpTableEntry - One jump table in the jump table info.