76 cl::desc(
"Putting Jump Table in function section"));
81 M.getModuleFlagsMetadata(ModuleFlags);
83 for (
const auto &MFE: ModuleFlags) {
89 if (Key ==
"Objective-C Image Info Version") {
90 Version = mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue();
91 }
else if (Key ==
"Objective-C Garbage Collection" ||
92 Key ==
"Objective-C GC Only" ||
93 Key ==
"Objective-C Is Simulated" ||
94 Key ==
"Objective-C Class Properties" ||
95 Key ==
"Objective-C Image Swift Version") {
96 Flags |= mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue();
97 }
else if (Key ==
"Objective-C Image Info Section") {
98 Section = cast<MDString>(MFE.Val)->getString();
102 else if (Key ==
"Swift ABI Version") {
103 Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 8;
104 }
else if (Key ==
"Swift Major Version") {
105 Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 24;
106 }
else if (Key ==
"Swift Minor Version") {
107 Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 16;
302 if (
auto *GO = dyn_cast<GlobalObject>(GV))
310 if (
NamedMDNode *LinkerOptions = M.getNamedMetadata(
"llvm.linker.options")) {
316 for (
const auto *Operand : LinkerOptions->operands()) {
317 if (cast<MDNode>(Operand)->getNumOperands() != 2)
319 for (
const auto &Option : cast<MDNode>(Operand)->operands()) {
320 Streamer.
emitBytes(cast<MDString>(Option)->getString());
326 if (
NamedMDNode *DependentLibraries = M.getNamedMetadata(
"llvm.dependent-libraries")) {
332 for (
const auto *Operand : DependentLibraries->operands()) {
334 cast<MDString>(cast<MDNode>(Operand)->getOperand(0))->getString());
346 for (
const auto *Operand : FuncInfo->operands()) {
347 const auto *MD = cast<MDNode>(Operand);
348 auto *GUID = mdconst::dyn_extract<ConstantInt>(MD->getOperand(0));
349 auto *Hash = mdconst::dyn_extract<ConstantInt>(MD->getOperand(1));
350 auto *
Name = cast<MDString>(MD->getOperand(2));
351 auto *S =
C.getObjectFileInfo()->getPseudoProbeDescSection(
355 Streamer.
emitInt64(GUID->getZExtValue());
356 Streamer.
emitInt64(Hash->getZExtValue());
362 if (
NamedMDNode *LLVMStats = M.getNamedMetadata(
"llvm.stats")) {
365 auto *S =
C.getObjectFileInfo()->getLLVMStatsSection();
367 for (
const auto *Operand : LLVMStats->operands()) {
368 const auto *MD = cast<MDNode>(Operand);
369 assert(MD->getNumOperands() % 2 == 0 &&
370 (
"Operand num should be even for a list of key/value pair"));
371 for (
size_t I = 0;
I < MD->getNumOperands();
I += 2) {
373 auto *Key = cast<MDString>(MD->getOperand(
I));
378 Twine(mdconst::dyn_extract<ConstantInt>(MD->getOperand(
I + 1))
387 unsigned Version = 0;
392 if (!Section.empty()) {
419 NameData +=
Sym->getName();
421 cast<MCSymbolELF>(
getContext().getOrCreateSymbol(NameData));
427 unsigned Size =
DL.getPointerSize();
475 Name ==
".llvmbc" ||
Name ==
".llvmcmd")
478 if (
Name.empty() ||
Name[0] !=
'.')
return K;
481 if (
Name ==
".bss" ||
482 Name.startswith(
".bss.") ||
483 Name.startswith(
".gnu.linkonce.b.") ||
484 Name.startswith(
".llvm.linkonce.b.") ||
486 Name.startswith(
".sbss.") ||
487 Name.startswith(
".gnu.linkonce.sb.") ||
488 Name.startswith(
".llvm.linkonce.sb."))
491 if (
Name ==
".tdata" ||
492 Name.startswith(
".tdata.") ||
493 Name.startswith(
".gnu.linkonce.td.") ||
494 Name.startswith(
".llvm.linkonce.td."))
497 if (
Name ==
".tbss" ||
498 Name.startswith(
".tbss.") ||
499 Name.startswith(
".gnu.linkonce.tb.") ||
500 Name.startswith(
".llvm.linkonce.tb."))
515 if (
Name.startswith(
".note"))
530 if (K.isBSS() || K.isThreadBSS())
539 if (!K.isMetadata() && !K.isExclude())
548 if (K.isExecuteOnly())
554 if (K.isThreadLocal())
557 if (K.isMergeableCString() || K.isMergeableConst())
560 if (K.isMergeableCString())
574 "SelectionKind::NoDeduplicate, '" +
575 C->getName() +
"' cannot be lowered.");
587 auto *OtherGV = dyn_cast<GlobalValue>(VM->getValue());
588 return OtherGV ? dyn_cast<MCSymbolELF>(
TM.getSymbol(OtherGV)) :
nullptr;
592 if (Kind.isMergeable1ByteCString())
594 else if (Kind.isMergeable2ByteCString())
596 else if (Kind.isMergeable4ByteCString())
598 else if (Kind.isMergeableConst4())
600 else if (Kind.isMergeableConst8())
602 else if (Kind.isMergeableConst16())
604 else if (Kind.isMergeableConst32())
609 assert(!Kind.isMergeableCString() &&
"unknown string width");
610 assert(!Kind.isMergeableConst() &&
"unknown data width");
620 if (Kind.isReadOnly())
621 return IsLarge ?
".lrodata" :
".rodata";
623 return IsLarge ?
".lbss" :
".bss";
624 if (Kind.isThreadData())
626 if (Kind.isThreadBSS())
629 return IsLarge ?
".ldata" :
".data";
630 if (Kind.isReadOnlyWithRel())
631 return IsLarge ?
".ldata.rel.ro" :
".data.rel.ro";
638 unsigned EntrySize,
bool UniqueSectionName) {
640 if (Kind.isMergeableCString()) {
645 cast<GlobalVariable>(GO));
647 std::string SizeSpec =
".rodata.str" + utostr(EntrySize) +
".";
648 Name = SizeSpec + utostr(Alignment.
value());
649 }
else if (Kind.isMergeableConst()) {
650 Name =
".rodata.cst";
651 Name += utostr(EntrySize);
653 bool IsLarge =
false;
654 if (
auto *GV = dyn_cast<GlobalVariable>(GO))
655 IsLarge =
TM.isLargeData(GV);
659 bool HasPrefix =
false;
660 if (
const auto *
F = dyn_cast<Function>(GO)) {
661 if (std::optional<StringRef> Prefix =
F->getSectionPrefix()) {
667 if (UniqueSectionName) {
669 TM.getNameWithPrefix(
Name, GO, Mang,
true);
670 }
else if (HasPrefix)
682 LoweringDiagnosticInfo(
const Twine &DiagMsg,
695 unsigned &EntrySize,
unsigned &NextUniqueID,
696 const bool Retain,
const bool ForceUnique) {
701 return NextUniqueID++;
705 const bool Associated = GO->
getMetadata(LLVMContext::MD_associated);
708 return NextUniqueID++;
712 if (
TM.getTargetTriple().isOSSolaris())
717 return NextUniqueID++;
728 if (!SupportsUnique) {
729 Flags &= ~ELF::SHF_MERGE;
735 const bool SeenSectionNameBefore =
739 if (!SymbolMergeable && !SeenSectionNameBefore)
745 const auto PreviousID =
756 if (SymbolMergeable &&
763 return NextUniqueID++;
766static std::tuple<StringRef, bool, unsigned>
769 bool IsComdat =
false;
773 Group =
C->getName();
776 if (
auto *GV = dyn_cast<GlobalVariable>(GO)) {
777 if (
TM.isLargeData(GV)) {
782 return {Group, IsComdat, Flags};
788 bool Retain,
bool ForceUnique) {
797 if (Attrs.hasAttribute(
"bss-section") && Kind.isBSS()) {
798 SectionName = Attrs.getAttribute(
"bss-section").getValueAsString();
799 }
else if (Attrs.hasAttribute(
"rodata-section") && Kind.isReadOnly()) {
800 SectionName = Attrs.getAttribute(
"rodata-section").getValueAsString();
801 }
else if (Attrs.hasAttribute(
"relro-section") && Kind.isReadOnlyWithRel()) {
802 SectionName = Attrs.getAttribute(
"relro-section").getValueAsString();
803 }
else if (Attrs.hasAttribute(
"data-section") && Kind.isData()) {
804 SectionName = Attrs.getAttribute(
"data-section").getValueAsString();
807 const Function *
F = dyn_cast<Function>(GO);
808 if (
F &&
F->hasFnAttribute(
"implicit-section-name")) {
809 SectionName =
F->getFnAttribute(
"implicit-section-name").getValueAsString();
821 GO,
SectionName, Kind,
TM, Ctx, Mang, Flags, EntrySize, NextUniqueID,
822 Retain, ForceUnique);
827 Group, IsComdat, UniqueID, LinkedToSym);
830 assert(Section->getLinkedToSymbol() == LinkedToSym &&
831 "Associated symbol mismatch between sections");
841 "Symbol '" + GO->
getName() +
"' from module '" +
843 "' required a section with entry-size=" +
846 ": Explicit assignment by pragma or attribute of an incompatible "
847 "symbol to this section?"));
856 NextUniqueID, Used.count(GO),
863 unsigned *NextUniqueID,
const MCSymbolELF *AssociatedSymbol) {
871 bool UniqueSectionName =
false;
873 if (EmitUniqueSection) {
874 if (
TM.getUniqueSectionNames()) {
875 UniqueSectionName =
true;
877 UniqueID = *NextUniqueID;
882 GO, Kind, Mang,
TM, EntrySize, UniqueSectionName);
885 if (Kind.isExecuteOnly())
888 EntrySize, Group, IsComdat, UniqueID,
895 unsigned Flags,
unsigned *NextUniqueID) {
898 EmitUniqueSection =
true;
902 if (
TM.getTargetTriple().isOSSolaris()) {
903 EmitUniqueSection =
true;
907 EmitUniqueSection =
true;
913 Ctx, GO, Kind, Mang,
TM, EmitUniqueSection, Flags,
914 NextUniqueID, LinkedToSym);
915 assert(Section->getLinkedToSymbol() == LinkedToSym);
925 bool EmitUniqueSection =
false;
934 Used.count(GO), EmitUniqueSection, Flags,
944 if (
F.hasSection() ||
F.hasFnAttribute(
"implicit-section-name"))
947 Used.count(&
F),
true);
951 true, Flags, &NextUniqueID);
960 if (!EmitUniqueSection)
976 const auto *LSDA = cast<MCSectionELF>(
LSDASection);
977 unsigned Flags = LSDA->getFlags();
980 bool IsComdat =
false;
983 Group =
C->getName();
989 (
getContext().getAsmInfo()->useIntegratedAssembler() &&
990 getContext().getAsmInfo()->binutilsIsAtLeast(2, 36))) {
992 LinkedToSym = cast<MCSymbolELF>(&FnSym);
1005 bool UsesLabelDifference,
const Function &
F)
const {
1015 Align &Alignment)
const {
1024 if (Kind.isReadOnly())
1027 assert(Kind.isReadOnlyWithRel() &&
"Unknown section kind");
1045 if (FunctionSectionName.
equals(
".text") ||
1051 Name += FunctionName;
1053 Name +=
".text.eh.";
1054 Name += FunctionName;
1056 Name += FunctionSectionName;
1058 if (!
Name.endswith(
"."))
1062 UniqueID = NextUniqueID++;
1068 Name = FunctionSectionName;
1069 UniqueID = NextUniqueID++;
1073 std::string GroupName;
1074 if (
F.hasComdat()) {
1076 GroupName =
F.getComdat()->getName().str();
1080 F.hasComdat(), UniqueID,
nullptr);
1084 bool IsCtor,
unsigned Priority,
1097 Name =
".init_array";
1100 Name =
".fini_array";
1102 if (Priority != 65535) {
1104 Name += utostr(Priority);
1113 if (Priority != 65535)
1122 unsigned Priority,
const MCSymbol *KeySym)
const {
1128 unsigned Priority,
const MCSymbol *KeySym)
const {
1138 if (!
LHS->hasGlobalUnnamedAddr() || !
LHS->getValueType()->isFunctionTy())
1144 RHS->isThreadLocal())
1160 if (GV->isDSOLocal() || GV->isImplicitDSOLocal())
1177 UseInitArray = UseInitArray_;
1179 if (!UseInitArray) {
1227 unsigned Priority,
const MCSymbol *KeySym)
const {
1239 if (
auto *LinkerOptions = M.getNamedMetadata(
"llvm.linker.options")) {
1240 for (
const auto *Option : LinkerOptions->operands()) {
1242 for (
const auto &Piece : cast<MDNode>(Option)->operands())
1243 StrOptions.
push_back(std::string(cast<MDString>(Piece)->getString()));
1248 unsigned VersionVal = 0;
1249 unsigned ImageInfoFlags = 0;
1256 if (SectionVal.
empty())
1260 unsigned TAA = 0, StubSize = 0;
1263 SectionVal, Segment, Section, TAA, TAAParsed, StubSize)) {
1274 getOrCreateSymbol(
StringRef(
"L_OBJC_IMAGE_INFO")));
1286 "' cannot be lowered.");
1297 if (Attrs.hasAttribute(
"bss-section") && Kind.isBSS()) {
1298 SectionName = Attrs.getAttribute(
"bss-section").getValueAsString();
1299 }
else if (Attrs.hasAttribute(
"rodata-section") && Kind.isReadOnly()) {
1300 SectionName = Attrs.getAttribute(
"rodata-section").getValueAsString();
1301 }
else if (Attrs.hasAttribute(
"relro-section") && Kind.isReadOnlyWithRel()) {
1302 SectionName = Attrs.getAttribute(
"relro-section").getValueAsString();
1303 }
else if (Attrs.hasAttribute(
"data-section") && Kind.isData()) {
1304 SectionName = Attrs.getAttribute(
"data-section").getValueAsString();
1308 const Function *
F = dyn_cast<Function>(GO);
1309 if (
F &&
F->hasFnAttribute(
"implicit-section-name")) {
1310 SectionName =
F->getFnAttribute(
"implicit-section-name").getValueAsString();
1315 unsigned TAA = 0, StubSize = 0;
1321 SectionName, Segment, Section, TAA, TAAParsed, StubSize)) {
1324 "' has an invalid section specifier '" +
1343 "' section type or attributes does not match previous"
1344 " section specifier");
1364 if (Kind.isReadOnly())
1366 if (Kind.isReadOnlyWithRel())
1372 if (Kind.isMergeable1ByteCString() &&
1374 cast<GlobalVariable>(GO)) <
Align(32))
1382 cast<GlobalVariable>(GO)) <
Align(32))
1388 if (Kind.isMergeableConst4())
1390 if (Kind.isMergeableConst8())
1392 if (Kind.isMergeableConst16())
1398 if (Kind.isReadOnly())
1403 if (Kind.isReadOnlyWithRel())
1408 if (Kind.isBSSExtern())
1413 if (Kind.isBSSLocal())
1422 Align &Alignment)
const {
1425 if (Kind.isData() || Kind.isReadOnlyWithRel())
1428 if (Kind.isMergeableConst4())
1430 if (Kind.isMergeableConst8())
1432 if (Kind.isMergeableConst16())
1582 bool CannotUsePrivateLabel =
true;
1586 CannotUsePrivateLabel =
1604 else if (K.isExclude())
1607 else if (K.isText())
1618 else if (K.isThreadLocal())
1623 else if (K.isReadOnly() || K.isReadOnlyWithRel())
1627 else if (K.isWriteable())
1638 assert(
C &&
"expected GV to have a Comdat!");
1644 "' does not exist.");
1648 "' is not a key for its COMDAT.");
1656 if (
const auto *GA = dyn_cast<GlobalAlias>(ComdatKey))
1658 if (ComdatKey == GV) {
1659 switch (
C->getSelectionKind()) {
1694 COMDATSymName =
Sym->getName();
1710 if (Kind.isThreadLocal())
1712 if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1721 bool EmitUniquedSection;
1723 EmitUniquedSection =
TM.getFunctionSections();
1725 EmitUniquedSection =
TM.getDataSections();
1727 if ((EmitUniquedSection && !Kind.isCommon()) || GO->
hasComdat()) {
1743 if (EmitUniquedSection)
1744 UniqueID = NextUniqueID++;
1750 if (
const auto *
F = dyn_cast<Function>(GO))
1751 if (std::optional<StringRef> Prefix =
F->getSectionPrefix())
1757 if (
getContext().getTargetTriple().isWindowsGNUEnvironment())
1773 if (Kind.isThreadLocal())
1776 if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1782 if (Kind.isBSS() || Kind.isCommon())
1791 bool CannotUsePrivateLabel =
false;
1793 ((isa<Function>(GV) &&
TM.getFunctionSections()) ||
1794 (isa<GlobalVariable>(GV) &&
TM.getDataSections())))
1795 CannotUsePrivateLabel =
true;
1805 bool EmitUniqueSection =
TM.getFunctionSections() ||
C;
1806 if (!EmitUniqueSection)
1810 if (
F.hasPrivateLinkage())
1820 unsigned UniqueID = NextUniqueID++;
1828 bool UsesLabelDifference,
const Function &
F)
const {
1837 UsesLabelDifference,
F);
1842 emitLinkerDirectives(Streamer, M);
1844 unsigned Version = 0;
1849 if (!Section.empty()) {
1851 auto *S =
C.getCOFFSection(Section,
1865void TargetLoweringObjectFileCOFF::emitLinkerDirectives(
1867 if (
NamedMDNode *LinkerOptions = M.getNamedMetadata(
"llvm.linker.options")) {
1873 for (
const auto *Option : LinkerOptions->operands()) {
1874 for (
const auto &Piece : cast<MDNode>(Option)->operands()) {
1877 Directive.append(std::string(cast<MDString>(Piece)->getString()));
1890 if (!
Flags.empty()) {
1898 if (
const auto *LU =
M.getNamedGlobal(
"llvm.used")) {
1899 assert(LU->hasInitializer() &&
"expected llvm.used to have an initializer");
1900 assert(isa<ArrayType>(LU->getValueType()) &&
1901 "expected llvm.used to be an array type");
1902 if (
const auto *
A = cast<ConstantArray>(LU->getInitializer())) {
1903 for (
const Value *
Op :
A->operands()) {
1904 const auto *GV = cast<GlobalValue>(
Op->stripPointerCasts());
1908 if (GV->hasLocalLinkage())
1916 if (!
Flags.empty()) {
1931 if (
T.isWindowsMSVCEnvironment() ||
T.isWindowsItaniumEnvironment()) {
1957 if (
T.isWindowsMSVCEnvironment() ||
T.isWindowsItaniumEnvironment()) {
1959 if (Priority == 65535)
1973 char LastLetter =
'T';
1974 bool AddPrioritySuffix = Priority != 200 && Priority != 400;
1977 else if (Priority < 400)
1979 else if (Priority == 400)
1982 OS <<
".CRT$X" << (IsCtor ?
"C" :
"T") << LastLetter;
1983 if (AddPrioritySuffix)
1991 std::string
Name = IsCtor ?
".ctors" :
".dtors";
1992 if (Priority != 65535)
2004 unsigned Priority,
const MCSymbol *KeySym)
const {
2011 unsigned Priority,
const MCSymbol *KeySym)
const {
2021 if (
T.isOSCygMing())
2037 if (!isa<GlobalObject>(
LHS) || !isa<GlobalVariable>(
RHS) ||
2038 LHS->isThreadLocal() ||
RHS->isThreadLocal() ||
2039 RHS->
getName() !=
"__ImageBase" || !
RHS->hasExternalLinkage() ||
2040 cast<GlobalVariable>(
RHS)->hasInitializer() ||
RHS->hasSection())
2050 std::string HexString =
toString(AI, 16,
false);
2052 unsigned Size = HexString.size();
2053 assert(Width >=
Size &&
"hex string is too large!");
2054 HexString.insert(HexString.begin(), Width -
Size,
'0');
2060 Type *Ty =
C->getType();
2061 if (isa<UndefValue>(
C)) {
2063 }
else if (
const auto *CFP = dyn_cast<ConstantFP>(
C)) {
2065 }
else if (
const auto *CI = dyn_cast<ConstantInt>(
C)) {
2068 unsigned NumElements;
2069 if (
auto *VTy = dyn_cast<VectorType>(Ty))
2070 NumElements = cast<FixedVectorType>(VTy)->getNumElements();
2073 std::string HexString;
2074 for (
int I = NumElements - 1,
E = -1;
I !=
E; --
I)
2082 Align &Alignment)
const {
2083 if (Kind.isMergeableConst() &&
C &&
2084 getContext().getAsmInfo()->hasCOFFComdatConstants()) {
2092 std::string COMDATSymName;
2093 if (Kind.isMergeableConst4()) {
2094 if (Alignment <= 4) {
2096 Alignment =
Align(4);
2098 }
else if (Kind.isMergeableConst8()) {
2099 if (Alignment <= 8) {
2101 Alignment =
Align(8);
2103 }
else if (Kind.isMergeableConst16()) {
2105 if (Alignment <= 16) {
2107 Alignment =
Align(16);
2109 }
else if (Kind.isMergeableConst32()) {
2110 if (Alignment <= 32) {
2112 Alignment =
Align(32);
2116 if (!COMDATSymName.empty())
2137 "SelectionKind::Any, '" +
C->getName() +
"' cannot be "
2146 if (K.isThreadLocal())
2149 if (K.isMergeableCString())
2161 if (isa<Function>(GO)) {
2172 if (
Name ==
".llvmcmd" ||
Name ==
".llvmbc")
2177 Group =
C->getName();
2189 const TargetMachine &
TM,
bool EmitUniqueSection,
unsigned *NextUniqueID) {
2192 Group =
C->getName();
2195 bool UniqueSectionNames =
TM.getUniqueSectionNames();
2198 if (
const auto *
F = dyn_cast<Function>(GO)) {
2199 const auto &OptionalPrefix =
F->getSectionPrefix();
2204 if (EmitUniqueSection && UniqueSectionNames) {
2205 Name.push_back(
'.');
2206 TM.getNameWithPrefix(
Name, GO, Mang,
true);
2209 if (EmitUniqueSection && !UniqueSectionNames) {
2210 UniqueID = *NextUniqueID;
2221 if (Kind.isCommon())
2226 bool EmitUniqueSection =
false;
2234 EmitUniqueSection, &NextUniqueID);
2238 bool UsesLabelDifference,
const Function &
F)
const {
2249 if (!
LHS->hasGlobalUnnamedAddr() || !
LHS->getValueType()->isFunctionTy())
2255 RHS->isThreadLocal())
2274 unsigned Priority,
const MCSymbol *KeySym)
const {
2275 return Priority == UINT16_MAX ?
2282 unsigned Priority,
const MCSymbol *KeySym)
const {
2295 if (!
F.hasPersonalityFn() || !
F.needsUnwindTableEntry())
2299 dyn_cast<GlobalValue>(
F.getPersonalityFn()->stripPointerCasts());
2300 assert(Per &&
"Personality routine is not a GlobalValue type.");
2310 if (!
F.hasStackProtectorFnAttr())
2335 if (
const GlobalObject *GO = dyn_cast<GlobalObject>(GV)) {
2336 if (GO->isDeclarationForLinker())
2338 ->getQualNameSymbol();
2341 if (GVar->hasAttribute(
"toc-data"))
2342 return cast<MCSectionXCOFF>(
2344 ->getQualNameSymbol();
2348 return cast<MCSectionXCOFF>(
2350 ->getQualNameSymbol();
2354 ->getQualNameSymbol();
2370 if (GVar->hasAttribute(
"toc-data"))
2379 else if (Kind.isData() || Kind.isBSS())
2381 else if (Kind.isReadOnlyWithRel())
2384 else if (Kind.isReadOnly())
2397 "Tried to get ER section for a defined global.");
2408 if (GVar->hasAttribute(
"toc-data"))
2421 if (GVar->hasAttribute(
"toc-data")) {
2433 if (Kind.isBSSLocal() || GO->
hasCommonLinkage() || Kind.isThreadBSSLocal()) {
2443 if (Kind.isText()) {
2446 ->getRepresentedCsect();
2454 "ReadOnlyPointers is supported only if data sections is turned on");
2467 if (Kind.isData() || Kind.isReadOnlyWithRel() || Kind.isBSS()) {
2478 if (Kind.isReadOnly()) {
2493 if (Kind.isThreadLocal()) {
2508 assert (!
F.getComdat() &&
"Comdat not supported on XCOFF.");
2523 bool UsesLabelDifference,
const Function &
F)
const {
2531 Align &Alignment)
const {
2533 if (Alignment >
Align(16))
2536 if (Alignment ==
Align(8)) {
2541 if (Alignment ==
Align(16)) {
2569 unsigned Priority,
const MCSymbol *KeySym)
const {
2574 unsigned Priority,
const MCSymbol *KeySym)
const {
2587 assert(!isa<GlobalIFunc>(GV) &&
"GlobalIFunc is not supported on AIX.");
2605 "There is no mapping that implements AppendingLinkage for XCOFF.");
2612 assert((isa<Function>(Func) ||
2613 (isa<GlobalAlias>(Func) &&
2614 isa_and_nonnull<Function>(
2615 cast<GlobalAlias>(Func)->getAliaseeObject()))) &&
2616 "Func must be a function or an alias which has a function as base "
2628 Func->isDeclarationForLinker()) &&
2629 isa<Function>(Func)) {
2672 LSDA->getCsectProp());
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
static bool isThumb(const MCSubtargetInfo &STI)
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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.
This file declares the MCSectionGOFF class, which contains all of the necessary machine code sections...
Module.h This file contains the declarations for the Module class.
const char LLVMTargetMachineRef TM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
static unsigned getWasmSectionFlags(SectionKind K)
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 MCSectionWasm * selectWasmSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool EmitUniqueSection, unsigned *NextUniqueID)
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 unsigned getELFSectionType(StringRef Name, SectionKind K)
static bool hasPrefix(StringRef SectionName, StringRef Prefix)
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 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
bool isDeclarationForLinker() const
Module * getParent()
Get the module that this global value is contained inside of...
const GlobalObject * getAliaseeObject() const
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.
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.
virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const
True if the section is atomized using the symbols in it.
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)
bool isELFGenericMergeableSection(StringRef Name)
@ GenericSectionID
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
MCSectionXCOFF * getXCOFFSection(StringRef Section, SectionKind K, std::optional< XCOFF::CsectProperties > CsectProp=std::nullopt, bool MultiSymbolsAllowed=false, const char *BeginSymName=nullptr, std::optional< XCOFF::DwarfSectionSubtypeFlags > DwarfSubtypeFlags=std::nullopt)
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
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
bool isELFImplicitMergeableSectionNamePrefix(StringRef Name)
MCSectionGOFF * getGOFFSection(StringRef Section, SectionKind Kind, MCSection *Parent, const MCExpr *SubsectionId)
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.
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, const MCExpr *Subsection=nullptr)
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)
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.
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.
MachineModuleInfo & getMMI() const
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 MCContext & getContext() const
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.
constexpr bool empty() const
empty - Check if the string is empty.
bool startswith(StringRef Prefix) const
bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
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
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.
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 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
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...
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
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.
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.
const CustomOperand< const MCSubtargetInfo & > Msg[]
@ 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)
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
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)
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