83 cl::desc(
"Putting Jump Table in function section"));
88 M.getModuleFlagsMetadata(ModuleFlags);
90 for (
const auto &MFE: ModuleFlags) {
96 if (
Key ==
"Objective-C Image Info Version") {
98 }
else if (
Key ==
"Objective-C Garbage Collection" ||
99 Key ==
"Objective-C GC Only" ||
100 Key ==
"Objective-C Is Simulated" ||
101 Key ==
"Objective-C Class Properties" ||
102 Key ==
"Objective-C Image Swift Version") {
104 }
else if (
Key ==
"Objective-C Image Info Section") {
109 else if (
Key ==
"Swift ABI Version") {
111 }
else if (
Key ==
"Swift Major Version") {
113 }
else if (
Key ==
"Swift Minor Version") {
325 if (
NamedMDNode *DependentLibraries = M.getNamedMetadata(
"llvm.dependent-libraries")) {
331 for (
const auto *Operand : DependentLibraries->operands()) {
340 if (
NamedMDNode *LLVMStats = M.getNamedMetadata(
"llvm.stats")) {
343 auto *S =
C.getObjectFileInfo()->getLLVMStatsSection();
345 for (
const auto *Operand : LLVMStats->operands()) {
347 assert(MD->getNumOperands() % 2 == 0 &&
348 (
"Operand num should be even for a list of key/value pair"));
349 for (
size_t I = 0;
I < MD->getNumOperands();
I += 2) {
352 Streamer.emitULEB128IntValue(
Key->getString().size());
370 if (!Section.empty()) {
385 if (
NamedMDNode *LinkerOptions = M.getNamedMetadata(
"llvm.linker.options")) {
391 for (
const auto *Operand : LinkerOptions->operands()) {
394 for (
const auto &Option :
cast<MDNode>(Operand)->operands()) {
408 TM.getSymbol(GV)->getName());
410 return TM.getSymbol(GV);
426 unsigned Size =
DL.getPointerSize();
428 Streamer.emitValueToAlignment(
DL.getPointerABIAlignment(0));
440 Streamer.emitSymbolValue(Sym,
DL.getPointerSize());
484 Name ==
".llvmbc" || Name ==
".llvmcmd")
487 if (!Name.starts_with(
"."))
return K;
490 if (Name ==
".bss" || Name.starts_with(
".bss.") ||
491 Name.starts_with(
".gnu.linkonce.b.") ||
492 Name.starts_with(
".llvm.linkonce.b.") || Name ==
".sbss" ||
493 Name.starts_with(
".sbss.") || Name.starts_with(
".gnu.linkonce.sb.") ||
494 Name.starts_with(
".llvm.linkonce.sb."))
497 if (Name ==
".tdata" || Name.starts_with(
".tdata.") ||
498 Name.starts_with(
".gnu.linkonce.td.") ||
499 Name.starts_with(
".llvm.linkonce.td."))
502 if (Name ==
".tbss" || Name.starts_with(
".tbss.") ||
503 Name.starts_with(
".gnu.linkonce.tb.") ||
504 Name.starts_with(
".llvm.linkonce.tb."))
519 if (Name.starts_with(
".note"))
533 if (Name ==
".llvm.lto")
536 if (
K.isBSS() ||
K.isThreadBSS())
545 if (!
K.isMetadata() && !
K.isExclude())
554 if (
K.isExecuteOnly()) {
557 else if (
T.isARM() ||
T.isThumb())
564 if (
K.isThreadLocal())
567 if (
K.isMergeableCString() ||
K.isMergeableConst())
570 if (
K.isMergeableCString())
592 "SelectionKind::NoDeduplicate, '" +
593 C->getName() +
"' cannot be lowered.");
611 if (Kind.isMergeable1ByteCString())
613 else if (Kind.isMergeable2ByteCString())
615 else if (Kind.isMergeable4ByteCString())
617 else if (Kind.isMergeableConst4())
619 else if (Kind.isMergeableConst8())
621 else if (Kind.isMergeableConst16())
623 else if (Kind.isMergeableConst32())
628 assert(!Kind.isMergeableCString() &&
"unknown string width");
629 assert(!Kind.isMergeableConst() &&
"unknown data width");
638 return IsLarge ?
".ltext" :
".text";
639 if (Kind.isReadOnly())
640 return IsLarge ?
".lrodata" :
".rodata";
642 return IsLarge ?
".lbss" :
".bss";
643 if (Kind.isThreadData())
645 if (Kind.isThreadBSS())
648 return IsLarge ?
".ldata" :
".data";
649 if (Kind.isReadOnlyWithRel())
650 return IsLarge ?
".ldata.rel.ro" :
".data.rel.ro";
657 bool UniqueSectionName,
662 if (Kind.isMergeableCString()) {
670 Name +=
utostr(EntrySize);
672 Name +=
utostr(Alignment.value());
673 }
else if (Kind.isMergeableConst()) {
675 Name +=
utostr(EntrySize);
678 bool HasPrefix =
false;
698 }
else if (std::optional<StringRef> Prefix =
F->getSectionPrefix())
701 if (std::optional<StringRef> Prefix = GV->getSectionPrefix()) {
706 if (!SectionPrefix.
empty()) {
707 bool AddSectionPrefix =
true;
708 if (Kind.isReadOnly() || Kind.isReadOnlyWithRel() || Kind.isData() ||
715 if (AddSectionPrefix) {
716 Name += SectionPrefix;
721 if (UniqueSectionName) {
724 }
else if (HasPrefix)
739 void print(DiagnosticPrinter &DP)
const override { DP <<
Msg; }
749 unsigned &EntrySize,
unsigned &NextUniqueID,
750 const bool Retain,
const bool ForceUnique) {
755 return NextUniqueID++;
759 const bool Associated = GO->
getMetadata(LLVMContext::MD_associated);
762 return NextUniqueID++;
768 else if (Ctx.getAsmInfo().useIntegratedAssembler() ||
769 Ctx.getAsmInfo().binutilsIsAtLeast(2, 36))
771 return NextUniqueID++;
780 const bool SupportsUnique = Ctx.getAsmInfo().useIntegratedAssembler() ||
781 Ctx.getAsmInfo().binutilsIsAtLeast(2, 35);
782 if (!SupportsUnique) {
783 Flags &=
~ELF::SHF_MERGE;
789 const bool SeenSectionNameBefore =
793 if (!SymbolMergeable && !SeenSectionNameBefore) {
795 return NextUniqueID++;
803 const auto PreviousID =
804 Ctx.getELFUniqueIDForEntsize(
SectionName, Flags, EntrySize);
815 if (SymbolMergeable &&
816 Ctx.isELFImplicitMergeableSectionNamePrefix(
SectionName) &&
822 return NextUniqueID++;
825static std::tuple<StringRef, bool, unsigned, unsigned, unsigned>
829 bool IsComdat =
false;
833 Group =
C->getName();
839 unsigned Type, EntrySize;
854 return {Group, IsComdat, Flags,
Type, EntrySize};
861 unsigned &NextUniqueID,
862 bool Retain,
bool ForceUnique) {
870 auto [Group, IsComdat, ExtraFlags,
Type, EntrySize] =
875 GO,
SectionName, Kind, TM, Ctx, Mang, Flags, EntrySize, NextUniqueID,
880 Ctx.getELFSection(
SectionName,
Type, Flags, EntrySize, Group, IsComdat,
884 assert(Section->getLinkedToSymbol() == LinkedToSym &&
885 "Associated symbol mismatch between sections");
887 if (!(Ctx.getAsmInfo().useIntegratedAssembler() ||
888 Ctx.getAsmInfo().binutilsIsAtLeast(2, 35))) {
895 "Symbol '" + GO->
getName() +
"' from module '" +
897 "' required a section with entry-size=" +
900 ": Explicit assignment by pragma or attribute of an incompatible "
901 "symbol to this section?"));
910 NextUniqueID, Used.count(GO),
916 const TargetMachine &TM,
bool EmitUniqueSection,
unsigned Flags,
917 unsigned *NextUniqueID,
const MCSymbolELF *AssociatedSymbol,
919 bool UniqueSectionName =
false;
921 if (EmitUniqueSection) {
923 UniqueSectionName =
true;
932 auto [Group, IsComdat, ExtraFlags,
Type, EntrySize] =
937 if (Kind.isExecuteOnly())
939 return Ctx.getELFSection(Name,
Type, Flags, EntrySize, Group, IsComdat,
946 unsigned Flags,
unsigned *NextUniqueID) {
949 EmitUniqueSection =
true;
954 EmitUniqueSection =
true;
956 }
else if (Ctx.getAsmInfo().useIntegratedAssembler() ||
957 Ctx.getAsmInfo().binutilsIsAtLeast(2, 36)) {
958 EmitUniqueSection =
true;
962 if (GO->
hasMetadata(LLVMContext::MD_elf_section_properties))
963 EmitUniqueSection =
true;
966 Ctx, GO, Kind, Mang, TM, EmitUniqueSection, Flags,
967 NextUniqueID, LinkedToSym);
968 assert(Section->getLinkedToSymbol() == LinkedToSym);
978 bool EmitUniqueSection =
false;
981 EmitUniqueSection =
TM.getFunctionSections();
983 EmitUniqueSection =
TM.getDataSections();
987 Used.count(GO), EmitUniqueSection, Flags,
1000 Used.count(&
F),
true);
1004 true, Flags, &NextUniqueID);
1018 bool EmitUniqueSection =
TM.getFunctionSections() ||
C;
1019 if (!EmitUniqueSection && !
TM.getEnableStaticDataPartitioning())
1032 if (!
LSDASection || (!
F.hasComdat() && !
TM.getFunctionSections()))
1039 bool IsComdat =
false;
1042 Group =
C->getName();
1047 if (
TM.getFunctionSections() &&
1048 (
getContext().getAsmInfo().useIntegratedAssembler() &&
1049 getContext().getAsmInfo().binutilsIsAtLeast(2, 36))) {
1051 LinkedToSym =
static_cast<const MCSymbolELF *
>(&FnSym);
1057 (
TM.getUniqueSectionNames() ? LSDA->getName() +
"." +
F.getName()
1064 bool UsesLabelDifference,
const Function &
F)
const {
1079 if (Kind.isMergeableCString() &&
C) {
1080 assert(
C->getType()->isSized());
1081 return TM->isLargeDataSize(
DL.getTypeAllocSize(
C->getType()));
1093 if (Kind.isMergeableConst() || Kind.isMergeableCString())
1099 StringRef CstPrefix = IsLarge ?
".lrodata" :
".rodata";
1101 if (!SectionSuffix.
empty()) {
1103 SectionSuffixStr += SectionSuffix;
1107 if (Kind.isMergeableConst4())
1108 return Context.getELFSection(CstPrefix +
".cst4" + SectionSuffixStr,
1110 if (Kind.isMergeableConst8())
1111 return Context.getELFSection(CstPrefix +
".cst8" + SectionSuffixStr,
1113 if (Kind.isMergeableConst16())
1114 return Context.getELFSection(CstPrefix +
".cst16" + SectionSuffixStr,
1116 if (Kind.isMergeableConst32())
1117 return Context.getELFSection(CstPrefix +
".cst32" + SectionSuffixStr,
1119 if (Kind.isReadOnly())
1120 return Context.getELFSection(
1124 assert(Kind.isReadOnlyWithRel() &&
"Unknown section kind");
1125 return Context.getELFSection(
".data.rel.ro" + SectionSuffixStr,
1139 if (SectionSuffix.
empty())
1149 assert(
MBB.isBeginSection() &&
"Basic block does not start a section!");
1158 StringRef FunctionSectionName =
MBB.getParent()->getSection()->getName();
1159 if (FunctionSectionName ==
".text" ||
1165 Name += FunctionName;
1167 Name +=
".text.eh.";
1168 Name += FunctionName;
1170 Name += FunctionSectionName;
1171 if (
TM.getUniqueBasicBlockSectionNames()) {
1172 if (!Name.ends_with(
"."))
1174 Name +=
MBB.getSymbol()->getName();
1182 Name = FunctionSectionName;
1189 std::string GroupName;
1190 if (
F.hasComdat()) {
1192 GroupName =
F.getComdat()->getName().str();
1200 bool IsCtor,
unsigned Priority,
1213 Name =
".init_array";
1216 Name =
".fini_array";
1218 if (Priority != 65535) {
1220 Name +=
utostr(Priority);
1229 if (Priority != 65535)
1234 return Ctx.getELFSection(Name,
Type, Flags, 0,
Comdat,
true);
1238 unsigned Priority,
const MCSymbol *KeySym)
const {
1244 unsigned Priority,
const MCSymbol *KeySym)
const {
1251 std::optional<int64_t> PCRelativeOffset)
const {
1259 Addend += *PCRelativeOffset;
1280 std::optional<int64_t> PCRelativeOffset,
const TargetMachine &
TM)
const {
1301 UseInitArray = UseInitArray_;
1303 if (!UseInitArray) {
1352 unsigned Priority,
const MCSymbol *KeySym)
const {
1368 unsigned VersionVal = 0;
1369 unsigned ImageInfoFlags = 0;
1376 if (SectionVal.
empty())
1380 unsigned TAA = 0, StubSize = 0;
1383 SectionVal, Segment, Section, TAA, TAAParsed, StubSize)) {
1386 "': " +
toString(std::move(E)) +
".");
1394 getOrCreateSymbol(
StringRef(
"L_OBJC_IMAGE_INFO")));
1396 Streamer.emitInt32(ImageInfoFlags);
1403 auto [Segment, SecName] = Name.split(
',');
1409 if (
auto *LinkerOptions = M.getNamedMetadata(
"llvm.linker.options")) {
1410 for (
const auto *Option : LinkerOptions->operands()) {
1412 for (
const auto &Piece :
cast<MDNode>(Option)->operands())
1414 Streamer.emitLinkerOptions(StrOptions);
1425 "' cannot be lowered.");
1436 unsigned TAA = 0, StubSize = 0;
1442 SectionName, Segment, Section, TAA, TAAParsed, StubSize)) {
1445 "' has an invalid section specifier '" +
1464 "' section type or attributes does not match previous"
1465 " section specifier");
1485 if (Kind.isReadOnly())
1487 if (Kind.isReadOnlyWithRel())
1493 if (Kind.isMergeable1ByteCString() &&
1509 if (Kind.isMergeableConst4())
1511 if (Kind.isMergeableConst8())
1513 if (Kind.isMergeableConst16())
1519 if (Kind.isReadOnly())
1524 if (Kind.isReadOnlyWithRel())
1529 if (Kind.isBSSExtern())
1534 if (Kind.isBSSLocal())
1546 if (Kind.isData() || Kind.isReadOnlyWithRel())
1549 if (Kind.isMergeableConst4())
1551 if (Kind.isMergeableConst8())
1553 if (Kind.isMergeableConst16())
1667 MCSymbol *Stub = Ctx.getOrCreateSymbol(Name);
1701 bool CannotUsePrivateLabel =
true;
1722 else if (
K.isExclude())
1725 else if (
K.isText())
1736 else if (
K.isThreadLocal())
1741 else if (
K.isReadOnly() ||
K.isReadOnlyWithRel())
1745 else if (
K.isWriteable())
1756 assert(
C &&
"expected GV to have a Comdat!");
1762 "' does not exist.");
1766 "' is not a key for its COMDAT.");
1776 if (ComdatKey == GV) {
1777 switch (
C->getSelectionKind()) {
1807 Name ==
".llvmbc" || Name ==
".llvmcmd")
1822 COMDATSymName = Sym->
getName();
1838 if (Kind.isThreadLocal())
1840 if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1849 bool EmitUniquedSection;
1851 EmitUniquedSection =
TM.getFunctionSections();
1853 EmitUniquedSection =
TM.getDataSections();
1855 if ((EmitUniquedSection && !Kind.isCommon()) || GO->
hasComdat()) {
1871 if (EmitUniquedSection)
1879 if (std::optional<StringRef> Prefix =
F->getSectionPrefix())
1885 if (
getContext().getTargetTriple().isOSCygMing())
1901 if (Kind.isThreadLocal())
1904 if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1910 if (Kind.isBSS() || Kind.isCommon())
1919 bool CannotUsePrivateLabel =
false;
1923 CannotUsePrivateLabel =
true;
1933 bool EmitUniqueSection =
TM.getFunctionSections() ||
C;
1934 if (!EmitUniqueSection)
1938 if (
F.hasPrivateLinkage())
1948 unsigned UniqueID = NextUniqueID++;
1956 bool UsesLabelDifference,
const Function &
F)
const {
1965 UsesLabelDifference,
F);
1977 if (!Section.empty()) {
1993 if (Sym->isUndefined()) {
2009 if (
NamedMDNode *LinkerOptions = M.getNamedMetadata(
"llvm.linker.options")) {
2015 for (
const auto *Option : LinkerOptions->operands()) {
2016 for (
const auto &Piece :
cast<MDNode>(Option)->operands()) {
2031 if (!Flags.empty()) {
2039 if (
const auto *LU = M.getNamedGlobal(
"llvm.used")) {
2040 assert(LU->hasInitializer() &&
"expected llvm.used to have an initializer");
2042 "expected llvm.used to be an array type");
2044 for (
const Value *
Op :
A->operands()) {
2049 if (GV->hasLocalLinkage())
2056 if (!Flags.empty()) {
2071 if (
T.isWindowsMSVCEnvironment() ||
T.isWindowsItaniumEnvironment()) {
2093 if (
T.isWindowsMSVCEnvironment() ||
T.isWindowsItaniumEnvironment()) {
2095 if (Priority == 65535)
2096 return Ctx.getAssociativeCOFFSection(
Default, KeySym, 0);
2109 char LastLetter =
'T';
2110 bool AddPrioritySuffix = Priority != 200 && Priority != 400;
2113 else if (Priority < 400)
2115 else if (Priority == 400)
2118 OS <<
".CRT$X" << (IsCtor ?
"C" :
"T") << LastLetter;
2119 if (AddPrioritySuffix)
2120 OS <<
format(
"%05u", Priority);
2123 return Ctx.getAssociativeCOFFSection(Sec, KeySym, 0);
2126 std::string Name = IsCtor ?
".ctors" :
".dtors";
2127 if (Priority != 65535)
2130 return Ctx.getAssociativeCOFFSection(
2138 unsigned Priority,
const MCSymbol *KeySym)
const {
2145 unsigned Priority,
const MCSymbol *KeySym)
const {
2153 std::optional<int64_t> PCRelativeOffset,
const TargetMachine &
TM)
const {
2154 const Triple &
T = LHS->getParent()->getTargetTriple();
2155 if (
T.isOSCygMing())
2160 if (LHS->getType()->getPointerAddressSpace() != 0 ||
2161 RHS->getType()->getPointerAddressSpace() != 0)
2185 RHS->isThreadLocal() || RHS->getName() !=
"__ImageBase" ||
2186 !RHS->hasExternalLinkage() ||
2200 std::string HexString =
toString(AI, 16,
false);
2202 unsigned Size = HexString.size();
2203 assert(Width >=
Size &&
"hex string is too large!");
2204 HexString.insert(HexString.begin(), Width -
Size,
'0');
2210 Type *Ty =
C->getType();
2214 if (CFP->getType()->isFloatingPointTy())
2217 std::string HexString;
2218 unsigned NumElements =
2220 for (
unsigned I = 0;
I < NumElements; ++
I)
2224 if (CI->getType()->isIntegerTy())
2227 std::string HexString;
2228 unsigned NumElements =
2230 for (
unsigned I = 0;
I < NumElements; ++
I)
2234 unsigned NumElements;
2238 NumElements = Ty->getArrayNumElements();
2239 std::string HexString;
2240 for (
int I = NumElements - 1,
E = -1;
I !=
E; --
I)
2249 if (Kind.isMergeableConst() &&
C &&
2250 getContext().getAsmInfo().hasCOFFComdatConstants()) {
2258 std::string COMDATSymName;
2259 if (Kind.isMergeableConst4()) {
2260 if (Alignment <= 4) {
2262 Alignment =
Align(4);
2264 }
else if (Kind.isMergeableConst8()) {
2265 if (Alignment <= 8) {
2267 Alignment =
Align(8);
2269 }
else if (Kind.isMergeableConst16()) {
2271 if (Alignment <= 16) {
2273 Alignment =
Align(16);
2275 }
else if (Kind.isMergeableConst32()) {
2276 if (Alignment <= 32) {
2278 Alignment =
Align(32);
2282 if (!COMDATSymName.empty())
2303 "SelectionKind::Any, '" +
C->getName() +
"' cannot be "
2312 if (
K.isThreadLocal())
2315 if (
K.isMergeableCString())
2341 if (Kind.isMetadata())
2365 Name ==
".llvmbc" || Name ==
".llvmcmd")
2370 Group =
C->getName();
2384 unsigned *NextUniqueID,
bool Retain) {
2387 Group =
C->getName();
2394 const auto &OptionalPrefix =
F->getSectionPrefix();
2399 if (EmitUniqueSection && UniqueSectionNames) {
2400 Name.push_back(
'.');
2404 if (EmitUniqueSection && !UniqueSectionNames) {
2410 return Ctx.getWasmSection(Name, Kind, Flags, Group,
UniqueID);
2416 if (Kind.isCommon())
2421 bool EmitUniqueSection =
false;
2423 EmitUniqueSection =
TM.getFunctionSections();
2425 EmitUniqueSection =
TM.getDataSections();
2427 bool Retain = Used.count(GO);
2428 EmitUniqueSection |=
Retain;
2431 EmitUniqueSection, &NextUniqueID,
Retain);
2435 bool UsesLabelDifference,
const Function &
F)
const {
2451 unsigned Priority,
const MCSymbol *KeySym)
const {
2452 return Priority == UINT16_MAX ?
2459 unsigned Priority,
const MCSymbol *KeySym)
const {
2472 if (!
F.hasPersonalityFn() || !
F.needsUnwindTableEntry())
2477 assert(Per &&
"Personality routine is not a GlobalValue type.");
2487 if (!
F.hasStackProtectorFnAttr())
2518 if (GO->isDeclarationForLinker())
2521 ->getQualNameSymbol();
2524 if (GVar->hasAttribute(
"toc-data"))
2527 ->getQualNameSymbol();
2532 ->getQualNameSymbol();
2538 ->getQualNameSymbol();
2539 if ((
TM.getDataSections() && !GO->hasSection()) || GO->hasCommonLinkage() ||
2543 ->getQualNameSymbol();
2559 if (GVar->hasAttribute(
"toc-data"))
2568 else if (Kind.isData() || Kind.isBSS())
2570 else if (Kind.isReadOnlyWithRel())
2573 else if (Kind.isReadOnly())
2586 "Tried to get ER section for a defined global.");
2606 if (GVar->hasAttribute(
"toc-data"))
2619 if (GVar->hasAttribute(
"toc-data")) {
2633 if (Kind.isBSSLocal() || GO->
hasCommonLinkage() || Kind.isThreadBSSLocal()) {
2643 if (Kind.isText()) {
2644 if (
TM.getFunctionSections()) {
2647 ->getRepresentedCsect();
2652 if (
TM.Options.XCOFFReadOnlyPointers && Kind.isReadOnlyWithRel()) {
2653 if (!
TM.getDataSections())
2655 "ReadOnlyPointers is supported only if data sections is turned on");
2668 if (Kind.isData() || Kind.isReadOnlyWithRel() || Kind.isBSS()) {
2669 if (
TM.getDataSections()) {
2679 if (Kind.isReadOnly()) {
2680 if (
TM.getDataSections()) {
2694 if (Kind.isThreadLocal()) {
2695 if (
TM.getDataSections()) {
2709 assert (!
F.getComdat() &&
"Comdat not supported on XCOFF.");
2711 if (!
TM.getFunctionSections())
2724 bool UsesLabelDifference,
const Function &
F)
const {
2734 if (Alignment >
Align(16))
2737 if (Alignment ==
Align(8)) {
2742 if (Alignment ==
Align(16)) {
2771 unsigned Priority,
const MCSymbol *KeySym)
const {
2776 unsigned Priority,
const MCSymbol *KeySym)
const {
2800 "There is no mapping that implements AppendingLinkage for XCOFF.");
2811 "Func must be a function or an alias which has a function as base "
2822 if (((
TM.getFunctionSections() && !Func->hasSection()) ||
2823 Func->isDeclarationForLinker()) &&
2840 "F must be a function or ifunc object.");
2856 if (XSym->getSymbolTableName() ==
"_$TLSML")
2862 if (XSym->isEHInfo())
2866 if (!XSym->hasPerSymbolCodeModel())
2876 static_cast<const MCSymbolXCOFF *
>(Sym)->getSymbolTableName(),
2883 if (
TM.getFunctionSections()) {
2890 LSDA->getCsectProp());
2908 FileName = FileName.
substr(1, FileName.
size() - 2);
2914 RootSD->
setName(DefaultRootSDName);
2915 ADAPR->
setName(DefaultADAPRName);
2932 bool UsesLabelDifference,
const Function &
F)
const {
2949 std::string Name =
"GCC_except." +
F.getName().str();
2970 auto *Symbol =
TM.getSymbol(GO);
2974 if (Kind.isBSS() || Kind.isData() || Kind.isReadOnlyWithRel() ||
2986 Alignment =
F->getAlign();
2988 Alignment = V->getAlign();
2991 GOFF::SDAttr{GOFF::ESD_TA_Unspecified, SDBindingScope});
3000 Kind, Symbol->getName(),
3001 GOFF::PRAttr{false, GOFF::ESD_EXE_DATA, GOFF::ESD_BST_Strong,
3002 GOFF::ESD_LT_XPLink, PRBindingScope, 0},
3020 static constexpr const uint32_t ClangDefaultSinitPriority = 65535;
3021 uint32_t Prio = Priority + (0x80000000 - ClangDefaultSinitPriority);
3023 std::string Name(
".xtor");
3024 if (Priority != ClangDefaultSinitPriority)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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 const Function * getParent(const Value *V)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_LIFETIME_BOUND
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 MCSymbolGOFF class.
This file defines the SmallString class.
This file defines the SmallVector class.
cl::opt< bool > PreserveHotDataSectionPrefix("preserve-hot-data-section-prefix", cl::Hidden, cl::init(true), cl::desc("If true, hot data section prefixes are preserved"))
std::unique_ptr< MCStreamer > && Streamer
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 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 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 void GetObjCImageInfo(const Module &M, unsigned &Version, unsigned &Flags, StringRef &Section)
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 std::tuple< StringRef, bool, unsigned, unsigned, unsigned > getGlobalObjectInfo(const GlobalObject *GO, const TargetMachine &TM, StringRef SectionName, SectionKind Kind)
static unsigned getWasmSectionFlags(SectionKind K, bool Retain)
static void checkMachOComdat(const GlobalValue *GV)
static std::string APIntToHexString(const APInt &AI)
static unsigned getELFSectionFlags(SectionKind K, const Triple &T)
static SmallString< 128 > getELFSectionNameForGlobal(const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool UniqueSectionName, const MachineJumpTableEntry *JTE)
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 std::string scalarConstantToHexString(const Constant *C)
static StringRef getCOFFSectionNameForUniqueGlobal(SectionKind Kind)
static const Comdat * getELFComdat(const GlobalValue *GV)
static MCSectionELF * selectELFSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool EmitUniqueSection, unsigned Flags, unsigned *NextUniqueID, const MCSymbolELF *AssociatedSymbol, const MachineJumpTableEntry *MJTE=nullptr)
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.
A parsed version of the target data layout string in and methods for querying it.
StringRef getInternalSymbolPrefix() const
LLVM_ABI Align getPreferredAlign(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global.
This is the base abstract class for diagnostic reporting in the backend.
Lightweight error class with error context and mandatory checking.
StringRef getSection() const
Get the custom section of this global if it has one.
bool hasMetadata() const
Return true if this GlobalObject has any metadata attached to it.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this GlobalObject.
bool hasSection() const
Check if this global has a custom object file section.
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 hasDefaultVisibility() const
bool hasPrivateLinkage() const
LLVM_ABI const Comdat * getComdat() const
ThreadLocalMode getThreadLocalMode() const
bool isDeclarationForLinker() const
Module * getParent()
Get the module that this global value is contained inside of...
LLVM_ABI const GlobalObject * getAliaseeObject() const
LLVM_ABI 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.
LLVM_ABI 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...
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
LLVM_ABI 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.
LLVM_ABI MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, StringRef COMDATSymName, int Selection, unsigned UniqueID=MCSection::NonUniqueID)
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
LLVM_ABI 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)
LLVM_ABI MCSectionXCOFF * getXCOFFSection(StringRef Section, SectionKind K, std::optional< XCOFF::CsectProperties > CsectProp=std::nullopt, bool MultiSymbolsAllowed=false, std::optional< XCOFF::DwarfSectionSubtypeFlags > DwarfSubtypeFlags=std::nullopt)
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Base class for the full range of assembler expressions which are needed for parsing.
MCSection * TLSBSSSection
Section directive for Thread Local uninitialized data.
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 * 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 * CStringSection
bool isPositionIndependent() const
MCSection * DataCoalSection
MCSection * UStringSection
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 * ConstDataSection
MCContext & getContext() const
MCSection * DataSection
Section directive for standard data.
This represents a section on Windows.
MCSymbol * getCOMDATSymbol() const
This represents a section on linux, lots of unix variants and some bare metal systems.
unsigned getFlags() const
void setName(StringRef SectionName)
void setRequiresNonZeroLength()
MCSectionGOFF * getParent() const
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.
void setAlignment(Align Value)
static constexpr unsigned NonUniqueID
void setBeginSymbol(MCSymbol *Sym)
StringRef getName() const
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Streaming machine code generation interface.
void setWeak(bool Value=true)
void setExternal(bool Value) const
void setCodeData(GOFF::ESDExecutable Value)
void setADA(MCSectionGOFF *AssociatedDataArea)
void setLinkage(GOFF::ESDLinkageType Value)
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
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.
int64_t getConstant() const
const MCSymbol * getSubSym() const
const MDOperand & getOperand(unsigned I) const
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current 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.
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.
LLVM_ABI 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.
const Triple & getTargetTriple() const
Get the target triple which is a string describing the target host.
@ 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.
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...
bool starts_with(StringRef Prefix) const
starts_with - Check if this string starts with the given Prefix.
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.
Represent a constant reference to a string, i.e.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
Check if the string is empty.
constexpr size_t size() const
Get the string size.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
void initialize(MCContext &Ctx, const TargetMachine &TM, const Module &M) override
This method must be called before any actual lowering is done.
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
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, int64_t Addend, std::optional< int64_t > PCRelativeOffset, const TargetMachine &TM) const override
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
MCSection * getNamedSection(StringRef Name, SectionKind Kind) const override
Get a section with the given name and kind, using format-appropriate defaults for section flags.
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment, const Function *F) const override
Given a mergeable constant with the specified size and relocation information, return a section that ...
void emitModuleMetadata(MCStreamer &Streamer, const Module &M) const override
Emit Obj-C garbage collection and linker options.
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
void emitLinkerDirectives(MCStreamer &Streamer, const Module &M) const override
Process linker options metadata and emit platform-specific bits.
MCSection * getUniqueSectionForFunction(const Function &F, const TargetMachine &TM) const override
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
MCSection * getSectionForConstantImpl(const DataLayout &DL, SectionKind Kind, const Constant *C, StringRef SectionSuffix) const
void emitModuleMetadata(MCStreamer &Streamer, const Module &M) const override
Emit Obj-C garbage collection and linker options.
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment, const Function *F) const override
Given a constant with the SectionKind, return a section that it should be placed in.
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym, const MachineModuleInfo *MMI) const override
void emitLinkerDirectives(MCStreamer &Streamer, const Module &M) const override
Process linker options metadata and emit platform-specific bits.
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...
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
uint16_t PLTRelativeSpecifier
const MCExpr * lowerSymbolDifference(const MCSymbol *LHS, const MCSymbol *RHS, int64_t Addend, std::optional< int64_t > PCRelativeOffset) const
MCSection * getNamedSection(StringRef Name, SectionKind Kind) const override
Get a section with the given name and kind, using format-appropriate defaults for section flags.
const MCExpr * lowerDSOLocalEquivalent(const MCSymbol *LHS, const MCSymbol *RHS, int64_t Addend, std::optional< int64_t > PCRelativeOffset, 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
void initialize(MCContext &Ctx, const TargetMachine &TM, const Module &M) override
This method must be called before any actual lowering is done.
virtual void emitPersonalityValueImpl(MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym, const MachineModuleInfo *MMI) const
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
bool isLargeConstant(const DataLayout &DL, SectionKind Kind, const Constant *C) const
Given a mergeable constant with the specified size and relocation information, return a section that ...
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.
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...
void initialize(MCContext &Ctx, const TargetMachine &TM, const Module &M) 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 Function *F) const override
Given a constant with the SectionKind, return a section that it should be placed in.
MCSection * getStaticXtorSection(unsigned Priority) const
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
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment, const Function *F) const override
Given a constant with the SectionKind, return a section that it should be placed in.
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...
void emitModuleMetadata(MCStreamer &Streamer, const Module &M) const override
Emit the module flags that specify the garbage collection information.
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.
MCSection * getSectionForCommandLines() const override
If supported, return the section to use for the llvm.commandline metadata.
void emitLinkerDirectives(MCStreamer &Streamer, const Module &M) const override
Process linker options metadata and emit platform-specific bits.
void initialize(MCContext &Ctx, const TargetMachine &TM, const Module &M) override
This method must be called before any actual lowering is done.
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.
MCSection * getNamedSection(StringRef Name, SectionKind Kind) const override
Get a section with the given name and kind, using format-appropriate defaults for section flags.
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
MCSection * getNamedSection(StringRef Name, SectionKind Kind) const override
Get a section with the given name and kind, using format-appropriate defaults for section flags.
void initialize(MCContext &Ctx, const TargetMachine &TM, const Module &M) override
This method must be called before any actual lowering is done.
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)
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.
void initialize(MCContext &Ctx, const TargetMachine &TM, const Module &M) override
This method must be called before any actual lowering is done.
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
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
static MCSymbol * getEHInfoTableSymbol(const MachineFunction *MF)
MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment, const Function *F) const override
Given a constant with the SectionKind, return a section that it should be placed in.
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)
MCSymbol * getTargetSymbol(const GlobalValue *GV, const TargetMachine &TM) const override
For functions, this will always return a function descriptor symbol.
MCSection * getSectionForFunctionDescriptor(const GlobalObject *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.
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
void emitCGProfileMetadata(MCStreamer &Streamer, const Module &M) const
Emit Call Graph Profile metadata.
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
virtual void initialize(MCContext &ctx, const TargetMachine &TM, const Module &M)
This method must be called before any actual lowering is done.
bool SupportDebugThreadLocalLocation
unsigned getPersonalityEncoding() const
MCSection * StaticCtorSection
This section contains the static constructor pointer list.
virtual MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, Align &Alignment, const Function *F) const
Given a constant with the SectionKind, return a section that it should be placed in.
static StringRef getCustomSectionName(const GlobalObject *GO, const TargetMachine &TM)
Return the section name specified by 'pragma clang section' or the section attribute.
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix, const TargetMachine &TM) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
uint32_t PLTPCRelativeSpecifier
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...
void emitPseudoProbeDescMetadata(MCStreamer &Streamer, const Module &M, std::function< void(MCStreamer &Streamer)> COMDATSymEmitter=nullptr) const
Emit pseudo_probe_desc metadata.
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 getSeparateNamedSections() const
bool getUniqueSectionNames() const
bool getEnableStaticDataPartitioning() const
MCSymbol * getSymbol(const GlobalValue *GV) const
CodeModel::Model getCodeModel() const
Returns the code model.
bool isLargeGlobalValue(const GlobalValue *GV) const
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
unsigned UseInitArray
UseInitArray - Use .init_array instead of .ctors for static constructors.
MCTargetOptions MCOptions
Machine level options.
Triple - Helper class for working with autoconf configuration names.
ArchType getArch() const
Get the parsed architecture type of this triple.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
Twine concat(const Twine &Suffix) const
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
LLVMContext & getContext() const
All values hold a context through their type.
LLVM_ABI 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
@ SHT_LLVM_DEPENDENT_LIBRARIES
@ SHT_LLVM_LINKER_OPTIONS
constexpr StringLiteral CLASS_WSA
constexpr StringLiteral CLASS_SINIT
@ 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)
Calculates the starting offsets for various sections within the .debug_names section.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
LLVM_ABI StringRef stem(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get stem.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
std::string utostr(uint64_t X, bool isNeg=false)
bool isa_and_nonnull(const Y &Val)
LLVM_ABI 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...
auto dyn_cast_or_null(const Y &Val)
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)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
LLVM_ABI void emitLinkerFlagsForUsedCOFF(raw_ostream &OS, const GlobalValue *GV, const Triple &T, Mangler &M)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
DWARFExpression::Operation Op
std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
LLVM_ABI void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV, const Triple &TT, Mangler &Mangler)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI cl::opt< std::string > BBSectionsColdTextPrefix
@ MCSA_Global
.type _foo, @gnu_unique_object
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
@ MCSA_Hidden
.hidden (ELF)
LLVM_ABI 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 ...
This struct is a compact representation of a valid (non-zero power of two) alignment.
LLVM_ABI static const MBBSectionID ExceptionSectionID
LLVM_ABI static const MBBSectionID ColdSectionID
MachineJumpTableEntry - One jump table in the jump table info.
MachineFunctionDataHotness Hotness
The hotness of MJTE is inferred from the hotness of the source basic block(s) that reference it.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.