1//===- llvm/CodeGen/TargetLoweringObjectFileImpl.cpp - Object File Info ---===// 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 7//===----------------------------------------------------------------------===// 9// This file implements classes used to handle lowerings specific to common 10// object file formats. 12//===----------------------------------------------------------------------===// 77cl::desc(
"Putting Jump Table in function section"));
82 M.getModuleFlagsMetadata(ModuleFlags);
84for (
constauto &MFE: ModuleFlags) {
85// Ignore flags with 'Require' behaviour. 90if (Key ==
"Objective-C Image Info Version") {
91 Version = mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue();
92 }
elseif (Key ==
"Objective-C Garbage Collection" ||
93 Key ==
"Objective-C GC Only" ||
94 Key ==
"Objective-C Is Simulated" ||
95 Key ==
"Objective-C Class Properties" ||
96 Key ==
"Objective-C Image Swift Version") {
97 Flags |= mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue();
98 }
elseif (Key ==
"Objective-C Image Info Section") {
99 Section = cast<MDString>(MFE.Val)->getString();
101// Backend generates L_OBJC_IMAGE_INFO from Swift ABI version + major + minor + 102// "Objective-C Garbage Collection". 103elseif (Key ==
"Swift ABI Version") {
104 Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 8;
105 }
elseif (Key ==
"Swift Major Version") {
106 Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 24;
107 }
elseif (Key ==
"Swift Minor Version") {
108 Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 16;
113//===----------------------------------------------------------------------===// 115//===----------------------------------------------------------------------===// 135// Fallthrough if not using EHABI 187// The small model guarantees static code/data size < 4GB, but not where it 188// will be in memory. Most of these could end up >2GB away so even a signed 189// pc-relative 32-bit address is insufficient, theoretically. 191// Use DW_EH_PE_indirect even for -fno-pic to avoid copy relocations. 208// MIPS uses indirect pointer to refer personality functions and types, so 209// that the eh_frame section can be read-only. DW.ref.personality will be 210// generated for relocation. 212// FIXME: The N64 ABI probably ought to use DW_EH_PE_sdata8 but we can't 213// identify N64 from just a triple. 217// FreeBSD must be explicit about the data size and using pcrel since it's 218// assembler/linker won't do the automatic conversion that the Linux tools 270// All currently-defined code models guarantee that 4-byte PC-relative 271// values will be in range. 301if (
auto *GO = dyn_cast<GlobalObject>(GV))
311if (
NamedMDNode *DependentLibraries = M.getNamedMetadata(
"llvm.dependent-libraries")) {
317for (
constauto *Operand : DependentLibraries->operands()) {
319 cast<MDString>(cast<MDNode>(Operand)->getOperand(0))->getString());
325// Emit a descriptor for every function including functions that have an 326// available external linkage. We may not want this for imported functions 327// that has code in another thinLTO module but we don't have a good way to 328// tell them apart from inline functions defined in header files. Therefore 329// we put each descriptor in a separate comdat section and rely on the 330// linker to deduplicate. 331for (
constauto *Operand : FuncInfo->operands()) {
332constauto *MD = cast<MDNode>(Operand);
333auto *GUID = mdconst::dyn_extract<ConstantInt>(MD->getOperand(0));
334auto *Hash = mdconst::dyn_extract<ConstantInt>(MD->getOperand(1));
335auto *
Name = cast<MDString>(MD->getOperand(2));
336auto *S =
C.getObjectFileInfo()->getPseudoProbeDescSection(
340 Streamer.
emitInt64(GUID->getZExtValue());
341 Streamer.
emitInt64(Hash->getZExtValue());
347if (
NamedMDNode *LLVMStats = M.getNamedMetadata(
"llvm.stats")) {
348// Emit the metadata for llvm statistics into .llvm_stats section, which is 349// formatted as a list of key/value pair, the value is base64 encoded. 350auto *S =
C.getObjectFileInfo()->getLLVMStatsSection();
352for (
constauto *Operand : LLVMStats->operands()) {
353constauto *MD = cast<MDNode>(Operand);
354assert(MD->getNumOperands() % 2 == 0 &&
355 (
"Operand num should be even for a list of key/value pair"));
356for (
size_tI = 0;
I < MD->getNumOperands();
I += 2) {
357// Encode the key string size. 358auto *Key = cast<MDString>(MD->getOperand(
I));
361// Encode the value into a Base64 string. 363Twine(mdconst::dyn_extract<ConstantInt>(MD->getOperand(
I + 1))
377if (!Section.empty()) {
392if (
NamedMDNode *LinkerOptions = M.getNamedMetadata(
"llvm.linker.options")) {
398for (
constauto *Operand : LinkerOptions->operands()) {
399if (cast<MDNode>(Operand)->getNumOperands() != 2)
401for (
constauto &Option : cast<MDNode>(Operand)->operands()) {
402 Streamer.
emitBytes(cast<MDString>(Option)->getString());
425 NameData +=
Sym->getName();
427 cast<MCSymbolELF>(
getContext().getOrCreateSymbol(NameData));
433unsignedSize =
DL.getPointerSize();
458// Add information about the stub reference to ELFMMI so that the stub 459// gets emitted by the asmprinter. 476// N.B.: The defaults used in here are not the same ones used in MC. 477// We follow gcc, MC follows gas. For example, given ".section .eh_frame", 478// both gas and MC will produce a section with no flags. Given 479// section(".eh_frame") gcc will produce: 481// .section .eh_frame,"a",@progbits 484/*AddSegmentInfo=*/false) ||
486/*AddSegmentInfo=*/false) ||
488/*AddSegmentInfo=*/false) ||
490/*AddSegmentInfo=*/false) ||
491Name ==
".llvmbc" ||
Name ==
".llvmcmd")
494if (!
Name.starts_with(
"."))
return K;
496// Default implementation based on some magic section names. 497if (
Name ==
".bss" ||
Name.starts_with(
".bss.") ||
498Name.starts_with(
".gnu.linkonce.b.") ||
499Name.starts_with(
".llvm.linkonce.b.") ||
Name ==
".sbss" ||
500Name.starts_with(
".sbss.") ||
Name.starts_with(
".gnu.linkonce.sb.") ||
501Name.starts_with(
".llvm.linkonce.sb."))
504if (
Name ==
".tdata" ||
Name.starts_with(
".tdata.") ||
505Name.starts_with(
".gnu.linkonce.td.") ||
506Name.starts_with(
".llvm.linkonce.td."))
509if (
Name ==
".tbss" ||
Name.starts_with(
".tbss.") ||
510Name.starts_with(
".gnu.linkonce.tb.") ||
511Name.starts_with(
".llvm.linkonce.tb."))
523// Use SHT_NOTE for section whose name starts with ".note" to allow 524// emitting ELF notes from C variable declaration. 525// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77609 526if (
Name.starts_with(
".note"))
540if (
Name ==
".llvm.lto")
543if (K.isBSS() || K.isThreadBSS())
552if (!K.isMetadata() && !K.isExclude())
561if (K.isExecuteOnly())
567if (K.isThreadLocal())
570if (K.isMergeableCString() || K.isMergeableConst())
573if (K.isMergeableCString())
587"SelectionKind::NoDeduplicate, '" +
588C->getName() +
"' cannot be lowered.");
600auto *OtherGV = dyn_cast<GlobalValue>(VM->getValue());
601return OtherGV ? dyn_cast<MCSymbolELF>(TM.getSymbol(OtherGV)) :
nullptr;
605if (Kind.isMergeable1ByteCString())
607elseif (Kind.isMergeable2ByteCString())
609elseif (Kind.isMergeable4ByteCString())
611elseif (Kind.isMergeableConst4())
613elseif (Kind.isMergeableConst8())
615elseif (Kind.isMergeableConst16())
617elseif (Kind.isMergeableConst32())
620// We shouldn't have mergeable C strings or mergeable constants that we 621// didn't handle above. 622assert(!Kind.isMergeableCString() &&
"unknown string width");
623assert(!Kind.isMergeableConst() &&
"unknown data width");
628/// Return the section prefix name used by options FunctionsSections and 632return IsLarge ?
".ltext" :
".text";
633if (Kind.isReadOnly())
634return IsLarge ?
".lrodata" :
".rodata";
636return IsLarge ?
".lbss" :
".bss";
637if (Kind.isThreadData())
639if (Kind.isThreadBSS())
642return IsLarge ?
".ldata" :
".data";
643if (Kind.isReadOnlyWithRel())
644return IsLarge ?
".ldata.rel.ro" :
".data.rel.ro";
651unsigned EntrySize,
bool UniqueSectionName) {
654if (Kind.isMergeableCString()) {
655// We also need alignment here. 656// FIXME: this is getting the alignment of the character, not the 657// alignment of the global! 659 cast<GlobalVariable>(GO));
662Name += utostr(EntrySize);
665 }
elseif (Kind.isMergeableConst()) {
667Name += utostr(EntrySize);
670bool HasPrefix =
false;
671if (
constauto *
F = dyn_cast<Function>(GO)) {
672if (std::optional<StringRef> Prefix =
F->getSectionPrefix()) {
678if (UniqueSectionName) {
680 TM.getNameWithPrefix(
Name, GO, Mang,
/*MayAlwaysUsePrivate*/true);
682// For distinguishing between .text.${text-section-prefix}. (with trailing 683// dot) and .text.${function-name} 693 LoweringDiagnosticInfo(
constTwine &DiagMsg,
700/// Calculate an appropriate unique ID for a section, and update Flags, 701/// EntrySize and NextUniqueID where appropriate. 706unsigned &EntrySize,
unsigned &NextUniqueID,
707constbool Retain,
constbool ForceUnique) {
708// Increment uniqueID if we are forced to emit a unique section. 709// This works perfectly fine with section attribute or pragma section as the 710// sections with the same name are grouped together by the assembler. 712return NextUniqueID++;
714// A section can have at most one associated section. Put each global with 715// MD_associated in a unique section. 716constbool Associated = GO->
getMetadata(LLVMContext::MD_associated);
719return NextUniqueID++;
723if (TM.getTargetTriple().isOSSolaris())
728return NextUniqueID++;
731// If two symbols with differing sizes end up in the same mergeable section 732// that section can be assigned an incorrect entry size. To avoid this we 733// usually put symbols of the same size into distinct mergeable sections with 734// the same name. Doing so relies on the ",unique ," assembly feature. This 735// feature is not available until binutils version 2.35 736// (https://sourceware.org/bugzilla/show_bug.cgi?id=25380). 739if (!SupportsUnique) {
740 Flags &= ~ELF::SHF_MERGE;
746constbool SeenSectionNameBefore =
748// If this is the first occurrence of this section name, treat it as the 750if (!SymbolMergeable && !SeenSectionNameBefore) {
751if (TM.getSeparateNamedSections())
752return NextUniqueID++;
757// Symbols must be placed into sections with compatible entry sizes. Generate 758// unique sections for symbols that have not been assigned to compatible 760constauto PreviousID =
762if (PreviousID && (!TM.getSeparateNamedSections() ||
766// If the user has specified the same section name as would be created 767// implicitly for this symbol e.g. .rodata.str1.1, then we don't need 768// to unique the section as the entry size for this symbol will be 769// compatible with implicitly created sections. 772if (SymbolMergeable &&
777// We have seen this section name before, but with different flags or entity 778// size. Create a new unique ID. 779return NextUniqueID++;
782static std::tuple<StringRef, bool, unsigned>
792if (TM.isLargeGlobalValue(GO))
794return {Group, IsComdat, Flags};
799// Check if '#pragma clang section' name is applicable. 800// Note that pragma directive overrides -ffunction-section, -fdata-section 801// and so section name is exactly as user specified and not uniqued. 805if (Attrs.hasAttribute(
"bss-section") && Kind.isBSS())
806return Attrs.getAttribute(
"bss-section").getValueAsString();
807elseif (Attrs.hasAttribute(
"rodata-section") && Kind.isReadOnly())
808return Attrs.getAttribute(
"rodata-section").getValueAsString();
809elseif (Attrs.hasAttribute(
"relro-section") && Kind.isReadOnlyWithRel())
810return Attrs.getAttribute(
"relro-section").getValueAsString();
811elseif (Attrs.hasAttribute(
"data-section") && Kind.isData())
812return Attrs.getAttribute(
"data-section").getValueAsString();
822unsigned &NextUniqueID,
823bool Retain,
bool ForceUnique) {
826// Infer section flags from the section name if we can. 835 GO,
SectionName, Kind, TM, Ctx, Mang, Flags, EntrySize, NextUniqueID,
836 Retain, ForceUnique);
841 Group, IsComdat, UniqueID, LinkedToSym);
842// Make sure that we did not get some other section with incompatible sh_link. 843// This should not be possible due to UniqueID code above. 844assert(Section->getLinkedToSymbol() == LinkedToSym &&
845"Associated symbol mismatch between sections");
849// If we are using GNU as before 2.35, then this symbol might have 850// been placed in an incompatible mergeable section. Emit an error if this 851// is the case to avoid creating broken output. 855"Symbol '" + GO->
getName() +
"' from module '" +
857"' required a section with entry-size=" +
860": Explicit assignment by pragma or attribute of an incompatible " 861"symbol to this section?"));
870 NextUniqueID, Used.count(GO),
871/* ForceUnique = */false);
877unsigned *NextUniqueID,
constMCSymbolELF *AssociatedSymbol) {
882// Get the section entry size based on the kind. 885bool UniqueSectionName =
false;
887if (EmitUniqueSection) {
888if (TM.getUniqueSectionNames()) {
889 UniqueSectionName =
true;
891 UniqueID = *NextUniqueID;
896 GO, Kind, Mang, TM, EntrySize, UniqueSectionName);
898// Use 0 as the unique ID for execute-only text. 899if (Kind.isExecuteOnly())
902 EntrySize, Group, IsComdat, UniqueID,
909unsigned Flags,
unsigned *NextUniqueID) {
912 EmitUniqueSection =
true;
916if (TM.getTargetTriple().isOSSolaris()) {
917 EmitUniqueSection =
true;
921 EmitUniqueSection =
true;
927 Ctx, GO, Kind, Mang, TM, EmitUniqueSection, Flags,
928 NextUniqueID, LinkedToSym);
929assert(Section->getLinkedToSymbol() == LinkedToSym);
937// If we have -ffunction-section or -fdata-section then we should emit the 938// global value to a uniqued section specifically for it. 939bool EmitUniqueSection =
false;
948 Used.count(GO), EmitUniqueSection, Flags,
956// If the function's section names is pre-determined via pragma or a 957// section attribute, call selectExplicitSectionGlobal. 961 Used.count(&
F),
/* ForceUnique = */true);
965/*EmitUniqueSection=*/true, Flags, &NextUniqueID);
970// If the function can be removed, produce a unique section so that 971// the table doesn't prevent the removal. 974if (!EmitUniqueSection)
980/* AssociatedSymbol */nullptr);
985// If neither COMDAT nor function sections, use the monolithic LSDA section. 986// Re-use this path if LSDASection is null as in the Arm EHABI. 991unsigned Flags = LSDA->getFlags();
1000// Use SHF_LINK_ORDER to facilitate --gc-sections if we can use GNU ld>=2.36 1001// or LLD, which support mixed SHF_LINK_ORDER & non-SHF_LINK_ORDER. 1003 (
getContext().getAsmInfo()->useIntegratedAssembler() &&
1004getContext().getAsmInfo()->binutilsIsAtLeast(2, 36))) {
1006 LinkedToSym = cast<MCSymbolELF>(&FnSym);
1009// Append the function name as the suffix like GCC, assuming 1010// -funique-section-names applies to .gcc_except_table sections. 1019bool UsesLabelDifference,
constFunction &
F)
const{
1020// We can always create relative relocations, so use another section 1021// that can be marked non-executable. 1025/// Given a mergeable constant with the specified size and relocation 1026/// information, return a section that it should be placed in. 1029Align &Alignment)
const{
1038if (Kind.isReadOnly())
1041assert(Kind.isReadOnlyWithRel() &&
"Unknown section kind");
1045/// Returns a unique section for the given machine basic block. 1052// For cold sections use the .text.split. prefix along with the parent 1053// function name. All cold blocks for the same function go to the same 1054// section. Similarly all exception blocks are grouped by symbol name 1055// under the .text.eh prefix. For regular sections, we either use a unique 1056// name, or a unique ID for the section. 1059if (FunctionSectionName ==
".text" ||
1061// Function is in a regular .text section. 1065Name += FunctionName;
1068Name += FunctionName;
1070Name += FunctionSectionName;
1072if (!
Name.ends_with(
"."))
1076 UniqueID = NextUniqueID++;
1080// If the original function has a custom non-dot-text section, then emit 1081// all basic block sections into that section too, each with a unique id. 1082Name = FunctionSectionName;
1083 UniqueID = NextUniqueID++;
1087 std::string GroupName;
1090 GroupName =
F.getComdat()->getName().str();
1093 0
/* Entry Size */, GroupName,
1094F.hasComdat(), UniqueID,
nullptr);
1098bool IsCtor,
unsigned Priority,
1116if (Priority != 65535) {
1118Name += utostr(Priority);
1121// The default scheme is .ctor / .dtor, so we have to invert the priority 1127if (Priority != 65535)
1136unsigned Priority,
constMCSymbol *KeySym)
const{
1142unsigned Priority,
constMCSymbol *KeySym)
const{
1150// We may only use a PLT-relative relocation to refer to unnamed_addr 1152if (!
LHS->hasGlobalUnnamedAddr() || !
LHS->getValueType()->isFunctionTy())
1155// Basic correctness checks. 1158RHS->isThreadLocal())
1173// A PLT entry is not needed for dso_local globals. 1174if (GV->isDSOLocal() || GV->isImplicitDSOLocal())
1182// Use ".GCC.command.line" since this feature is to support clang's 1183// -frecord-gcc-switches which in turn attempts to mimic GCC's switch of the 1191 UseInitArray = UseInitArray_;
1208//===----------------------------------------------------------------------===// 1210//===----------------------------------------------------------------------===// 1241unsigned Priority,
constMCSymbol *KeySym)
const{
1243// In userspace, we lower global destructors via atexit(), but kernel/kext 1244// environments do not provide this function so we still need to support the 1246// See the -disable-atexit-based-global-dtor-lowering CodeGen flag for more 1252// Emit the linker options if present. 1255unsigned VersionVal = 0;
1256unsigned ImageInfoFlags = 0;
1262// The section is mandatory. If we don't have it, then we don't have GC info. 1263if (SectionVal.
empty())
1267unsigned TAA = 0, StubSize = 0;
1270 SectionVal, Segment, Section, TAA, TAAParsed, StubSize)) {
1271// If invalid, report the error with report_fatal_error. 1273"': " +
toString(std::move(E)) +
".");
1281 getOrCreateSymbol(
StringRef(
"L_OBJC_IMAGE_INFO")));
1289if (
auto *LinkerOptions = M.getNamedMetadata(
"llvm.linker.options")) {
1290for (
constauto *Option : LinkerOptions->operands()) {
1292for (
constauto &Piece : cast<MDNode>(Option)->operands())
1293 StrOptions.
push_back(std::string(cast<MDString>(Piece)->getString()));
1305"' cannot be lowered.");
1313// Parse the section specifier and create it if valid. 1315unsigned TAA = 0, StubSize = 0;
1321SectionName, Segment, Section, TAA, TAAParsed, StubSize)) {
1322// If invalid, report the error with report_fatal_error. 1324"' has an invalid section specifier '" +
1332// If TAA wasn't set by ParseSectionSpecifier() above, 1333// use the value returned by getMachOSection() as a default. 1337// Okay, now that we got the section, verify that the TAA & StubSize agree. 1338// If the user declared multiple globals with different section flags, we need 1339// to reject it here. 1341// If invalid, report the error with report_fatal_error. 1343"' section type or attributes does not match previous" 1344" section specifier");
1354// Handle thread local data. 1361// If this is weak/linkonce, put this in a coalescable section, either in text 1362// or data depending on if it is writable. 1364if (Kind.isReadOnly())
1366if (Kind.isReadOnlyWithRel())
1371// FIXME: Alignment check should be handled by section classifier. 1372if (Kind.isMergeable1ByteCString() &&
1374 cast<GlobalVariable>(GO)) <
Align(32))
1377// Do not put 16-bit arrays in the UString section if they have an 1378// externally visible label, this runs into issues with certain linker 1382 cast<GlobalVariable>(GO)) <
Align(32))
1385// With MachO only variables whose corresponding symbol starts with 'l' or 1386// 'L' can be merged, so we only try merging GVs with private linkage. 1388if (Kind.isMergeableConst4())
1390if (Kind.isMergeableConst8())
1392if (Kind.isMergeableConst16())
1396// Otherwise, if it is readonly, but not something we can specially optimize, 1397// just drop it in .const. 1398if (Kind.isReadOnly())
1401// If this is marked const, put it into a const section. But if the dynamic 1402// linker needs to write to it, put it in the data segment. 1403if (Kind.isReadOnlyWithRel())
1406// Put zero initialized globals with strong external linkage in the 1407// DATA, __common section with the .zerofill directive. 1408if (Kind.isBSSExtern())
1411// Put zero initialized globals with local linkage in __DATA,__bss directive 1412// with the .zerofill directive (aka .lcomm). 1413if (Kind.isBSSLocal())
1416// Otherwise, just drop the variable in the normal data section. 1422Align &Alignment)
const{
1423// If this constant requires a relocation, we have to put it in the data 1424// segment, not in the text segment. 1425if (Kind.isData() || Kind.isReadOnlyWithRel())
1428if (Kind.isMergeableConst4())
1430if (Kind.isMergeableConst8())
1432if (Kind.isMergeableConst16())
1445// The mach-o version of this method defaults to returning a stub reference. 1453// Add information about the stub reference to MachOMMI so that the stub 1454// gets emitted by the asmprinter. 1473// The mach-o version of this method defaults to returning a stub reference. 1479// Add information about the stub reference to MachOMMI so that the stub 1480// gets emitted by the asmprinter. 1493// Although MachO 32-bit targets do not explicitly have a GOTPCREL relocation 1494// as 64-bit do, we replace the GOT equivalent by accessing the final symbol 1495// through a non_lazy_ptr stub instead. One advantage is that it allows the 1496// computation of deltas to final external symbols. Example: 1502// .long _extgotequiv-_delta 1504// is transformed to: 1507// .long L_extfoo$non_lazy_ptr-(_delta+0) 1509// .section __IMPORT,__pointers,non_lazy_symbol_pointers 1510// L_extfoo$non_lazy_ptr: 1511// .indirect_symbol _extfoo 1514// The indirect symbol table (and sections of non_lazy_symbol_pointers type) 1515// may point to both local (same translation unit) and global (other 1516// translation units) symbols. Example: 1518// .section __DATA,__pointers,non_lazy_symbol_pointers 1520// .indirect_symbol _myGlobal 1523// .indirect_symbol _myLocal 1526// If the symbol is local, instead of the symbol's index, the assembler 1527// places the constant INDIRECT_SYMBOL_LOCAL into the indirect symbol table. 1528// Then the linker will notice the constant in the table and will look at the 1529// content of the symbol. 1534// The offset must consider the original displacement from the base symbol 1535// since 32-bit targets don't have a GOTPCREL to fold the PC displacement. 1539// Access the final symbol via sym$non_lazy_ptr and generate the appropriated 1540// non_lazy_ptr stubs. 1572// FIXME: we should be able to use private labels for sections that can't be 1573// dead-stripped (there's no issue with blocking atomization there), but `ld 1574// -r` sometimes drops the no_dead_strip attribute from sections so for safety 1575// we don't allow it. 1582bool CannotUsePrivateLabel =
true;
1586 CannotUsePrivateLabel =
1592//===----------------------------------------------------------------------===// 1594//===----------------------------------------------------------------------===// 1604elseif (K.isExclude())
1618elseif (K.isThreadLocal())
1623elseif (K.isReadOnly() || K.isReadOnlyWithRel())
1627elseif (K.isWriteable())
1638assert(
C &&
"expected GV to have a Comdat!");
1644"' does not exist.");
1648"' is not a key for its COMDAT.");
1656if (
constauto *GA = dyn_cast<GlobalAlias>(ComdatKey))
1658if (ComdatKey == GV) {
1659switch (
C->getSelectionKind()) {
1682/*AddSegmentInfo=*/false) ||
1684/*AddSegmentInfo=*/false) ||
1686/*AddSegmentInfo=*/false) ||
1688/*AddSegmentInfo=*/false))
1703 COMDATSymName =
Sym->getName();
1719if (Kind.isThreadLocal())
1721if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1728// If we have -ffunction-sections then we should emit the global value to a 1729// uniqued section specifically for it. 1730bool EmitUniquedSection;
1732 EmitUniquedSection = TM.getFunctionSections();
1734 EmitUniquedSection = TM.getDataSections();
1736if ((EmitUniquedSection && !Kind.isCommon()) || GO->
hasComdat()) {
1752if (EmitUniquedSection)
1753 UniqueID = NextUniqueID++;
1759if (
constauto *
F = dyn_cast<Function>(GO))
1760if (std::optional<StringRef> Prefix =
F->getSectionPrefix())
1763// Append "$symbol" to the section name *before* IR-level mangling is 1764// applied when targetting mingw. This is what GCC does, and the ld.bfd 1765// COFF linker will not properly handle comdats otherwise. 1766if (
getContext().getTargetTriple().isWindowsGNUEnvironment())
1782if (Kind.isThreadLocal())
1785if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1788// Note: we claim that common symbols are put in BSSSection, but they are 1789// really emitted with the magic .comm directive, which creates a symbol table 1790// entry but not a section. 1791if (Kind.isBSS() || Kind.isCommon())
1800bool CannotUsePrivateLabel =
false;
1802 ((isa<Function>(GV) && TM.getFunctionSections()) ||
1803 (isa<GlobalVariable>(GV) && TM.getDataSections())))
1804 CannotUsePrivateLabel =
true;
1811// If the function can be removed, produce a unique section so that 1812// the table doesn't prevent the removal. 1814bool EmitUniqueSection = TM.getFunctionSections() ||
C;
1815if (!EmitUniqueSection)
1818// FIXME: we should produce a symbol for F instead. 1819if (
F.hasPrivateLinkage())
1829unsigned UniqueID = NextUniqueID++;
1837bool UsesLabelDifference,
constFunction &
F)
const{
1840// We can always create relative relocations, so use another section 1841// that can be marked non-executable. 1846 UsesLabelDifference,
F);
1858if (!Section.empty()) {
1874if (
NamedMDNode *LinkerOptions = M.getNamedMetadata(
"llvm.linker.options")) {
1875// Emit the linker options to the linker .drectve section. According to the 1876// spec, this section is a space-separated string containing flags for 1880for (
constauto *Option : LinkerOptions->operands()) {
1881for (
constauto &Piece : cast<MDNode>(Option)->operands()) {
1882// Lead with a space for consistency with our dllexport implementation. 1884Directive.append(std::string(cast<MDString>(Piece)->getString()));
1890// Emit /EXPORT: flags for each exported global as necessary. 1897if (!Flags.empty()) {
1904// Emit /INCLUDE: flags for each used global as necessary. 1905if (
constauto *LU = M.getNamedGlobal(
"llvm.used")) {
1906assert(LU->hasInitializer() &&
"expected llvm.used to have an initializer");
1907assert(isa<ArrayType>(LU->getValueType()) &&
1908"expected llvm.used to be an array type");
1909if (
constauto *
A = cast<ConstantArray>(LU->getInitializer())) {
1910for (
constValue *
Op :
A->operands()) {
1911constauto *GV = cast<GlobalValue>(
Op->stripPointerCasts());
1912// Global symbols with internal or private linkage are not visible to 1913// the linker, and thus would cause an error when the linker tried to 1914// preserve the symbol due to the `/include:` directive. 1915if (GV->hasLocalLinkage())
1923if (!Flags.empty()) {
1937constTriple &
T = TM.getTargetTriple();
1938if (
T.isWindowsMSVCEnvironment() ||
T.isWindowsItaniumEnvironment()) {
1960if (
T.isWindowsMSVCEnvironment() ||
T.isWindowsItaniumEnvironment()) {
1961// If the priority is the default, use .CRT$XCU, possibly associative. 1962if (Priority == 65535)
1965// Otherwise, we need to compute a new section name. Low priorities should 1966// run earlier. The linker will sort sections ASCII-betically, and we need a 1967// string that sorts between .CRT$XCA and .CRT$XCU. In the general case, we 1968// make a name like ".CRT$XCT12345", since that runs before .CRT$XCU. Really 1969// low priorities need to sort before 'L', since the CRT uses that 1970// internally, so we use ".CRT$XCA00001" for them. We have a contract with 1971// the frontend that "init_seg(compiler)" corresponds to priority 200 and 1972// "init_seg(lib)" corresponds to priority 400, and those respectively use 1973// 'C' and 'L' without the priority suffix. Priorities between 200 and 400 1974// use 'C' with the priority as a suffix. 1976char LastLetter =
'T';
1977bool AddPrioritySuffix = Priority != 200 && Priority != 400;
1980elseif (Priority < 400)
1982elseif (Priority == 400)
1985OS <<
".CRT$X" << (IsCtor ?
"C" :
"T") << LastLetter;
1986if (AddPrioritySuffix)
1993 std::string
Name = IsCtor ?
".ctors" :
".dtors";
1994if (Priority != 65535)
2005unsigned Priority,
constMCSymbol *KeySym)
const{
2012unsigned Priority,
constMCSymbol *KeySym)
const{
2021constTriple &
T = TM.getTargetTriple();
2025// Our symbols should exist in address space zero, cowardly no-op if 2031// Both ptrtoint instructions must wrap global objects: 2032// - Only global variables are eligible for image relative relocations. 2033// - The subtrahend refers to the special symbol __ImageBase, a GlobalVariable. 2034// We expect __ImageBase to be a global variable without a section, externally 2037// It should look something like this: @__ImageBase = external constant i8 2038if (!isa<GlobalObject>(
LHS) || !isa<GlobalVariable>(
RHS) ||
2039LHS->isThreadLocal() ||
RHS->isThreadLocal() ||
2040RHS->
getName() !=
"__ImageBase" || !
RHS->hasExternalLinkage() ||
2041 cast<GlobalVariable>(
RHS)->hasInitializer() ||
RHS->hasSection())
2051 std::string HexString =
toString(AI, 16,
/*Signed=*/false);
2053unsignedSize = HexString.size();
2054assert(Width >=
Size &&
"hex string is too large!");
2055 HexString.insert(HexString.begin(), Width -
Size,
'0');
2061Type *Ty =
C->getType();
2062if (isa<UndefValue>(
C)) {
2064 }
elseif (
constauto *CFP = dyn_cast<ConstantFP>(
C)) {
2066 }
elseif (
constauto *CI = dyn_cast<ConstantInt>(
C)) {
2069unsigned NumElements;
2070if (
auto *VTy = dyn_cast<VectorType>(Ty))
2071 NumElements = cast<FixedVectorType>(VTy)->getNumElements();
2074 std::string HexString;
2075for (
intI = NumElements - 1, E = -1;
I != E; --
I)
2083Align &Alignment)
const{
2084if (Kind.isMergeableConst() &&
C &&
2085getContext().getAsmInfo()->hasCOFFComdatConstants()) {
2086// This creates comdat sections with the given symbol name, but unless 2087// AsmPrinter::GetCPISymbol actually makes the symbol global, the symbol 2088// will be created with a null storage class, which makes GNU binutils 2093 std::string COMDATSymName;
2094if (Kind.isMergeableConst4()) {
2095if (Alignment <= 4) {
2097 Alignment =
Align(4);
2099 }
elseif (Kind.isMergeableConst8()) {
2100if (Alignment <= 8) {
2102 Alignment =
Align(8);
2104 }
elseif (Kind.isMergeableConst16()) {
2105// FIXME: These may not be appropriate for non-x86 architectures. 2106if (Alignment <= 16) {
2108 Alignment =
Align(16);
2110 }
elseif (Kind.isMergeableConst32()) {
2111if (Alignment <= 32) {
2113 Alignment =
Align(32);
2117if (!COMDATSymName.empty())
2127//===----------------------------------------------------------------------===// 2129//===----------------------------------------------------------------------===// 2138"SelectionKind::Any, '" +
C->getName() +
"' cannot be " 2147if (K.isThreadLocal())
2150if (K.isMergeableCString())
2156// TODO(sbc): Add suport for K.isMergeableConst() 2165if (
auto *GO = dyn_cast<GlobalObject>(GV))
2171// We don't support explict section names for functions in the wasm object 2172// format. Each function has to be in its own unique section. 2173if (isa<Function>(GO)) {
2179// Certain data sections we treat as named custom sections rather than 2180// segments within the data section. 2181// This could be avoided if all data segements (the wasm sense) were 2182// represented as their own sections (in the llvm sense). 2183// TODO(sbc): https://github.com/WebAssembly/tool-conventions/issues/138 2185/*AddSegmentInfo=*/false) ||
2187/*AddSegmentInfo=*/false) ||
2188Name ==
".llvmbc" ||
Name ==
".llvmcmd")
2193 Group =
C->getName();
2207unsigned *NextUniqueID,
bool Retain) {
2210 Group =
C->getName();
2213bool UniqueSectionNames = TM.getUniqueSectionNames();
2216if (
constauto *
F = dyn_cast<Function>(GO)) {
2217constauto &OptionalPrefix =
F->getSectionPrefix();
2222if (EmitUniqueSection && UniqueSectionNames) {
2224 TM.getNameWithPrefix(
Name, GO, Mang,
true);
2227if (EmitUniqueSection && !UniqueSectionNames) {
2228 UniqueID = *NextUniqueID;
2242// If we have -ffunction-section or -fdata-section then we should emit the 2243// global value to a uniqued section specifically for it. 2244bool EmitUniqueSection =
false;
2250bool Retain = Used.count(GO);
2251 EmitUniqueSection |= Retain;
2254 EmitUniqueSection, &NextUniqueID, Retain);
2258bool UsesLabelDifference,
constFunction &
F)
const{
2259// We can always create relative relocations, so use another section 2260// that can be marked non-executable. 2267// We may only use a PLT-relative relocation to refer to unnamed_addr 2269if (!
LHS->hasGlobalUnnamedAddr() || !
LHS->getValueType()->isFunctionTy())
2272// Basic correctness checks. 2275RHS->isThreadLocal())
2288// We don't use PersonalityEncoding and LSDAEncoding because we don't emit 2289// .cfi directives. We use TTypeEncoding to encode typeinfo global variables. 2294unsigned Priority,
constMCSymbol *KeySym)
const{
2295return Priority == UINT16_MAX ?
2302unsigned Priority,
constMCSymbol *KeySym)
const{
2306//===----------------------------------------------------------------------===// 2308//===----------------------------------------------------------------------===// 2315if (!
F.hasPersonalityFn() || !
F.needsUnwindTableEntry())
2319 dyn_cast<GlobalValue>(
F.getPersonalityFn()->stripPointerCasts());
2320assert(Per &&
"Personality routine is not a GlobalValue type.");
2330if (!
F.hasStackProtectorFnAttr())
2332// FIXME: check presence of canary word 2333// There are cases that the stack protectors are not really inserted even if 2334// the attributes are on. 2342 cast<MCSymbolXCOFF>(EHInfoSym)->setEHInfo();
2349// We always use a qualname symbol for a GV that represents 2350// a declaration, a function descriptor, or a common symbol. 2351// If a GV represents a GlobalVariable and -fdata-sections is enabled, we 2352// also return a qualname so that a label symbol could be avoided. 2353// It is inherently ambiguous when the GO represents the address of a 2354// function, as the GO could either represent a function descriptor or a 2355// function entry point. We choose to always return a function descriptor 2357if (
constGlobalObject *GO = dyn_cast<GlobalObject>(GV)) {
2358if (GO->isDeclarationForLinker())
2360 ->getQualNameSymbol();
2363if (GVar->hasAttribute(
"toc-data"))
2364return cast<MCSectionXCOFF>(
2366 ->getQualNameSymbol();
2370return cast<MCSectionXCOFF>(
2372 ->getQualNameSymbol();
2376 ->getQualNameSymbol();
2379// For all other cases, fall back to getSymbol to return the unqualified name. 2390// Handle the XCOFF::TD case first, then deal with the rest. 2392if (GVar->hasAttribute(
"toc-data"))
2396/* MultiSymbolsAllowed*/true);
2401elseif (Kind.isData() || Kind.isBSS())
2403elseif (Kind.isReadOnlyWithRel())
2406elseif (Kind.isReadOnly())
2413/* MultiSymbolsAllowed*/true);
2419"Tried to get ER section for a defined global.");
2424// AIX TLS local-dynamic does not need the external reference for the 2439if (GVar->hasAttribute(
"toc-data"))
2442// Externals go into a csect of type ER. 2450// Handle the XCOFF::TD case first, then deal with the rest. 2452if (GVar->hasAttribute(
"toc-data")) {
2459/* MultiSymbolsAllowed*/true);
2462// Common symbols go into a csect with matching name which will get mapped 2463// into the .bss section. 2464// Zero-initialized local TLS symbols go into a csect with matching name which 2465// will get mapped into the .tbss section. 2466if (Kind.isBSSLocal() || GO->
hasCommonLinkage() || Kind.isThreadBSSLocal()) {
2479 ->getRepresentedCsect();
2487"ReadOnlyPointers is supported only if data sections is turned on");
2496// For BSS kind, zero initialized data must be emitted to the .data section 2497// because external linkage control sections that get mapped to the .bss 2498// section will be linked as tentative defintions, which is only appropriate 2499// for SectionKind::Common. 2500if (Kind.isData() || Kind.isReadOnlyWithRel() || Kind.isBSS()) {
2511if (Kind.isReadOnly()) {
2522// External/weak TLS data and initialized local TLS data are not eligible 2523// to be put into common csect. If data sections are enabled, thread 2524// data are emitted into separate sections. Otherwise, thread data 2525// are emitted into the .tdata section. 2526if (Kind.isThreadLocal()) {
2541assert (!
F.getComdat() &&
"Comdat not supported on XCOFF.");
2546// If the function can be removed, produce a unique section so that 2547// the table doesn't prevent the removal. 2556bool UsesLabelDifference,
constFunction &
F)
const{
2560/// Given a mergeable constant with the specified size and relocation 2561/// information, return a section that it should be placed in. 2564Align &Alignment)
const{
2565// TODO: Enable emiting constant pool to unique sections when we support it. 2566if (Alignment >
Align(16))
2569if (Alignment ==
Align(8)) {
2574if (Alignment ==
Align(16)) {
2593// AIX debug for thread local location is not ready. And for integrated as 2594// mode, the relocatable address for the thread local variable will cause 2595// linker error. So disable the location attribute generation for thread local 2596// variables for now. 2597// FIXME: when TLS debug on AIX is ready, remove this setting. 2602unsigned Priority,
constMCSymbol *KeySym)
const{
2607unsigned Priority,
constMCSymbol *KeySym)
const{
2614/* Not implemented yet, but don't crash, return nullptr. */ 2620assert(!isa<GlobalIFunc>(GV) &&
"GlobalIFunc is not supported on AIX.");
2638"There is no mapping that implements AppendingLinkage for XCOFF.");
2645assert((isa<Function>(Func) ||
2646 (isa<GlobalAlias>(Func) &&
2647 isa_and_nonnull<Function>(
2648 cast<GlobalAlias>(Func)->getAliaseeObject()))) &&
2649"Func must be a function or an alias which has a function as base " 2656// When -function-sections is enabled and explicit section is not specified, 2657// it's not necessary to emit function entry point label any more. We will use 2658// function entry point csect instead. And for function delcarations, the 2659// undefined symbols gets treated as csect with XTY_ER property. 2661 Func->isDeclarationForLinker()) &&
2662 isa<Function>(Func)) {
2690// The "_$TLSML" symbol for TLS local-dynamic mode requires XMC_TC, 2691// otherwise the AIX assembler will complain. 2695// Use large code model toc entries for ehinfo symbols as they are 2696// never referenced directly. The runtime loads their TOC entry 2697// addresses from the trace-back table. 2701// If the symbol does not have a code model specified use the module value. 2720// If option -ffunction-sections is on, append the function name to the 2721// name of the LSDA csect so that each function has its own LSDA csect. 2722// This helps the linker to garbage-collect EH info of unused functions. 2726 LSDA->getCsectProp());
2730//===----------------------------------------------------------------------===// 2732//===----------------------------------------------------------------------===// 2742 std::string
Name =
".gcc_exception_table." +
F.getName().str();
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
static bool isThumb(const MCSubtargetInfo &STI)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
COFFYAML::WeakExternalCharacteristics Characteristics
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.
This file declares the MCSectionGOFF class, which contains all of the necessary machine code sections...
This file contains the declarations for metadata subclasses.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
This file contains some functions that are useful when dealing with strings.
static bool canUsePrivateLabel(const MCAsmInfo &AsmInfo, const MCSection &Section)
static MCSection * selectExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM, MCContext &Ctx, Mangler &Mang, unsigned &NextUniqueID, bool Retain, bool ForceUnique)
static int getSelectionForCOFF(const GlobalValue *GV)
static MCSectionCOFF * getCOFFStaticStructorSection(MCContext &Ctx, const Triple &T, bool IsCtor, unsigned Priority, const MCSymbol *KeySym, MCSectionCOFF *Default)
static unsigned getEntrySizeForKind(SectionKind Kind)
static void GetObjCImageInfo(Module &M, unsigned &Version, unsigned &Flags, StringRef &Section)
static const GlobalValue * getComdatGVForCOFF(const GlobalValue *GV)
static unsigned getCOFFSectionFlags(SectionKind K, const TargetMachine &TM)
static StringRef handlePragmaClangSection(const GlobalObject *GO, SectionKind Kind)
static unsigned getELFSectionType(StringRef Name, SectionKind K)
static bool hasPrefix(StringRef SectionName, StringRef Prefix)
static MCSectionWasm * selectWasmSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool EmitUniqueSection, unsigned *NextUniqueID, bool Retain)
static const MCSymbolELF * getLinkedToSymbol(const GlobalObject *GO, const TargetMachine &TM)
static unsigned calcUniqueIDUpdateFlagsAndSize(const GlobalObject *GO, StringRef SectionName, SectionKind Kind, const TargetMachine &TM, MCContext &Ctx, Mangler &Mang, unsigned &Flags, unsigned &EntrySize, unsigned &NextUniqueID, const bool Retain, const bool ForceUnique)
Calculate an appropriate unique ID for a section, and update Flags, EntrySize and NextUniqueID where ...
static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K)
static const Comdat * getWasmComdat(const GlobalValue *GV)
static MCSectionELF * getStaticStructorSection(MCContext &Ctx, bool UseInitArray, bool IsCtor, unsigned Priority, const MCSymbol *KeySym)
static unsigned getWasmSectionFlags(SectionKind K, bool Retain)
static void checkMachOComdat(const GlobalValue *GV)
static std::string APIntToHexString(const APInt &AI)
static cl::opt< bool > JumpTableInFunctionSection("jumptable-in-function-section", cl::Hidden, cl::init(false), cl::desc("Putting Jump Table in function section"))
static StringRef getSectionPrefixForGlobal(SectionKind Kind, bool IsLarge)
Return the section prefix name used by options FunctionsSections and DataSections.
static MCSectionELF * selectELFSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool EmitUniqueSection, unsigned Flags, unsigned *NextUniqueID, const MCSymbolELF *AssociatedSymbol)
static SmallString< 128 > getELFSectionNameForGlobal(const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, unsigned EntrySize, bool UniqueSectionName)
static std::string scalarConstantToHexString(const Constant *C)
static StringRef getCOFFSectionNameForUniqueGlobal(SectionKind Kind)
static const Comdat * getELFComdat(const GlobalValue *GV)
static std::tuple< StringRef, bool, unsigned > getGlobalObjectInfo(const GlobalObject *GO, const TargetMachine &TM)
static unsigned getELFSectionFlags(SectionKind K)
Class for arbitrary precision integers.
unsigned getBitWidth() const
Return the number of bits in the APInt.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
@ Largest
The linker will choose the largest COMDAT.
@ SameSize
The data referenced by the COMDAT must be the same size.
@ Any
The linker may choose any COMDAT.
@ NoDeduplicate
No deduplication is performed.
@ ExactMatch
The data referenced by the COMDAT must be the same.
This is an important base class in LLVM.
Wrapper for a function that represents a value that functionally represents the original function.
GlobalValue * getGlobalValue() const
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Align getPreferredAlign(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global.
StringRef getPrivateGlobalPrefix() const
This is the base abstract class for diagnostic reporting in the backend.
Interface for custom diagnostic printing.
Lightweight error class with error context and mandatory checking.
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.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
bool hasExternalLinkage() const
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
LinkageTypes getLinkage() const
bool hasLocalLinkage() const
bool hasPrivateLinkage() const
const Comdat * getComdat() const
ThreadLocalMode getThreadLocalMode() const
bool isDeclarationForLinker() const
Module * getParent()
Get the module that this global value is contained inside of...
const GlobalObject * getAliaseeObject() const
const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
bool hasCommonLinkage() const
static bool isWeakForLinker(LinkageTypes Linkage)
Whether the definition of this global may be replaced at link time.
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ CommonLinkage
Tentative definitions.
@ InternalLinkage
Rename collisions when linking (static functions).
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ ExternalLinkage
Externally visible function.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
@ AppendingLinkage
Special purpose, only applies to global arrays.
@ AvailableExternallyLinkage
Available for inspection, not emission.
@ ExternalWeakLinkage
ExternalWeak linkage description.
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
AttributeSet getAttributes() const
Return the attribute set for this global.
bool hasImplicitSection() const
Check if section name is present.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
static bool isSectionAtomizableBySymbols(const MCSection &Section)
True if the section is atomized using the symbols in it.
This class is intended to be used as a base class for asm properties and features specific to the tar...
bool useIntegratedAssembler() const
Return true if assembly (inline or otherwise) should be parsed.
bool binutilsIsAtLeast(int Major, int Minor) const
ExceptionHandling getExceptionHandlingType() const
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
const MCObjectFileInfo * getObjectFileInfo() const
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, const char *BeginSymName=nullptr)
Return the MCSection for the specified mach-o section.
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
MCSectionELF * getELFNamedSection(const Twine &Prefix, const Twine &Suffix, unsigned Type, unsigned Flags, unsigned EntrySize=0)
Get a section with the provided group identifier.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
MCSectionXCOFF * getXCOFFSection(StringRef Section, SectionKind K, std::optional< XCOFF::CsectProperties > CsectProp=std::nullopt, bool MultiSymbolsAllowed=false, std::optional< XCOFF::DwarfSectionSubtypeFlags > DwarfSubtypeFlags=std::nullopt)
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID)
MCSectionGOFF * getGOFFSection(StringRef Section, SectionKind Kind, MCSection *Parent, uint32_t Subsection=0)
bool isELFGenericMergeableSection(StringRef Name)
std::optional< unsigned > getELFUniqueIDForEntsize(StringRef SectionName, unsigned Flags, unsigned EntrySize)
Return the unique ID of the section with the given name, flags and entry size, if it exists.
const MCAsmInfo * getAsmInfo() const
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
bool isELFImplicitMergeableSectionNamePrefix(StringRef Name)
MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=GenericSectionID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym.
@ GenericSectionID
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
Base class for the full range of assembler expressions which are needed for parsing.
MCSection * TLSBSSSection
Section directive for Thread Local uninitialized data.
MCSection * MergeableConst16Section
MCSection * MergeableConst4Section
MCSection * TextSection
Section directive for standard text.
MCSection * ConstDataCoalSection
MCSection * ConstTextCoalSection
MCSection * TLSDataSection
Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
MCSection * MergeableConst8Section
MCSection * LSDASection
If exception handling is supported by the target, this is the section the Language Specific Data Area...
MCSection * ReadOnly16Section
MCSection * FourByteConstantSection
MCSection * ReadOnly8Section
MCSection * DataBSSSection
MCSection * getDrectveSection() const
MCSection * TextCoalSection
MCSection * DataRelROSection
MCSection * CStringSection
bool isPositionIndependent() const
MCSection * DataCoalSection
MCSection * UStringSection
MCSection * MergeableConst32Section
MCSection * SixteenByteConstantSection
MCSection * DataCommonSection
MCSection * ReadOnlySection
Section that is readonly and can contain arbitrary initialized data.
MCSection * BSSSection
Section that is default initialized to zero.
MCSection * EightByteConstantSection
MCSection * getTextSection() const
MCSection * ConstDataSection
MCContext & getContext() const
MCSection * DataSection
Section directive for standard data.
This represents a section on Windows.
This represents a section on linux, lots of unix variants and some bare metal systems.
This represents a section on a Mach-O system (used by Mac OS X).
static Error ParseSectionSpecifier(StringRef Spec, StringRef &Segment, StringRef &Section, unsigned &TAA, bool &TAAParsed, unsigned &StubSize)
Parse the section specifier indicated by "Spec".
unsigned getTypeAndAttributes() const
unsigned getStubSize() const
This represents a section on wasm.
MCSymbolXCOFF * getQualNameSymbol() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
static constexpr unsigned NonUniqueID
StringRef getName() const
Streaming machine code generation interface.
virtual void addBlankLine()
Emit a blank line to a .s file to pretty it up.
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
void emitSymbolValue(const MCSymbol *Sym, unsigned Size, bool IsSectionRelative=false)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void emitValueToAlignment(Align Alignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
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...
virtual void emitLinkerOptions(ArrayRef< std::string > Kind)
Emit the given list Options of strings as linker options into the output.
void emitInt64(uint64_t Value)
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
void emitInt32(uint64_t Value)
void emitInt8(uint64_t Value)
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
const MCSymbol & getSymbol() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
StringRef getSymbolTableName() const
bool hasPerSymbolCodeModel() const
CodeModel getPerSymbolCodeModel() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
StringRef getName() const
getName - Get the symbol name.
This represents an "assembler immediate".
int64_t getConstant() const
const MCSymbolRefExpr * getSymB() const
const MDOperand & getOperand(unsigned I) const
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
bool isBeginSection() const
Returns true if this block begins any section.
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MCContext & getContext() const
Function & getFunction()
Return the LLVM function that this machine code represents.
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
MCSection * getSection() const
Returns the Section this function belongs to.
MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation for ELF targets.
StubValueTy & getGVStubEntry(MCSymbol *Sym)
PointerIntPair< MCSymbol *, 1, bool > StubValueTy
MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation for MachO targets.
StubValueTy & getGVStubEntry(MCSymbol *Sym)
This class contains meta information specific to a module.
const Module * getModule() const
Ty & getObjFileInfo()
Keep track of various per-module pieces of information for backends that would like to do so.
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
A Module instance is used to store all the information related to an LLVM module.
@ Require
Adds a requirement that another module flag be present and have a specified value after linking is pe...
const std::string & getSourceFileName() const
Get the module's original source file name.
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
PointerIntPair - This class implements a pair of a pointer and small integer.
PointerTy getPointer() const
SectionKind - This is a simple POD value that classifies the properties of a section.
static SectionKind getThreadData()
static SectionKind getMetadata()
bool isThreadBSSLocal() const
static SectionKind getText()
static SectionKind getData()
static SectionKind getBSS()
static SectionKind getThreadBSS()
static SectionKind getReadOnly()
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const override
Given a mergeable constant with the specified size and relocation information, return a section that ...
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit Obj-C garbage collection and linker options.
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
void emitLinkerDirectives(MCStreamer &Streamer, Module &M) const override
Process linker options metadata and emit platform-specific bits.
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
MCSection * getUniqueSectionForFunction(const Function &F, const TargetMachine &TM) const override
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const override
Given a constant with the SectionKind, return a section that it should be placed in.
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit Obj-C garbage collection and linker options.
void emitLinkerDirectives(MCStreamer &Streamer, Module &M) const override
Process linker options metadata and emit platform-specific bits.
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
TargetLoweringObjectFileELF()
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym, const MachineModuleInfo *MMI) const override
const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
Return an MCExpr to use for a reference to the specified type info global variable from exception han...
void getModuleMetadata(Module &M) override
Get the module-level metadata that the platform cares about.
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
const MCExpr * lowerDSOLocalEquivalent(const DSOLocalEquivalent *Equiv, const TargetMachine &TM) const override
MCSection * getSectionForCommandLines() const override
If supported, return the section to use for the llvm.commandline metadata.
MCSection * getSectionForLSDA(const Function &F, const MCSymbol &FnSym, const TargetMachine &TM) const override
virtual void emitPersonalityValueImpl(MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym, const MachineModuleInfo *MMI) const
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
void InitializeELF(bool UseInitArray_)
MCSection * getSectionForMachineBasicBlock(const Function &F, const MachineBasicBlock &MBB, const TargetMachine &TM) const override
Returns a unique section for the given machine basic block.
MCSymbolRefExpr::VariantKind PLTRelativeVariantKind
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
MCSection * getSectionForLSDA(const Function &F, const MCSymbol &FnSym, const TargetMachine &TM) const override
TargetLoweringObjectFileGOFF()
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const override
Given a constant with the SectionKind, return a section that it should be placed in.
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
void emitLinkerDirectives(MCStreamer &Streamer, Module &M) const override
Process linker options metadata and emit platform-specific bits.
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
const MCExpr * getIndirectSymViaGOTPCRel(const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV, int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
Get MachO PC relative GOT entry relocation.
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit the module flags that specify the garbage collection information.
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
MCSection * getSectionForCommandLines() const override
If supported, return the section to use for the llvm.commandline metadata.
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
TargetLoweringObjectFileMachO()
const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const override
The mach-o version of this method defaults to returning a stub reference.
void getModuleMetadata(Module &M) override
Get the module-level metadata that the platform cares about.
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
static bool ShouldSetSSPCanaryBitInTB(const MachineFunction *MF)
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
MCSection * getSectionForTOCEntry(const MCSymbol *Sym, const TargetMachine &TM) const override
On targets that support TOC entries, return a section for the entry given the symbol it refers to.
MCSection * getSectionForExternalReference(const GlobalObject *GO, const TargetMachine &TM) const override
For external functions, this will always return a function descriptor csect.
MCSymbol * getFunctionEntryPointSymbol(const GlobalValue *Func, const TargetMachine &TM) const override
If supported, return the function entry point symbol.
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
static MCSymbol * getEHInfoTableSymbol(const MachineFunction *MF)
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
static XCOFF::StorageClass getStorageClassForGlobal(const GlobalValue *GV)
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const override
Given a constant with the SectionKind, return a section that it should be placed in.
MCSymbol * getTargetSymbol(const GlobalValue *GV, const TargetMachine &TM) const override
For functions, this will always return a function descriptor symbol.
MCSection * getSectionForFunctionDescriptor(const Function *F, const TargetMachine &TM) const override
On targets that use separate function descriptor symbols, return a section for the descriptor given i...
static bool ShouldEmitEHBlock(const MachineFunction *MF)
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
MCSection * getSectionForLSDA(const Function &F, const MCSymbol &FnSym, const TargetMachine &TM) const override
For functions, this will return the LSDA section.
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
MCSection * StaticDtorSection
This section contains the static destructor pointer list.
unsigned PersonalityEncoding
PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values for EH.
Mangler & getMangler() const
bool SupportIndirectSymViaGOTPCRel
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 bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const
bool SupportDebugThreadLocalLocation
bool supportDSOLocalEquivalentLowering() const
Target supports a native lowering of a dso_local_equivalent constant without needing to replace it wi...
virtual void Initialize(MCContext &ctx, const TargetMachine &TM)
This method must be called before any actual lowering is done.
unsigned getPersonalityEncoding() const
MCSection * StaticCtorSection
This section contains the static constructor pointer list.
bool SupportDSOLocalEquivalentLowering
virtual MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment) const
Given a constant with the SectionKind, return a section that it should be placed in.
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 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...
unsigned CallSiteEncoding
const MCExpr * getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, MCStreamer &Streamer) 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.
const Triple & getTargetTriple() const
bool getUniqueBasicBlockSectionNames() const
Return true if unique basic block section names must be generated.
bool getUniqueSectionNames() const
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
MCSymbol * getSymbol(const GlobalValue *GV) const
bool getDataSections() const
Return true if data objects should be emitted into their own section, corresponds to -fdata-sections.
CodeModel::Model getCodeModel() const
Returns the code model.
bool getFunctionSections() const
Return true if functions should be emitted into their own section, corresponding to -ffunction-sectio...
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
unsigned XCOFFReadOnlyPointers
When set to true, const objects with relocatable address values are put into the RO data section.
unsigned UseInitArray
UseInitArray - Use .init_array instead of .ctors for static constructors.
Triple - Helper class for working with autoconf configuration names.
ArchType getArch() const
Get the parsed architecture type of this triple.
EnvironmentType getEnvironment() const
Get the parsed environment type of this triple.
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string str() const
Return the twine contents as a std::string.
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
uint64_t getArrayNumElements() const
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVMContext & getContext() const
All values hold a context through their type.
StringRef getName() const
Return a constant reference to the value's name.
A raw_ostream that writes to an std::string.
A raw_ostream that writes to an SmallVector or SmallString.
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_SCN_CNT_UNINITIALIZED_DATA
@ IMAGE_SCN_MEM_DISCARDABLE
@ IMAGE_SCN_CNT_INITIALIZED_DATA
@ IMAGE_COMDAT_SELECT_NODUPLICATES
@ IMAGE_COMDAT_SELECT_LARGEST
@ IMAGE_COMDAT_SELECT_SAME_SIZE
@ IMAGE_COMDAT_SELECT_ASSOCIATIVE
@ IMAGE_COMDAT_SELECT_EXACT_MATCH
@ IMAGE_COMDAT_SELECT_ANY
@ C
The default llvm calling convention, compatible with C.
@ SHT_LLVM_DEPENDENT_LIBRARIES
@ SHT_LLVM_LINKER_OPTIONS
@ S_MOD_TERM_FUNC_POINTERS
S_MOD_TERM_FUNC_POINTERS - Section with only function pointers for termination.
@ S_MOD_INIT_FUNC_POINTERS
S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for initialization.
StorageMappingClass
Storage Mapping Class definitions.
@ XMC_TE
Symbol mapped at the end of TOC.
@ XMC_DS
Descriptor csect.
@ XMC_TL
Initialized thread-local variable.
@ XMC_RO
Read Only Constant.
@ XMC_UA
Unclassified - Treated as Read Write.
@ XMC_TD
Scalar data item in the TOC.
@ XMC_UL
Uninitialized thread-local variable.
@ XMC_BS
BSS class (uninitialized static internal)
@ XMC_TC
General TOC item.
@ XTY_CM
Common csect definition. For uninitialized storage.
@ XTY_SD
Csect definition for initialized storage.
@ XTY_ER
External reference.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
bool isNoOpWithoutInvoke(EHPersonality Pers)
Return true if this personality may be safely removed if there are no invoke instructions remaining i...
OutputIt transform(R &&Range, OutputIt d_first, UnaryFunction F)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere.
std::string encodeBase64(InputBytes const &Bytes)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
void emitLinkerFlagsForUsedCOFF(raw_ostream &OS, const GlobalValue *GV, const Triple &T, Mangler &M)
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV, const Triple &TT, Mangler &Mangler)
const char * toString(DWARFSectionKind Kind)
cl::opt< std::string > BBSectionsColdTextPrefix
@ Default
The result values are uniform if and only if all operands are uniform.
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
@ MCSA_Hidden
.hidden (ELF)
GlobalVariable * collectUsedGlobalVariables(const Module &M, SmallVectorImpl< GlobalValue * > &Vec, bool CompilerUsed)
Given "llvm.used" or "llvm.compiler.used" as a global name, collect the initializer elements of that ...
constexpr const char * PseudoProbeDescMetadataName
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t value() const
This is a hole in the type system and should not be abused.
static const MBBSectionID ExceptionSectionID
static const MBBSectionID ColdSectionID