LLVM: lib/CodeGen/TargetLoweringObjectFileImpl.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
73#include
74#include
75
76using namespace llvm;
77using namespace dwarf;
78
81 cl::desc("Putting Jump Table in function section"));
82
86 M.getModuleFlagsMetadata(ModuleFlags);
87
88 for (const auto &MFE: ModuleFlags) {
89
91 continue;
92
94 if (Key == "Objective-C Image Info Version") {
96 } else if (Key == "Objective-C Garbage Collection" ||
97 Key == "Objective-C GC Only" ||
98 Key == "Objective-C Is Simulated" ||
99 Key == "Objective-C Class Properties" ||
100 Key == "Objective-C Image Swift Version") {
102 } else if (Key == "Objective-C Image Info Section") {
104 }
105
106
107 else if (Key == "Swift ABI Version") {
109 } else if (Key == "Swift Major Version") {
111 } else if (Key == "Swift Minor Version") {
113 }
114 }
115}
116
117
118
119
120
124
127
134 break;
135
136 [[fallthrough]];
152 break;
164 } else {
172 }
173 break;
182 }
183 break;
187
188
189
190
191
198 break;
203 break;
208
209
210
212
213
216
217
218
219
223 }
224 break;
232 break;
241 } else {
245 }
247 break;
258 break;
266 } else {
269 }
270 break;
272
273
280 } else {
284 }
285 break;
293 break;
294 default:
295 break;
296 }
297}
298
304 Used.insert(GO);
305}
306
310
312
313 if (NamedMDNode *DependentLibraries = M.getNamedMetadata("llvm.dependent-libraries")) {
316
318
319 for (const auto *Operand : DependentLibraries->operands()) {
323 }
324 }
325
327
328 if (NamedMDNode *LLVMStats = M.getNamedMetadata("llvm.stats")) {
329
330
331 auto *S = C.getObjectFileInfo()->getLLVMStatsSection();
333 for (const auto *Operand : LLVMStats->operands()) {
335 assert(MD->getNumOperands() % 2 == 0 &&
336 ("Operand num should be even for a list of key/value pair"));
337 for (size_t I = 0; I < MD->getNumOperands(); I += 2) {
338
342
345 ->getZExtValue())
349 }
350 }
351 }
352
354 unsigned Flags = 0;
356
358 if (!Section.empty()) {
365 }
366
368}
369
373 if (NamedMDNode *LinkerOptions = M.getNamedMetadata("llvm.linker.options")) {
376
378
379 for (const auto *Operand : LinkerOptions->operands()) {
380 if (cast(Operand)->getNumOperands() != 2)
382 for (const auto &Option : cast(Operand)->operands()) {
385 }
386 }
387 }
388}
389
396 TM.getSymbol(GV)->getName());
398 return TM.getSymbol(GV);
400}
401
406 NameData += Sym->getName();
407 auto *Label =
414 unsigned Size = DL.getPointerSize();
421
423}
424
430
436
438
439
440
445 }
446
450 }
451
453 MMI, Streamer);
454}
455
457
458
459
460
461
462
463
465 false) ||
467 false) ||
469 false) ||
471 false) ||
472 Name == ".llvmbc" || Name == ".llvmcmd")
474
475 if (!Name.starts_with(".")) return K;
476
477
478 if (Name == ".bss" || Name.starts_with(".bss.") ||
479 Name.starts_with(".gnu.linkonce.b.") ||
480 Name.starts_with(".llvm.linkonce.b.") || Name == ".sbss" ||
481 Name.starts_with(".sbss.") || Name.starts_with(".gnu.linkonce.sb.") ||
482 Name.starts_with(".llvm.linkonce.sb."))
484
485 if (Name == ".tdata" || Name.starts_with(".tdata.") ||
486 Name.starts_with(".gnu.linkonce.td.") ||
487 Name.starts_with(".llvm.linkonce.td."))
489
490 if (Name == ".tbss" || Name.starts_with(".tbss.") ||
491 Name.starts_with(".gnu.linkonce.tb.") ||
492 Name.starts_with(".llvm.linkonce.tb."))
494
495 return K;
496}
497
502
504
505
506
507 if (Name.starts_with(".note"))
509
510 if (hasPrefix(Name, ".init_array"))
512
513 if (hasPrefix(Name, ".fini_array"))
515
516 if (hasPrefix(Name, ".preinit_array"))
518
519 if (hasPrefix(Name, ".llvm.offloading"))
521 if (Name == ".llvm.lto")
523
524 if (K.isBSS() || K.isThreadBSS())
526
528}
529
531 unsigned Flags = 0;
532
533 if (!K.isMetadata() && !K.isExclude())
535
536 if (K.isExclude())
538
539 if (K.isText())
541
542 if (K.isExecuteOnly()) {
543 if (T.isAArch64())
545 else if (T.isARM() || T.isThumb())
547 }
548
549 if (K.isWriteable())
551
552 if (K.isThreadLocal())
554
555 if (K.isMergeableCString() || K.isMergeableConst())
557
558 if (K.isMergeableCString())
560
561 return Flags;
562}
563
566 if ()
567 return nullptr;
568
571 report_fatal_error("ELF COMDATs only support SelectionKind::Any and "
572 "SelectionKind::NoDeduplicate, '" +
573 C->getName() + "' cannot be lowered.");
574
575 return C;
576}
577
581 if (!MD)
582 return nullptr;
583
587 : nullptr;
588}
589
591 if (Kind.isMergeable1ByteCString())
592 return 1;
593 else if (Kind.isMergeable2ByteCString())
594 return 2;
595 else if (Kind.isMergeable4ByteCString())
596 return 4;
597 else if (Kind.isMergeableConst4())
598 return 4;
599 else if (Kind.isMergeableConst8())
600 return 8;
601 else if (Kind.isMergeableConst16())
602 return 16;
603 else if (Kind.isMergeableConst32())
604 return 32;
605 else {
606
607
608 assert(!Kind.isMergeableCString() && "unknown string width");
609 assert(!Kind.isMergeableConst() && "unknown data width");
610 return 0;
611 }
612}
613
614
615
617 if (Kind.isText())
618 return IsLarge ? ".ltext" : ".text";
619 if (Kind.isReadOnly())
620 return IsLarge ? ".lrodata" : ".rodata";
621 if (Kind.isBSS())
622 return IsLarge ? ".lbss" : ".bss";
623 if (Kind.isThreadData())
624 return ".tdata";
625 if (Kind.isThreadBSS())
626 return ".tbss";
627 if (Kind.isData())
628 return IsLarge ? ".ldata" : ".data";
629 if (Kind.isReadOnlyWithRel())
630 return IsLarge ? ".ldata.rel.ro" : ".data.rel.ro";
632}
633
637 unsigned EntrySize, bool UniqueSectionName,
641 if (Kind.isMergeableCString()) {
642
643
644
647
648 Name += ".str";
649 Name += utostr(EntrySize);
650 Name += ".";
652 } else if (Kind.isMergeableConst()) {
653 Name += ".cst";
654 Name += utostr(EntrySize);
655 }
656
657 bool HasPrefix = false;
659
660
661
665 } else {
667 "Hotness must be cold");
669 }
670 HasPrefix = true;
671 } else if (std::optional Prefix = F->getSectionPrefix()) {
673 HasPrefix = true;
674 }
676 if (std::optional Prefix = GV->getSectionPrefix()) {
678 HasPrefix = true;
679 }
680 }
681
682 if (UniqueSectionName) {
683 Name.push_back('.');
684 TM.getNameWithPrefix(Name, GO, Mang, true);
685 } else if (HasPrefix)
686
687
688 Name.push_back('.');
689 return Name;
690}
691
692namespace {
693class LoweringDiagnosticInfo : public DiagnosticInfo {
694 const Twine &Msg;
695
696public:
699 : DiagnosticInfo(DK_Lowering, Severity), Msg(DiagMsg) {}
700 void print(DiagnosticPrinter &DP) const override { DP << Msg; }
701};
702}
703
704
705
706static unsigned
710 unsigned &EntrySize, unsigned &NextUniqueID,
711 const bool Retain, const bool ForceUnique) {
712
713
714
715 if (ForceUnique)
716 return NextUniqueID++;
717
718
719
720 const bool Associated = GO->getMetadata(LLVMContext::MD_associated);
721 if (Associated) {
723 return NextUniqueID++;
724 }
725
729 else if (Ctx.getAsmInfo()->useIntegratedAssembler() ||
730 Ctx.getAsmInfo()->binutilsIsAtLeast(2, 36))
732 return NextUniqueID++;
733 }
734
735
736
737
738
739
740
741 const bool SupportsUnique = Ctx.getAsmInfo()->useIntegratedAssembler() ||
742 Ctx.getAsmInfo()->binutilsIsAtLeast(2, 35);
743 if (!SupportsUnique) {
744 Flags &= ~ELF::SHF_MERGE;
745 EntrySize = 0;
747 }
748
750 const bool SeenSectionNameBefore =
751 Ctx.isELFGenericMergeableSection(SectionName);
752
753
754 if (!SymbolMergeable && !SeenSectionNameBefore) {
756 return NextUniqueID++;
757 else
759 }
760
761
762
763
764 const auto PreviousID =
765 Ctx.getELFUniqueIDForEntsize(SectionName, Flags, EntrySize);
766 if (PreviousID &&
768 return *PreviousID;
769
770
771
772
773
775 GO, Kind, Mang, TM, EntrySize, false, nullptr);
776 if (SymbolMergeable &&
777 Ctx.isELFImplicitMergeableSectionNamePrefix(SectionName) &&
778 SectionName.starts_with(ImplicitSectionNameStem))
780
781
782
783 return NextUniqueID++;
784}
785
786static std::tuple<StringRef, bool, unsigned>
789 bool IsComdat = false;
790 unsigned Flags = 0;
793 Group = C->getName();
794 IsComdat = C->getSelectionKind() == Comdat::Any;
795 }
798 return {Group, IsComdat, Flags};
799}
800
803
804
805
809 if (Attrs.hasAttribute("bss-section") && Kind.isBSS())
810 return Attrs.getAttribute("bss-section").getValueAsString();
811 else if (Attrs.hasAttribute("rodata-section") && Kind.isReadOnly())
812 return Attrs.getAttribute("rodata-section").getValueAsString();
813 else if (Attrs.hasAttribute("relro-section") && Kind.isReadOnlyWithRel())
814 return Attrs.getAttribute("relro-section").getValueAsString();
815 else if (Attrs.hasAttribute("data-section") && Kind.isData())
816 return Attrs.getAttribute("data-section").getValueAsString();
817 }
818
820}
821
826 unsigned &NextUniqueID,
827 bool Retain, bool ForceUnique) {
829
830
832
835 Flags |= ExtraFlags;
836
839 GO, SectionName, Kind, TM, Ctx, Mang, Flags, EntrySize, NextUniqueID,
840 Retain, ForceUnique);
841
845 Group, IsComdat, UniqueID, LinkedToSym);
846
847
848 assert(Section->getLinkedToSymbol() == LinkedToSym &&
849 "Associated symbol mismatch between sections");
850
851 if (!(Ctx.getAsmInfo()->useIntegratedAssembler() ||
852 Ctx.getAsmInfo()->binutilsIsAtLeast(2, 35))) {
853
854
855
859 "Symbol '" + GO->getName() + "' from module '" +
861 "' required a section with entry-size=" +
863 SectionName + "' with entry-size=" + Twine(Section->getEntrySize()) +
864 ": Explicit assignment by pragma or attribute of an incompatible "
865 "symbol to this section?"));
866 }
867
868 return Section;
869}
870
874 NextUniqueID, Used.count(GO),
875 false);
876}
877
880 const TargetMachine &TM, bool EmitUniqueSection, unsigned Flags,
881 unsigned *NextUniqueID, const MCSymbolELF *AssociatedSymbol,
883
885 Flags |= ExtraFlags;
886
887
889
890 bool UniqueSectionName = false;
892 if (EmitUniqueSection) {
894 UniqueSectionName = true;
895 } else {
897 (*NextUniqueID)++;
898 }
899 }
901 GO, Kind, Mang, TM, EntrySize, UniqueSectionName, MJTE);
902
903
904 if (Kind.isExecuteOnly())
906 return Ctx.getELFSection(Name, getELFSectionType(Name, Kind), Flags,
907 EntrySize, Group, IsComdat, UniqueID,
908 AssociatedSymbol);
909}
910
914 unsigned Flags, unsigned *NextUniqueID) {
916 if (LinkedToSym) {
917 EmitUniqueSection = true;
919 }
922 EmitUniqueSection = true;
924 } else if (Ctx.getAsmInfo()->useIntegratedAssembler() ||
925 Ctx.getAsmInfo()->binutilsIsAtLeast(2, 36)) {
926 EmitUniqueSection = true;
928 }
929 }
930
932 Ctx, GO, Kind, Mang, TM, EmitUniqueSection, Flags,
933 NextUniqueID, LinkedToSym);
934 assert(Section->getLinkedToSymbol() == LinkedToSym);
935 return Section;
936}
937
941
942
943
944 bool EmitUniqueSection = false;
946 if (Kind.isText())
947 EmitUniqueSection = TM.getFunctionSections();
948 else
949 EmitUniqueSection = TM.getDataSections();
950 }
951 EmitUniqueSection |= GO->hasComdat();
953 Used.count(GO), EmitUniqueSection, Flags,
954 &NextUniqueID);
955}
956
961
962
963 if (F.hasSection())
966 Used.count(&F), true);
967
970 true, Flags, &NextUniqueID);
971}
972
977
981
982
983 const Comdat *C = F.getComdat();
984 bool EmitUniqueSection = TM.getFunctionSections() || C;
985 if (!EmitUniqueSection && .getEnableStaticDataPartitioning())
987
991 nullptr, JTE);
992}
993
996
997
998 if ( || (
.hasComdat() &&
.getFunctionSections()))
1000
1002 unsigned Flags = LSDA->getFlags();
1003 const MCSymbolELF *LinkedToSym = nullptr;
1005 bool IsComdat = false;
1008 Group = C->getName();
1009 IsComdat = C->getSelectionKind() == Comdat::Any;
1010 }
1011
1012
1013 if (TM.getFunctionSections() &&
1014 (getContext().getAsmInfo()->useIntegratedAssembler() &&
1015 getContext().getAsmInfo()->binutilsIsAtLeast(2, 36))) {
1017 LinkedToSym = static_cast<const MCSymbolELF *>(&FnSym);
1018 }
1019
1020
1021
1023 (TM.getUniqueSectionNames() ? LSDA->getName() + "." + F.getName()
1024 : LSDA->getName()),
1026 LinkedToSym);
1027}
1028
1030 bool UsesLabelDifference, const Function &F) const {
1031
1032
1033 return false;
1034}
1035
1036
1037
1040 Align &Alignment) const {
1049 if (Kind.isReadOnly())
1051
1052 assert(Kind.isReadOnlyWithRel() && "Unknown section kind");
1054}
1055
1058 StringRef SectionSuffix) const {
1059
1060
1061 if (SectionSuffix.empty())
1063
1066 return Context.getELFSection(".rodata.cst4." + SectionSuffix + ".",
1070 return Context.getELFSection(".rodata.cst8." + SectionSuffix + ".",
1074 return Context.getELFSection(".rodata.cst16." + SectionSuffix + ".",
1078 return Context.getELFSection(".rodata.cst32." + SectionSuffix + ".",
1081 if (Kind.isReadOnly())
1082 return Context.getELFSection(".rodata." + SectionSuffix + ".",
1084
1085 assert(Kind.isReadOnlyWithRel() && "Unknown section kind");
1086 return Context.getELFSection(".data.rel.ro." + SectionSuffix + ".",
1089}
1090
1091
1095 assert(MBB.isBeginSection() && "Basic block does not start a section!");
1097
1098
1099
1100
1101
1102
1104 StringRef FunctionSectionName = MBB.getParent()->getSection()->getName();
1105 if (FunctionSectionName == ".text" ||
1106 FunctionSectionName.starts_with(".text.")) {
1107
1108 StringRef FunctionName = MBB.getParent()->getName();
1111 Name += FunctionName;
1113 Name += ".text.eh.";
1114 Name += FunctionName;
1115 } else {
1116 Name += FunctionSectionName;
1117 if (TM.getUniqueBasicBlockSectionNames()) {
1118 if (!Name.ends_with("."))
1119 Name += ".";
1120 Name += MBB.getSymbol()->getName();
1121 } else {
1123 }
1124 }
1125 } else {
1126
1127
1128 Name = FunctionSectionName;
1130 }
1131
1133 std::string GroupName;
1134 if (F.hasComdat()) {
1136 GroupName = F.getComdat()->getName().str();
1137 }
1139 0 , GroupName,
1140 F.hasComdat(), UniqueID, nullptr);
1141}
1142
1144 bool IsCtor, unsigned Priority,
1146 std::string Name;
1147 unsigned Type;
1150
1151 if (KeySym)
1153
1154 if (UseInitArray) {
1155 if (IsCtor) {
1157 Name = ".init_array";
1158 } else {
1160 Name = ".fini_array";
1161 }
1162 if (Priority != 65535) {
1163 Name += '.';
1164 Name += utostr(Priority);
1165 }
1166 } else {
1167
1168
1169 if (IsCtor)
1170 Name = ".ctors";
1171 else
1172 Name = ".dtors";
1173 if (Priority != 65535)
1176 }
1177
1178 return Ctx.getELFSection(Name, Type, Flags, 0, Comdat, true);
1179}
1180
1182 unsigned Priority, const MCSymbol *KeySym) const {
1184 KeySym);
1185}
1186
1188 unsigned Priority, const MCSymbol *KeySym) const {
1190 KeySym);
1191}
1192
1195 std::optional<int64_t> PCRelativeOffset) const {
1198
1199
1202
1203 Addend += *PCRelativeOffset;
1204 if (Addend)
1206 Ctx);
1208 }
1209
1211 return nullptr;
1215 if (Addend)
1216 Res =
1218 return Res;
1219}
1220
1221
1224 std::optional<int64_t> PCRelativeOffset, const TargetMachine &TM) const {
1225 if (RHS)
1227
1228
1229
1232 return nullptr;
1233}
1234
1242
1243void
1245 UseInitArray = UseInitArray_;
1247 if (!UseInitArray) {
1250
1253 return;
1254 }
1255
1260}
1261
1262
1263
1264
1265
1269
1274 StaticCtorSection = Ctx.getMachOSection("__TEXT", "__constructor", 0,
1276 StaticDtorSection = Ctx.getMachOSection("__TEXT", "__destructor", 0,
1278 } else {
1279 StaticCtorSection = Ctx.getMachOSection("__DATA", "__mod_init_func",
1282 StaticDtorSection = Ctx.getMachOSection("__DATA", "__mod_term_func",
1285 }
1286
1292}
1293
1295 unsigned Priority, const MCSymbol *KeySym) const {
1297
1298
1299
1300
1301
1302}
1303
1306
1308
1309 unsigned VersionVal = 0;
1310 unsigned ImageInfoFlags = 0;
1312
1313 GetObjCImageInfo(M, VersionVal, ImageInfoFlags, SectionVal);
1315
1316
1317 if (SectionVal.empty())
1318 return;
1319
1321 unsigned TAA = 0, StubSize = 0;
1322 bool TAAParsed;
1324 SectionVal, Segment, Section, TAA, TAAParsed, StubSize)) {
1325
1327 "': " + toString(std::move(E)) + ".");
1328 }
1329
1330
1335 getOrCreateSymbol(StringRef("L_OBJC_IMAGE_INFO")));
1337 Streamer.emitInt32(ImageInfoFlags);
1339}
1340
1343 if (auto *LinkerOptions = M.getNamedMetadata("llvm.linker.options")) {
1344 for (const auto *Option : LinkerOptions->operands()) {
1346 for (const auto &Piece : cast(Option)->operands())
1349 }
1350 }
1351}
1352
1355 if ()
1356 return;
1357
1359 "' cannot be lowered.");
1360}
1361
1364
1366
1367
1369 unsigned TAA = 0, StubSize = 0;
1370 bool TAAParsed;
1371
1373
1375 SectionName, Segment, Section, TAA, TAAParsed, StubSize)) {
1376
1378 "' has an invalid section specifier '" +
1380 }
1381
1382
1385
1386
1387
1388 if (!TAAParsed)
1390
1391
1392
1393
1395
1397 "' section type or attributes does not match previous"
1398 " section specifier");
1399 }
1400
1401 return S;
1402}
1403
1407
1408
1411
1412 if (Kind.isText())
1414
1415
1416
1418 if (Kind.isReadOnly())
1420 if (Kind.isReadOnlyWithRel())
1423 }
1424
1425
1426 if (Kind.isMergeable1ByteCString() &&
1430
1431
1432
1433
1438
1439
1440
1442 if (Kind.isMergeableConst4())
1444 if (Kind.isMergeableConst8())
1446 if (Kind.isMergeableConst16())
1448 }
1449
1450
1451
1452 if (Kind.isReadOnly())
1454
1455
1456
1457 if (Kind.isReadOnlyWithRel())
1459
1460
1461
1462 if (Kind.isBSSExtern())
1464
1465
1466
1467 if (Kind.isBSSLocal())
1469
1470
1472}
1473
1476 Align &Alignment) const {
1477
1478
1479 if (Kind.isData() || Kind.isReadOnlyWithRel())
1481
1482 if (Kind.isMergeableConst4())
1484 if (Kind.isMergeableConst8())
1486 if (Kind.isMergeableConst16())
1489}
1490
1495
1499
1500
1504
1506
1507
1508
1513 }
1514
1518 }
1519
1521 MMI, Streamer);
1522}
1523
1527
1530
1532
1533
1534
1539 }
1540
1541 return SSym;
1542}
1543
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1587
1588
1589
1592
1593
1594
1596 StringRef Suffix = "$non_lazy_ptr";
1599 Name += Suffix;
1600 MCSymbol *Stub = Ctx.getOrCreateSymbol(Name);
1601
1603
1607
1610
1613
1617}
1618
1622 return true;
1623
1624
1625
1626
1627
1628 return false;
1629}
1630
1634 bool CannotUsePrivateLabel = true;
1638 CannotUsePrivateLabel =
1640 }
1642}
1643
1644
1645
1646
1647
1648static unsigned
1650 unsigned Flags = 0;
1652
1653 if (K.isMetadata())
1654 Flags |=
1656 else if (K.isExclude())
1657 Flags |=
1659 else if (K.isText())
1660 Flags |=
1665 else if (K.isBSS())
1666 Flags |=
1670 else if (K.isThreadLocal())
1671 Flags |=
1675 else if (K.isReadOnly() || K.isReadOnlyWithRel())
1676 Flags |=
1679 else if (K.isWriteable())
1680 Flags |=
1684
1685 return Flags;
1686}
1687
1690 assert(C && "expected GV to have a Comdat!");
1691
1692 StringRef ComdatGVName = C->getName();
1694 if (!ComdatGV)
1696 "' does not exist.");
1697
1700 "' is not a key for its COMDAT.");
1701
1702 return ComdatGV;
1703}
1704
1710 if (ComdatKey == GV) {
1711 switch (C->getSelectionKind()) {
1722 }
1723 } else {
1725 }
1726 }
1727 return 0;
1728}
1729
1734 false) ||
1736 false) ||
1738 false) ||
1740 false) ||
1741 Name == ".llvmbc" || Name == ".llvmcmd")
1751 else
1752 ComdatGV = GO;
1753
1755 MCSymbol *Sym = TM.getSymbol(ComdatGV);
1756 COMDATSymName = Sym->getName();
1758 } else {
1760 }
1761 }
1762
1765}
1766
1768 if (Kind.isText())
1769 return ".text";
1770 if (Kind.isBSS())
1771 return ".bss";
1772 if (Kind.isThreadLocal())
1773 return ".tls$";
1774 if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1775 return ".rdata";
1776 return ".data";
1777}
1778
1781
1782
1783 bool EmitUniquedSection;
1784 if (Kind.isText())
1785 EmitUniquedSection = TM.getFunctionSections();
1786 else
1787 EmitUniquedSection = TM.getDataSections();
1788
1789 if ((EmitUniquedSection && !Kind.isCommon()) || GO->hasComdat()) {
1791
1793
1801 else
1802 ComdatGV = GO;
1803
1805 if (EmitUniquedSection)
1807
1809 MCSymbol *Sym = TM.getSymbol(ComdatGV);
1811
1813 if (std::optional Prefix = F->getSectionPrefix())
1815
1816
1817
1818
1819 if (getContext().getTargetTriple().isOSCygMing())
1821
1824 } else {
1829 }
1830 }
1831
1832 if (Kind.isText())
1834
1835 if (Kind.isThreadLocal())
1837
1838 if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1840
1841
1842
1843
1844 if (Kind.isBSS() || Kind.isCommon())
1846
1848}
1849
1853 bool CannotUsePrivateLabel = false;
1855 ((isa(GV) && TM.getFunctionSections()) ||
1857 CannotUsePrivateLabel = true;
1858
1860}
1861
1864
1865
1866 const Comdat *C = F.getComdat();
1867 bool EmitUniqueSection = TM.getFunctionSections() || C;
1868 if (!EmitUniqueSection)
1870
1871
1872 if (F.hasPrivateLinkage())
1874
1875 MCSymbol *Sym = TM.getSymbol(&F);
1877
1882 unsigned UniqueID = NextUniqueID++;
1883
1887}
1888
1890 bool UsesLabelDifference, const Function &F) const {
1891 if (TM->getTargetTriple().getArch() == Triple::x86_64) {
1893
1894
1895 return false;
1896 }
1897 }
1899 UsesLabelDifference, F);
1900}
1901
1905
1907 unsigned Flags = 0;
1909
1911 if (!Section.empty()) {
1920 }
1921
1927 if (Sym->isUndefined())
1929 });
1930}
1931
1934 if (NamedMDNode *LinkerOptions = M.getNamedMetadata("llvm.linker.options")) {
1935
1936
1937
1940 for (const auto *Option : LinkerOptions->operands()) {
1941 for (const auto &Piece : cast(Option)->operands()) {
1942
1946 }
1947 }
1948 }
1949
1950
1951 std::string Flags;
1952 for (const GlobalValue &GV : M.global_values()) {
1957 if (!Flags.empty()) {
1960 }
1961 Flags.clear();
1962 }
1963
1964
1965 if (const auto *LU = M.getNamedGlobal("llvm.used")) {
1966 assert(LU->hasInitializer() && "expected llvm.used to have an initializer");
1968 "expected llvm.used to be an array type");
1970 for (const Value *Op : A->operands()) {
1972
1973
1974
1975 if (GV->hasLocalLinkage())
1976 continue;
1977
1982
1983 if (!Flags.empty()) {
1986 }
1987 Flags.clear();
1988 }
1989 }
1990 }
1991}
1992
1996 this->TM = &TM;
1997 const Triple &T = TM.getTargetTriple();
1998 if (T.isWindowsMSVCEnvironment() || T.isWindowsItaniumEnvironment()) {
2005 } else {
2012 }
2013}
2014
2016 const Triple &T, bool IsCtor,
2017 unsigned Priority,
2020 if (T.isWindowsMSVCEnvironment() || T.isWindowsItaniumEnvironment()) {
2021
2022 if (Priority == 65535)
2023 return Ctx.getAssociativeCOFFSection(Default, KeySym, 0);
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2036 char LastLetter = 'T';
2037 bool AddPrioritySuffix = Priority != 200 && Priority != 400;
2038 if (Priority < 200)
2039 LastLetter = 'A';
2040 else if (Priority < 400)
2041 LastLetter = 'C';
2042 else if (Priority == 400)
2043 LastLetter = 'L';
2045 OS << ".CRT$X" << (IsCtor ? "C" : "T") << LastLetter;
2046 if (AddPrioritySuffix)
2047 OS << format("%05u", Priority);
2050 return Ctx.getAssociativeCOFFSection(Sec, KeySym, 0);
2051 }
2052
2053 std::string Name = IsCtor ? ".ctors" : ".dtors";
2054 if (Priority != 65535)
2056
2057 return Ctx.getAssociativeCOFFSection(
2061 KeySym, 0);
2062}
2063
2065 unsigned Priority, const MCSymbol *KeySym) const {
2069}
2070
2072 unsigned Priority, const MCSymbol *KeySym) const {
2076}
2077
2080 std::optional<int64_t> PCRelativeOffset, const TargetMachine &TM) const {
2081 const Triple &T = TM.getTargetTriple();
2082 if (T.isOSCygMing())
2083 return nullptr;
2084
2085
2086
2087 if (LHS->getType()->getPointerAddressSpace() != 0 ||
2088 RHS->getType()->getPointerAddressSpace() != 0)
2089 return nullptr;
2090
2091
2092
2093
2094
2095
2096
2097
2099 LHS->isThreadLocal() || RHS->isThreadLocal() ||
2100 RHS->getName() != "__ImageBase" || !RHS->hasExternalLinkage() ||
2102 return nullptr;
2103
2106 if (Addend != 0)
2109 return Res;
2110}
2111
2113 unsigned Width = (AI.getBitWidth() / 8) * 2;
2114 std::string HexString = toString(AI, 16, false);
2116 unsigned Size = HexString.size();
2117 assert(Width >= Size && "hex string is too large!");
2118 HexString.insert(HexString.begin(), Width - Size, '0');
2119
2120 return HexString;
2121}
2122
2128 return APIntToHexString(CFP->getValueAPF().bitcastToAPInt());
2131 } else {
2132 unsigned NumElements;
2135 else
2136 NumElements = Ty->getArrayNumElements();
2137 std::string HexString;
2138 for (int I = NumElements - 1, E = -1; I != E; --I)
2140 return HexString;
2141 }
2142}
2143
2146 Align &Alignment) const {
2147 if (Kind.isMergeableConst() && C &&
2148 getContext().getAsmInfo()->hasCOFFComdatConstants()) {
2149
2150
2151
2152
2156 std::string COMDATSymName;
2157 if (Kind.isMergeableConst4()) {
2158 if (Alignment <= 4) {
2160 Alignment = Align(4);
2161 }
2162 } else if (Kind.isMergeableConst8()) {
2163 if (Alignment <= 8) {
2165 Alignment = Align(8);
2166 }
2167 } else if (Kind.isMergeableConst16()) {
2168
2169 if (Alignment <= 16) {
2171 Alignment = Align(16);
2172 }
2173 } else if (Kind.isMergeableConst32()) {
2174 if (Alignment <= 32) {
2176 Alignment = Align(32);
2177 }
2178 }
2179
2180 if (!COMDATSymName.empty())
2182 COMDATSymName,
2184 }
2185
2187 Alignment);
2188}
2189
2190
2191
2192
2193
2196 if ()
2197 return nullptr;
2198
2201 "SelectionKind::Any, '" + C->getName() + "' cannot be "
2202 "lowered.");
2203
2204 return C;
2205}
2206
2208 unsigned Flags = 0;
2209
2210 if (K.isThreadLocal())
2212
2213 if (K.isMergeableCString())
2215
2218
2219
2220
2221 return Flags;
2222}
2223
2229 Used.insert(GO);
2230}
2231
2234
2235
2238 }
2239
2241
2242
2243
2244
2245
2246
2248 false) ||
2250 false) ||
2251 Name == ".llvmbc" || Name == ".llvmcmd")
2253
2256 Group = C->getName();
2257 }
2258
2262
2263 return Section;
2264}
2265
2269 const TargetMachine &TM, bool EmitUniqueSection,
2270 unsigned *NextUniqueID, bool Retain) {
2273 Group = C->getName();
2274 }
2275
2278
2280 const auto &OptionalPrefix = F->getSectionPrefix();
2281 if (OptionalPrefix)
2283 }
2284
2285 if (EmitUniqueSection && UniqueSectionNames) {
2286 Name.push_back('.');
2288 }
2290 if (EmitUniqueSection && !UniqueSectionNames) {
2292 (*NextUniqueID)++;
2293 }
2294
2296 return Ctx.getWasmSection(Name, Kind, Flags, Group, UniqueID);
2297}
2298
2301
2302 if (Kind.isCommon())
2304
2305
2306
2307 bool EmitUniqueSection = false;
2308 if (Kind.isText())
2309 EmitUniqueSection = TM.getFunctionSections();
2310 else
2311 EmitUniqueSection = TM.getDataSections();
2312 EmitUniqueSection |= GO->hasComdat();
2313 bool Retain = Used.count(GO);
2314 EmitUniqueSection |= Retain;
2315
2317 EmitUniqueSection, &NextUniqueID, Retain);
2318}
2319
2321 bool UsesLabelDifference, const Function &F) const {
2322
2323
2324 return false;
2325}
2326
2335
2337 unsigned Priority, const MCSymbol *KeySym) const {
2338 return Priority == UINT16_MAX ?
2342}
2343
2345 unsigned Priority, const MCSymbol *KeySym) const {
2346 report_fatal_error("@llvm.global_dtors should have been lowered already");
2347}
2348
2349
2350
2351
2355 return true;
2356
2358 if (.hasPersonalityFn() ||
.needsUnwindTableEntry())
2359 return false;
2360
2363 assert(Per && "Personality routine is not a GlobalValue type.");
2365 return false;
2366
2367 return true;
2368}
2369
2373 if (.hasStackProtectorFnAttr())
2374 return false;
2375
2376
2377
2378 return true;
2379}
2380
2383 auto *EHInfoSym =
2387 return EHInfoSym;
2388}
2389
2393
2394
2395
2396
2397
2398
2399
2400
2402 if (GO->isDeclarationForLinker())
2405 ->getQualNameSymbol();
2406
2408 if (GVar->hasAttribute("toc-data"))
2411 ->getQualNameSymbol();
2412
2414 if (GOKind.isText())
2417 ->getQualNameSymbol();
2418 if ((TM.getDataSections() && !GO->hasSection()) || GO->hasCommonLinkage() ||
2422 ->getQualNameSymbol();
2423 }
2424
2425
2426 return nullptr;
2427}
2428
2433
2435
2436
2438 if (GVar->hasAttribute("toc-data"))
2442 true);
2443
2445 if (Kind.isText())
2447 else if (Kind.isData() || Kind.isBSS())
2449 else if (Kind.isReadOnlyWithRel())
2450 MappingClass =
2452 else if (Kind.isReadOnly())
2454 else
2455 report_fatal_error("XCOFF other section types not yet implemented.");
2456
2459 true);
2460}
2461
2465 "Tried to get ER section for a defined global.");
2466
2469
2470
2471
2477 }
2478
2483
2485 if (GVar->hasAttribute("toc-data"))
2487
2488
2492}
2493
2496
2498 if (GVar->hasAttribute("toc-data")) {
2505 true);
2506 }
2507
2508
2509
2510
2511
2512 if (Kind.isBSSLocal() || GO->hasCommonLinkage() || Kind.isThreadBSSLocal()) {
2520 }
2521
2522 if (Kind.isText()) {
2523 if (TM.getFunctionSections()) {
2526 ->getRepresentedCsect();
2527 }
2529 }
2530
2531 if (TM.Options.XCOFFReadOnlyPointers && Kind.isReadOnlyWithRel()) {
2532 if (.getDataSections())
2534 "ReadOnlyPointers is supported only if data sections is turned on");
2535
2541 }
2542
2543
2544
2545
2546
2547 if (Kind.isData() || Kind.isReadOnlyWithRel() || Kind.isBSS()) {
2548 if (TM.getDataSections()) {
2554 }
2556 }
2557
2558 if (Kind.isReadOnly()) {
2559 if (TM.getDataSections()) {
2565 }
2567 }
2568
2569
2570
2571
2572
2573 if (Kind.isThreadLocal()) {
2574 if (TM.getDataSections()) {
2579 }
2581 }
2582
2583 report_fatal_error("XCOFF other section types not yet implemented.");
2584}
2585
2588 assert (.getComdat() && "Comdat not supported on XCOFF.");
2589
2590 if (.getFunctionSections())
2592
2593
2594
2600}
2601
2603 bool UsesLabelDifference, const Function &F) const {
2604 return false;
2605}
2606
2607
2608
2611 Align &Alignment) const {
2612
2613 if (Alignment > Align(16))
2614 report_fatal_error("Alignments greater than 16 not yet supported.");
2615
2616 if (Alignment == Align(8)) {
2619 }
2620
2621 if (Alignment == Align(16)) {
2624 }
2625
2627}
2628
2639
2640
2641
2642
2643
2644
2646}
2647
2649 unsigned Priority, const MCSymbol *KeySym) const {
2651}
2652
2654 unsigned Priority, const MCSymbol *KeySym) const {
2656}
2657
2661
2678 "There is no mapping that implements AppendingLinkage for XCOFF.");
2679 }
2681}
2682
2689 "Func must be a function or an alias which has a function as base "
2690 "object.");
2691
2695
2696
2697
2698
2699
2700 if (((TM.getFunctionSections() && !Func->hasSection()) ||
2701 Func->isDeclarationForLinker()) &&
2710 }
2711
2713}
2714
2723
2728 auto *XSym = static_cast<const MCSymbolXCOFF *>(Sym);
2729
2730
2731
2732 if (XSym->getSymbolTableName() == "_$TLSML")
2734
2735
2736
2737
2738 if (XSym->isEHInfo())
2740
2741
2742 if (!XSym->hasPerSymbolCodeModel())
2745
2749 }(Sym, TM);
2750
2752 static_cast<const MCSymbolXCOFF *>(Sym)->getSymbolTableName(),
2754}
2755
2759 if (TM.getFunctionSections()) {
2760
2761
2762
2766 LSDA->getCsectProp());
2767 }
2768 return LSDA;
2769}
2770
2771
2772
2774
2776
2780 FileName = FileName.substr(1, FileName.size() - 2);
2781 DefaultRootSDName = Twine(FileName).concat("#C").str();
2782 DefaultADAPRName = Twine(FileName).concat("#S").str();
2786 RootSD->setName(DefaultRootSDName);
2787 ADAPR->setName(DefaultADAPRName);
2788
2794 TextLD->setADA(ADAPR);
2796}
2797
2802
2805 std::string Name = ".gcc_exception_table." + F.getName().str();
2806
2818 WSA);
2819}
2820
2823 auto *Symbol = TM.getSymbol(GO);
2824
2825 if (Kind.isBSS() || Kind.isData()) {
2836 Alignment = F->getAlign();
2838 Alignment = V->getAlign();
2844 GOFF::SDAttr{GOFF::ESD_TA_Unspecified, SDBindingScope});
2850 SD);
2851 return getContext().getGOFFSection(Kind, Symbol->getName(),
2853 GOFF::ESD_LT_XPLink,
2854 PRBindingScope, 0},
2855 ED);
2856 }
2858}
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< 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.
static bool canUsePrivateLabel(const MCAsmInfo &AsmInfo, const MCSection &Section)
Definition TargetLoweringObjectFileImpl.cpp:1619
static MCSection * selectExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM, MCContext &Ctx, Mangler &Mang, unsigned &NextUniqueID, bool Retain, bool ForceUnique)
Definition TargetLoweringObjectFileImpl.cpp:822
static int getSelectionForCOFF(const GlobalValue *GV)
Definition TargetLoweringObjectFileImpl.cpp:1705
static MCSectionCOFF * getCOFFStaticStructorSection(MCContext &Ctx, const Triple &T, bool IsCtor, unsigned Priority, const MCSymbol *KeySym, MCSectionCOFF *Default)
Definition TargetLoweringObjectFileImpl.cpp:2015
static unsigned getEntrySizeForKind(SectionKind Kind)
Definition TargetLoweringObjectFileImpl.cpp:590
static void GetObjCImageInfo(Module &M, unsigned &Version, unsigned &Flags, StringRef &Section)
Definition TargetLoweringObjectFileImpl.cpp:83
static const GlobalValue * getComdatGVForCOFF(const GlobalValue *GV)
Definition TargetLoweringObjectFileImpl.cpp:1688
static unsigned getCOFFSectionFlags(SectionKind K, const TargetMachine &TM)
Definition TargetLoweringObjectFileImpl.cpp:1649
static StringRef handlePragmaClangSection(const GlobalObject *GO, SectionKind Kind)
Definition TargetLoweringObjectFileImpl.cpp:801
static unsigned getELFSectionType(StringRef Name, SectionKind K)
Definition TargetLoweringObjectFileImpl.cpp:503
static bool hasPrefix(StringRef SectionName, StringRef Prefix)
Definition TargetLoweringObjectFileImpl.cpp:498
static MCSectionWasm * selectWasmSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool EmitUniqueSection, unsigned *NextUniqueID, bool Retain)
Definition TargetLoweringObjectFileImpl.cpp:2267
static const MCSymbolELF * getLinkedToSymbol(const GlobalObject *GO, const TargetMachine &TM)
Definition TargetLoweringObjectFileImpl.cpp:578
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 ...
Definition TargetLoweringObjectFileImpl.cpp:707
static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K)
Definition TargetLoweringObjectFileImpl.cpp:456
static const Comdat * getWasmComdat(const GlobalValue *GV)
Definition TargetLoweringObjectFileImpl.cpp:2194
static MCSectionELF * getStaticStructorSection(MCContext &Ctx, bool UseInitArray, bool IsCtor, unsigned Priority, const MCSymbol *KeySym)
Definition TargetLoweringObjectFileImpl.cpp:1143
static SmallString< 128 > getELFSectionNameForGlobal(const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, unsigned EntrySize, bool UniqueSectionName, const MachineJumpTableEntry *JTE)
Definition TargetLoweringObjectFileImpl.cpp:635
static unsigned getWasmSectionFlags(SectionKind K, bool Retain)
Definition TargetLoweringObjectFileImpl.cpp:2207
static void checkMachOComdat(const GlobalValue *GV)
Definition TargetLoweringObjectFileImpl.cpp:1353
static std::string APIntToHexString(const APInt &AI)
Definition TargetLoweringObjectFileImpl.cpp:2112
static unsigned getELFSectionFlags(SectionKind K, const Triple &T)
Definition TargetLoweringObjectFileImpl.cpp:530
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.
Definition TargetLoweringObjectFileImpl.cpp:616
static std::string scalarConstantToHexString(const Constant *C)
Definition TargetLoweringObjectFileImpl.cpp:2123
static StringRef getCOFFSectionNameForUniqueGlobal(SectionKind Kind)
Definition TargetLoweringObjectFileImpl.cpp:1767
static const Comdat * getELFComdat(const GlobalValue *GV)
Definition TargetLoweringObjectFileImpl.cpp:564
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)
Definition TargetLoweringObjectFileImpl.cpp:878
static std::tuple< StringRef, bool, unsigned > getGlobalObjectInfo(const GlobalObject *GO, const TargetMachine &TM)
Definition TargetLoweringObjectFileImpl.cpp:787
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.
LLVM_ABI 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.
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 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.
AttributeSet getAttributes() const
Return the attribute set for this global.
bool hasImplicitSection() const
Check if section name is present.
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 * 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 * 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)
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.
static constexpr unsigned NonUniqueID
StringRef getName() const
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
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 Fill=0, uint8_t FillLen=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.
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
void emitInt32(uint64_t Value)
MCSection * getCurrentSectionOnly() const
void emitInt8(uint64_t Value)
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
void setADA(MCSectionGOFF *AssociatedDataArea)
void setLDAttributes(GOFF::LDAttr Attr)
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.
@ 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...
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 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
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
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...
Definition TargetLoweringObjectFileImpl.cpp:1730
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 ...
Definition TargetLoweringObjectFileImpl.cpp:2144
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Definition TargetLoweringObjectFileImpl.cpp:1993
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit Obj-C garbage collection and linker options.
Definition TargetLoweringObjectFileImpl.cpp:1902
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:1779
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition TargetLoweringObjectFileImpl.cpp:2064
void emitLinkerDirectives(MCStreamer &Streamer, Module &M) const override
Process linker options metadata and emit platform-specific bits.
Definition TargetLoweringObjectFileImpl.cpp:1932
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, int64_t Addend, std::optional< int64_t > PCRelativeOffset, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:2078
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
Definition TargetLoweringObjectFileImpl.cpp:1889
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:1850
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition TargetLoweringObjectFileImpl.cpp:2071
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:1862
MCSection * getUniqueSectionForFunction(const Function &F, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:957
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Definition TargetLoweringObjectFileImpl.cpp:121
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.
Definition TargetLoweringObjectFileImpl.cpp:1038
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition TargetLoweringObjectFileImpl.cpp:1181
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:973
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit Obj-C garbage collection and linker options.
Definition TargetLoweringObjectFileImpl.cpp:307
void emitLinkerDirectives(MCStreamer &Streamer, Module &M) const override
Process linker options metadata and emit platform-specific bits.
Definition TargetLoweringObjectFileImpl.cpp:370
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
Definition TargetLoweringObjectFileImpl.cpp:390
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition TargetLoweringObjectFileImpl.cpp:1187
void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym, const MachineModuleInfo *MMI) const override
Definition TargetLoweringObjectFileImpl.cpp:402
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...
Definition TargetLoweringObjectFileImpl.cpp:431
void getModuleMetadata(Module &M) override
Get the module-level metadata that the platform cares about.
Definition TargetLoweringObjectFileImpl.cpp:299
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:938
uint16_t PLTRelativeSpecifier
const MCExpr * lowerSymbolDifference(const MCSymbol *LHS, const MCSymbol *RHS, int64_t Addend, std::optional< int64_t > PCRelativeOffset) const
Definition TargetLoweringObjectFileImpl.cpp:1193
const MCExpr * lowerDSOLocalEquivalent(const MCSymbol *LHS, const MCSymbol *RHS, int64_t Addend, std::optional< int64_t > PCRelativeOffset, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:1222
MCSection * getSectionForCommandLines() const override
If supported, return the section to use for the llvm.commandline metadata.
Definition TargetLoweringObjectFileImpl.cpp:1235
MCSection * getSectionForLSDA(const Function &F, const MCSymbol &FnSym, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:994
virtual void emitPersonalityValueImpl(MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym, const MachineModuleInfo *MMI) const
Definition TargetLoweringObjectFileImpl.cpp:425
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
Definition TargetLoweringObjectFileImpl.cpp:1029
void InitializeELF(bool UseInitArray_)
Definition TargetLoweringObjectFileImpl.cpp:1244
MCSection * getSectionForMachineBasicBlock(const Function &F, const MachineBasicBlock &MBB, const TargetMachine &TM) const override
Returns a unique section for the given machine basic block.
Definition TargetLoweringObjectFileImpl.cpp:1092
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...
Definition TargetLoweringObjectFileImpl.cpp:871
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...
Definition TargetLoweringObjectFileImpl.cpp:2798
MCSection * getSectionForLSDA(const Function &F, const MCSymbol &FnSym, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:2803
TargetLoweringObjectFileGOFF()
void getModuleMetadata(Module &M) override
Get the module-level metadata that the platform cares about.
Definition TargetLoweringObjectFileImpl.cpp:2775
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:2821
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.
Definition TargetLoweringObjectFileImpl.cpp:1474
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:1631
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
Definition TargetLoweringObjectFileImpl.cpp:1524
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:1404
void emitLinkerDirectives(MCStreamer &Streamer, Module &M) const override
Process linker options metadata and emit platform-specific bits.
Definition TargetLoweringObjectFileImpl.cpp:1341
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...
Definition TargetLoweringObjectFileImpl.cpp:1362
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.
Definition TargetLoweringObjectFileImpl.cpp:1544
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit the module flags that specify the garbage collection information.
Definition TargetLoweringObjectFileImpl.cpp:1304
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Definition TargetLoweringObjectFileImpl.cpp:1270
MCSection * getSectionForCommandLines() const override
If supported, return the section to use for the llvm.commandline metadata.
Definition TargetLoweringObjectFileImpl.cpp:1491
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition TargetLoweringObjectFileImpl.cpp:1294
TargetLoweringObjectFileMachO()
Definition TargetLoweringObjectFileImpl.cpp:1266
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.
Definition TargetLoweringObjectFileImpl.cpp:1496
void getModuleMetadata(Module &M) override
Get the module-level metadata that the platform cares about.
Definition TargetLoweringObjectFileImpl.cpp:2224
void InitializeWasm()
Definition TargetLoweringObjectFileImpl.cpp:2327
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition TargetLoweringObjectFileImpl.cpp:2336
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
Definition TargetLoweringObjectFileImpl.cpp:2320
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition TargetLoweringObjectFileImpl.cpp:2344
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...
Definition TargetLoweringObjectFileImpl.cpp:2232
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:2299
static bool ShouldSetSSPCanaryBitInTB(const MachineFunction *MF)
Definition TargetLoweringObjectFileImpl.cpp:2370
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Definition TargetLoweringObjectFileImpl.cpp:2629
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.
Definition TargetLoweringObjectFileImpl.cpp:2724
MCSection * getSectionForExternalReference(const GlobalObject *GO, const TargetMachine &TM) const override
For external functions, this will always return a function descriptor csect.
Definition TargetLoweringObjectFileImpl.cpp:2462
MCSymbol * getFunctionEntryPointSymbol(const GlobalValue *Func, const TargetMachine &TM) const override
If supported, return the function entry point symbol.
Definition TargetLoweringObjectFileImpl.cpp:2683
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
Definition TargetLoweringObjectFileImpl.cpp:2602
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:2586
static MCSymbol * getEHInfoTableSymbol(const MachineFunction *MF)
Definition TargetLoweringObjectFileImpl.cpp:2382
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...
Definition TargetLoweringObjectFileImpl.cpp:2429
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition TargetLoweringObjectFileImpl.cpp:2648
static XCOFF::StorageClass getStorageClassForGlobal(const GlobalValue *GV)
Definition TargetLoweringObjectFileImpl.cpp:2659
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.
Definition TargetLoweringObjectFileImpl.cpp:2609
MCSymbol * getTargetSymbol(const GlobalValue *GV, const TargetMachine &TM) const override
For functions, this will always return a function descriptor symbol.
Definition TargetLoweringObjectFileImpl.cpp:2391
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...
Definition TargetLoweringObjectFileImpl.cpp:2715
static bool ShouldEmitEHBlock(const MachineFunction *MF)
Definition TargetLoweringObjectFileImpl.cpp:2352
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition TargetLoweringObjectFileImpl.cpp:2494
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition TargetLoweringObjectFileImpl.cpp:2653
MCSection * getSectionForLSDA(const Function &F, const MCSymbol &FnSym, const TargetMachine &TM) const override
For functions, this will return the LSDA section.
Definition TargetLoweringObjectFileImpl.cpp:2756
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
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.
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...
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...
unsigned CallSiteEncoding
void emitPseudoProbeDescMetadata(MCStreamer &Streamer, Module &M, std::function< void(MCStreamer &Streamer)> COMDATSymEmitter=nullptr) const
Emit pseudo_probe_desc metadata.
const MCExpr * getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, MCStreamer &Streamer) const
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
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.
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.
LLVM_ABI 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
@ C
The default llvm calling convention, compatible with C.
@ SHT_LLVM_DEPENDENT_LIBRARIES
@ SHT_LLVM_LINKER_OPTIONS
constexpr StringLiteral CLASS_WSA
@ 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 - 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...
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)
FunctionAddr VTableAddr uintptr_t uintptr_t Version
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 - 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 - Return the argument parameter cast to the specified type.
unsigned Log2(Align A)
Returns the log2 of the alignment.
cl::opt< std::string > BBSectionsColdTextPrefix
@ 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.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
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.