LLVM  13.0.0git
TargetLoweringObjectFileImpl.cpp
Go to the documentation of this file.
1 //===- llvm/CodeGen/TargetLoweringObjectFileImpl.cpp - Object File Info ---===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements classes used to handle lowerings specific to common
10 // object file formats.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/SmallString.h"
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/ADT/StringExtras.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/BinaryFormat/COFF.h"
22 #include "llvm/BinaryFormat/ELF.h"
29 #include "llvm/IR/Comdat.h"
30 #include "llvm/IR/Constants.h"
31 #include "llvm/IR/DataLayout.h"
32 #include "llvm/IR/DerivedTypes.h"
33 #include "llvm/IR/DiagnosticInfo.h"
35 #include "llvm/IR/Function.h"
36 #include "llvm/IR/GlobalAlias.h"
37 #include "llvm/IR/GlobalObject.h"
38 #include "llvm/IR/GlobalValue.h"
39 #include "llvm/IR/GlobalVariable.h"
40 #include "llvm/IR/Mangler.h"
41 #include "llvm/IR/Metadata.h"
42 #include "llvm/IR/Module.h"
43 #include "llvm/IR/PseudoProbe.h"
44 #include "llvm/IR/Type.h"
45 #include "llvm/MC/MCAsmInfo.h"
46 #include "llvm/MC/MCContext.h"
47 #include "llvm/MC/MCExpr.h"
48 #include "llvm/MC/MCSectionCOFF.h"
49 #include "llvm/MC/MCSectionELF.h"
50 #include "llvm/MC/MCSectionMachO.h"
51 #include "llvm/MC/MCSectionWasm.h"
52 #include "llvm/MC/MCSectionXCOFF.h"
53 #include "llvm/MC/MCStreamer.h"
54 #include "llvm/MC/MCSymbol.h"
55 #include "llvm/MC/MCSymbolELF.h"
56 #include "llvm/MC/MCValue.h"
57 #include "llvm/MC/SectionKind.h"
59 #include "llvm/Support/Casting.h"
60 #include "llvm/Support/CodeGen.h"
62 #include "llvm/Support/Format.h"
65 #include <cassert>
66 #include <string>
67 
68 using namespace llvm;
69 using namespace dwarf;
70 
71 static void GetObjCImageInfo(Module &M, unsigned &Version, unsigned &Flags,
72  StringRef &Section) {
74  M.getModuleFlagsMetadata(ModuleFlags);
75 
76  for (const auto &MFE: ModuleFlags) {
77  // Ignore flags with 'Require' behaviour.
78  if (MFE.Behavior == Module::Require)
79  continue;
80 
81  StringRef Key = MFE.Key->getString();
82  if (Key == "Objective-C Image Info Version") {
83  Version = mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue();
84  } else if (Key == "Objective-C Garbage Collection" ||
85  Key == "Objective-C GC Only" ||
86  Key == "Objective-C Is Simulated" ||
87  Key == "Objective-C Class Properties" ||
88  Key == "Objective-C Image Swift Version") {
89  Flags |= mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue();
90  } else if (Key == "Objective-C Image Info Section") {
91  Section = cast<MDString>(MFE.Val)->getString();
92  }
93  // Backend generates L_OBJC_IMAGE_INFO from Swift ABI version + major + minor +
94  // "Objective-C Garbage Collection".
95  else if (Key == "Swift ABI Version") {
96  Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 8;
97  } else if (Key == "Swift Major Version") {
98  Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 24;
99  } else if (Key == "Swift Minor Version") {
100  Flags |= (mdconst::extract<ConstantInt>(MFE.Val)->getZExtValue()) << 16;
101  }
102  }
103 }
104 
105 //===----------------------------------------------------------------------===//
106 // ELF
107 //===----------------------------------------------------------------------===//
108 
112 }
113 
115  const TargetMachine &TgtM) {
117 
118  CodeModel::Model CM = TgtM.getCodeModel();
120 
121  switch (TgtM.getTargetTriple().getArch()) {
122  case Triple::arm:
123  case Triple::armeb:
124  case Triple::thumb:
125  case Triple::thumbeb:
127  break;
128  // Fallthrough if not using EHABI
130  case Triple::ppc:
131  case Triple::ppcle:
132  case Triple::x86:
145  break;
146  case Triple::x86_64:
147  if (isPositionIndependent()) {
149  ((CM == CodeModel::Small || CM == CodeModel::Medium)
152  (CM == CodeModel::Small
155  ((CM == CodeModel::Small || CM == CodeModel::Medium)
157  } else {
159  (CM == CodeModel::Small || CM == CodeModel::Medium)
165  }
166  break;
167  case Triple::hexagon:
171  if (isPositionIndependent()) {
175  }
176  break;
177  case Triple::aarch64:
178  case Triple::aarch64_be:
179  case Triple::aarch64_32:
180  // The small model guarantees static code/data size < 4GB, but not where it
181  // will be in memory. Most of these could end up >2GB away so even a signed
182  // pc-relative 32-bit address is insufficient, theoretically.
183  if (isPositionIndependent()) {
184  // ILP32 uses sdata4 instead of sdata8
191  } else {
197  }
198  } else {
202  }
203  break;
204  case Triple::lanai:
208  break;
209  case Triple::mips:
210  case Triple::mipsel:
211  case Triple::mips64:
212  case Triple::mips64el:
213  // MIPS uses indirect pointer to refer personality functions and types, so
214  // that the eh_frame section can be read-only. DW.ref.personality will be
215  // generated for relocation.
217  // FIXME: The N64 ABI probably ought to use DW_EH_PE_sdata8 but we can't
218  // identify N64 from just a triple.
221  // We don't support PC-relative LSDA references in GAS so we use the default
222  // DW_EH_PE_absptr for those.
223 
224  // FreeBSD must be explicit about the data size and using pcrel since it's
225  // assembler/linker won't do the automatic conversion that the Linux tools
226  // do.
227  if (TgtM.getTargetTriple().isOSFreeBSD()) {
230  }
231  break;
232  case Triple::ppc64:
233  case Triple::ppc64le:
239  break;
240  case Triple::sparcel:
241  case Triple::sparc:
242  if (isPositionIndependent()) {
248  } else {
252  }
254  break;
255  case Triple::riscv32:
256  case Triple::riscv64:
263  break;
264  case Triple::sparcv9:
266  if (isPositionIndependent()) {
271  } else {
274  }
275  break;
276  case Triple::systemz:
277  // All currently-defined code models guarantee that 4-byte PC-relative
278  // values will be in range.
279  if (isPositionIndependent()) {
285  } else {
289  }
290  break;
291  default:
292  break;
293  }
294 }
295 
298  collectUsedGlobalVariables(M, Vec, false);
299  for (GlobalValue *GV : Vec)
300  if (auto *GO = dyn_cast<GlobalObject>(GV))
301  Used.insert(GO);
302 }
303 
305  Module &M) const {
306  auto &C = getContext();
307 
308  if (NamedMDNode *LinkerOptions = M.getNamedMetadata("llvm.linker.options")) {
309  auto *S = C.getELFSection(".linker-options", ELF::SHT_LLVM_LINKER_OPTIONS,
311 
312  Streamer.SwitchSection(S);
313 
314  for (const auto *Operand : LinkerOptions->operands()) {
315  if (cast<MDNode>(Operand)->getNumOperands() != 2)
316  report_fatal_error("invalid llvm.linker.options");
317  for (const auto &Option : cast<MDNode>(Operand)->operands()) {
318  Streamer.emitBytes(cast<MDString>(Option)->getString());
319  Streamer.emitInt8(0);
320  }
321  }
322  }
323 
324  if (NamedMDNode *DependentLibraries = M.getNamedMetadata("llvm.dependent-libraries")) {
325  auto *S = C.getELFSection(".deplibs", ELF::SHT_LLVM_DEPENDENT_LIBRARIES,
327 
328  Streamer.SwitchSection(S);
329 
330  for (const auto *Operand : DependentLibraries->operands()) {
331  Streamer.emitBytes(
332  cast<MDString>(cast<MDNode>(Operand)->getOperand(0))->getString());
333  Streamer.emitInt8(0);
334  }
335  }
336 
337  if (NamedMDNode *FuncInfo = M.getNamedMetadata(PseudoProbeDescMetadataName)) {
338  // Emit a descriptor for every function including functions that have an
339  // available external linkage. We may not want this for imported functions
340  // that has code in another thinLTO module but we don't have a good way to
341  // tell them apart from inline functions defined in header files. Therefore
342  // we put each descriptor in a separate comdat section and rely on the
343  // linker to deduplicate.
344  for (const auto *Operand : FuncInfo->operands()) {
345  const auto *MD = cast<MDNode>(Operand);
346  auto *GUID = mdconst::dyn_extract<ConstantInt>(MD->getOperand(0));
347  auto *Hash = mdconst::dyn_extract<ConstantInt>(MD->getOperand(1));
348  auto *Name = cast<MDString>(MD->getOperand(2));
349  auto *S = C.getObjectFileInfo()->getPseudoProbeDescSection(
350  TM->getFunctionSections() ? Name->getString() : StringRef());
351 
352  Streamer.SwitchSection(S);
353  Streamer.emitInt64(GUID->getZExtValue());
354  Streamer.emitInt64(Hash->getZExtValue());
355  Streamer.emitULEB128IntValue(Name->getString().size());
356  Streamer.emitBytes(Name->getString());
357  }
358  }
359 
360  unsigned Version = 0;
361  unsigned Flags = 0;
363 
364  GetObjCImageInfo(M, Version, Flags, Section);
365  if (!Section.empty()) {
366  auto *S = C.getELFSection(Section, ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
367  Streamer.SwitchSection(S);
368  Streamer.emitLabel(C.getOrCreateSymbol(StringRef("OBJC_IMAGE_INFO")));
369  Streamer.emitInt32(Version);
370  Streamer.emitInt32(Flags);
371  Streamer.AddBlankLine();
372  }
373 
374  emitCGProfileMetadata(Streamer, M);
375 }
376 
378  const GlobalValue *GV, const TargetMachine &TM,
379  MachineModuleInfo *MMI) const {
380  unsigned Encoding = getPersonalityEncoding();
381  if ((Encoding & 0x80) == DW_EH_PE_indirect)
382  return getContext().getOrCreateSymbol(StringRef("DW.ref.") +
383  TM.getSymbol(GV)->getName());
384  if ((Encoding & 0x70) == DW_EH_PE_absptr)
385  return TM.getSymbol(GV);
386  report_fatal_error("We do not support this DWARF encoding yet!");
387 }
388 
390  MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym) const {
391  SmallString<64> NameData("DW.ref.");
392  NameData += Sym->getName();
393  MCSymbolELF *Label =
394  cast<MCSymbolELF>(getContext().getOrCreateSymbol(NameData));
395  Streamer.emitSymbolAttribute(Label, MCSA_Hidden);
396  Streamer.emitSymbolAttribute(Label, MCSA_Weak);
397  unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_GROUP;
398  MCSection *Sec = getContext().getELFNamedSection(".data", Label->getName(),
399  ELF::SHT_PROGBITS, Flags, 0);
400  unsigned Size = DL.getPointerSize();
401  Streamer.SwitchSection(Sec);
402  Streamer.emitValueToAlignment(DL.getPointerABIAlignment(0).value());
403  Streamer.emitSymbolAttribute(Label, MCSA_ELF_TypeObject);
405  Streamer.emitELFSize(Label, E);
406  Streamer.emitLabel(Label);
407 
408  Streamer.emitSymbolValue(Sym, Size);
409 }
410 
412  const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
413  MachineModuleInfo *MMI, MCStreamer &Streamer) const {
414  if (Encoding & DW_EH_PE_indirect) {
416 
417  MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", TM);
418 
419  // Add information about the stub reference to ELFMMI so that the stub
420  // gets emitted by the asmprinter.
421  MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
422  if (!StubSym.getPointer()) {
423  MCSymbol *Sym = TM.getSymbol(GV);
425  }
426 
429  Encoding & ~DW_EH_PE_indirect, Streamer);
430  }
431 
433  MMI, Streamer);
434 }
435 
437  // N.B.: The defaults used in here are not the same ones used in MC.
438  // We follow gcc, MC follows gas. For example, given ".section .eh_frame",
439  // both gas and MC will produce a section with no flags. Given
440  // section(".eh_frame") gcc will produce:
441  //
442  // .section .eh_frame,"a",@progbits
443 
444  if (Name == getInstrProfSectionName(IPSK_covmap, Triple::ELF,
445  /*AddSegmentInfo=*/false) ||
446  Name == getInstrProfSectionName(IPSK_covfun, Triple::ELF,
447  /*AddSegmentInfo=*/false) ||
448  Name == ".llvmbc" || Name == ".llvmcmd")
449  return SectionKind::getMetadata();
450 
451  if (Name.empty() || Name[0] != '.') return K;
452 
453  // Default implementation based on some magic section names.
454  if (Name == ".bss" ||
455  Name.startswith(".bss.") ||
456  Name.startswith(".gnu.linkonce.b.") ||
457  Name.startswith(".llvm.linkonce.b.") ||
458  Name == ".sbss" ||
459  Name.startswith(".sbss.") ||
460  Name.startswith(".gnu.linkonce.sb.") ||
461  Name.startswith(".llvm.linkonce.sb."))
462  return SectionKind::getBSS();
463 
464  if (Name == ".tdata" ||
465  Name.startswith(".tdata.") ||
466  Name.startswith(".gnu.linkonce.td.") ||
467  Name.startswith(".llvm.linkonce.td."))
469 
470  if (Name == ".tbss" ||
471  Name.startswith(".tbss.") ||
472  Name.startswith(".gnu.linkonce.tb.") ||
473  Name.startswith(".llvm.linkonce.tb."))
474  return SectionKind::getThreadBSS();
475 
476  return K;
477 }
478 
480  // Use SHT_NOTE for section whose name starts with ".note" to allow
481  // emitting ELF notes from C variable declaration.
482  // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77609
483  if (Name.startswith(".note"))
484  return ELF::SHT_NOTE;
485 
486  if (Name == ".init_array")
487  return ELF::SHT_INIT_ARRAY;
488 
489  if (Name == ".fini_array")
490  return ELF::SHT_FINI_ARRAY;
491 
492  if (Name == ".preinit_array")
493  return ELF::SHT_PREINIT_ARRAY;
494 
495  if (K.isBSS() || K.isThreadBSS())
496  return ELF::SHT_NOBITS;
497 
498  return ELF::SHT_PROGBITS;
499 }
500 
501 static unsigned getELFSectionFlags(SectionKind K) {
502  unsigned Flags = 0;
503 
504  if (!K.isMetadata())
505  Flags |= ELF::SHF_ALLOC;
506 
507  if (K.isText())
508  Flags |= ELF::SHF_EXECINSTR;
509 
510  if (K.isExecuteOnly())
511  Flags |= ELF::SHF_ARM_PURECODE;
512 
513  if (K.isWriteable())
514  Flags |= ELF::SHF_WRITE;
515 
516  if (K.isThreadLocal())
517  Flags |= ELF::SHF_TLS;
518 
519  if (K.isMergeableCString() || K.isMergeableConst())
520  Flags |= ELF::SHF_MERGE;
521 
522  if (K.isMergeableCString())
523  Flags |= ELF::SHF_STRINGS;
524 
525  return Flags;
526 }
527 
528 static const Comdat *getELFComdat(const GlobalValue *GV) {
529  const Comdat *C = GV->getComdat();
530  if (!C)
531  return nullptr;
532 
533  if (C->getSelectionKind() != Comdat::Any &&
534  C->getSelectionKind() != Comdat::NoDuplicates)
535  report_fatal_error("ELF COMDATs only support SelectionKind::Any and "
536  "SelectionKind::NoDuplicates, '" + C->getName() +
537  "' cannot be lowered.");
538 
539  return C;
540 }
541 
543  const TargetMachine &TM) {
544  MDNode *MD = GO->getMetadata(LLVMContext::MD_associated);
545  if (!MD)
546  return nullptr;
547 
548  const MDOperand &Op = MD->getOperand(0);
549  if (!Op.get())
550  return nullptr;
551 
552  auto *VM = dyn_cast<ValueAsMetadata>(Op);
553  if (!VM)
554  report_fatal_error("MD_associated operand is not ValueAsMetadata");
555 
556  auto *OtherGV = dyn_cast<GlobalValue>(VM->getValue());
557  return OtherGV ? dyn_cast<MCSymbolELF>(TM.getSymbol(OtherGV)) : nullptr;
558 }
559 
561  if (Kind.isMergeable1ByteCString())
562  return 1;
563  else if (Kind.isMergeable2ByteCString())
564  return 2;
565  else if (Kind.isMergeable4ByteCString())
566  return 4;
567  else if (Kind.isMergeableConst4())
568  return 4;
569  else if (Kind.isMergeableConst8())
570  return 8;
571  else if (Kind.isMergeableConst16())
572  return 16;
573  else if (Kind.isMergeableConst32())
574  return 32;
575  else {
576  // We shouldn't have mergeable C strings or mergeable constants that we
577  // didn't handle above.
578  assert(!Kind.isMergeableCString() && "unknown string width");
579  assert(!Kind.isMergeableConst() && "unknown data width");
580  return 0;
581  }
582 }
583 
584 /// Return the section prefix name used by options FunctionsSections and
585 /// DataSections.
587  if (Kind.isText())
588  return ".text";
589  if (Kind.isReadOnly())
590  return ".rodata";
591  if (Kind.isBSS())
592  return ".bss";
593  if (Kind.isThreadData())
594  return ".tdata";
595  if (Kind.isThreadBSS())
596  return ".tbss";
597  if (Kind.isData())
598  return ".data";
599  if (Kind.isReadOnlyWithRel())
600  return ".data.rel.ro";
601  llvm_unreachable("Unknown section kind");
602 }
603 
604 static SmallString<128>
606  Mangler &Mang, const TargetMachine &TM,
607  unsigned EntrySize, bool UniqueSectionName) {
609  if (Kind.isMergeableCString()) {
610  // We also need alignment here.
611  // FIXME: this is getting the alignment of the character, not the
612  // alignment of the global!
613  Align Alignment = GO->getParent()->getDataLayout().getPreferredAlign(
614  cast<GlobalVariable>(GO));
615 
616  std::string SizeSpec = ".rodata.str" + utostr(EntrySize) + ".";
617  Name = SizeSpec + utostr(Alignment.value());
618  } else if (Kind.isMergeableConst()) {
619  Name = ".rodata.cst";
620  Name += utostr(EntrySize);
621  } else {
623  }
624 
625  bool HasPrefix = false;
626  if (const auto *F = dyn_cast<Function>(GO)) {
627  if (Optional<StringRef> Prefix = F->getSectionPrefix()) {
628  raw_svector_ostream(Name) << '.' << *Prefix;
629  HasPrefix = true;
630  }
631  }
632 
633  if (UniqueSectionName) {
634  Name.push_back('.');
635  TM.getNameWithPrefix(Name, GO, Mang, /*MayAlwaysUsePrivate*/true);
636  } else if (HasPrefix)
637  // For distinguishing between .text.${text-section-prefix}. (with trailing
638  // dot) and .text.${function-name}
639  Name.push_back('.');
640  return Name;
641 }
642 
643 namespace {
644 class LoweringDiagnosticInfo : public DiagnosticInfo {
645  const Twine &Msg;
646 
647 public:
648  LoweringDiagnosticInfo(const Twine &DiagMsg,
649  DiagnosticSeverity Severity = DS_Error)
650  : DiagnosticInfo(DK_Lowering, Severity), Msg(DiagMsg) {}
651  void print(DiagnosticPrinter &DP) const override { DP << Msg; }
652 };
653 }
654 
656  const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
658 
659  // Check if '#pragma clang section' name is applicable.
660  // Note that pragma directive overrides -ffunction-section, -fdata-section
661  // and so section name is exactly as user specified and not uniqued.
662  const GlobalVariable *GV = dyn_cast<GlobalVariable>(GO);
663  if (GV && GV->hasImplicitSection()) {
664  auto Attrs = GV->getAttributes();
665  if (Attrs.hasAttribute("bss-section") && Kind.isBSS()) {
666  SectionName = Attrs.getAttribute("bss-section").getValueAsString();
667  } else if (Attrs.hasAttribute("rodata-section") && Kind.isReadOnly()) {
668  SectionName = Attrs.getAttribute("rodata-section").getValueAsString();
669  } else if (Attrs.hasAttribute("relro-section") && Kind.isReadOnlyWithRel()) {
670  SectionName = Attrs.getAttribute("relro-section").getValueAsString();
671  } else if (Attrs.hasAttribute("data-section") && Kind.isData()) {
672  SectionName = Attrs.getAttribute("data-section").getValueAsString();
673  }
674  }
675  const Function *F = dyn_cast<Function>(GO);
676  if (F && F->hasFnAttribute("implicit-section-name")) {
677  SectionName = F->getFnAttribute("implicit-section-name").getValueAsString();
678  }
679 
680  // Infer section flags from the section name if we can.
682 
683  StringRef Group = "";
684  bool IsComdat = false;
685  unsigned Flags = getELFSectionFlags(Kind);
686  if (const Comdat *C = getELFComdat(GO)) {
687  Group = C->getName();
688  IsComdat = C->getSelectionKind() == Comdat::Any;
689  Flags |= ELF::SHF_GROUP;
690  }
691 
692  unsigned EntrySize = getEntrySizeForKind(Kind);
693 
694  // A section can have at most one associated section. Put each global with
695  // MD_associated in a unique section.
696  unsigned UniqueID = MCContext::GenericSectionID;
697  const MCSymbolELF *LinkedToSym = getLinkedToSymbol(GO, TM);
698  const bool Associated = GO->getMetadata(LLVMContext::MD_associated);
699  const bool Retain = Used.count(GO);
700  if (Associated || Retain) {
701  UniqueID = NextUniqueID++;
702  if (Associated)
703  Flags |= ELF::SHF_LINK_ORDER;
704  if (Retain && (getContext().getAsmInfo()->useIntegratedAssembler() ||
705  getContext().getAsmInfo()->binutilsIsAtLeast(2, 36)))
706  Flags |= ELF::SHF_GNU_RETAIN;
707  } else {
708  if (getContext().getAsmInfo()->useIntegratedAssembler() ||
709  getContext().getAsmInfo()->binutilsIsAtLeast(2, 35)) {
710  // Symbols must be placed into sections with compatible entry
711  // sizes. Generate unique sections for symbols that have not
712  // been assigned to compatible sections.
713  if (Flags & ELF::SHF_MERGE) {
714  auto maybeID = getContext().getELFUniqueIDForEntsize(SectionName, Flags,
715  EntrySize);
716  if (maybeID)
717  UniqueID = *maybeID;
718  else {
719  // If the user has specified the same section name as would be created
720  // implicitly for this symbol e.g. .rodata.str1.1, then we don't need
721  // to unique the section as the entry size for this symbol will be
722  // compatible with implicitly created sections.
723  SmallString<128> ImplicitSectionNameStem = getELFSectionNameForGlobal(
724  GO, Kind, getMangler(), TM, EntrySize, false);
725  if (!(getContext().isELFImplicitMergeableSectionNamePrefix(
726  SectionName) &&
727  SectionName.startswith(ImplicitSectionNameStem)))
728  UniqueID = NextUniqueID++;
729  }
730  } else {
731  // We need to unique the section if the user has explicity
732  // assigned a non-mergeable symbol to a section name for
733  // a generic mergeable section.
734  if (getContext().isELFGenericMergeableSection(SectionName)) {
735  auto maybeID = getContext().getELFUniqueIDForEntsize(
736  SectionName, Flags, EntrySize);
737  UniqueID = maybeID ? *maybeID : NextUniqueID++;
738  }
739  }
740  } else {
741  // If two symbols with differing sizes end up in the same mergeable
742  // section that section can be assigned an incorrect entry size. To avoid
743  // this we usually put symbols of the same size into distinct mergeable
744  // sections with the same name. Doing so relies on the ",unique ,"
745  // assembly feature. This feature is not avalible until bintuils
746  // version 2.35 (https://sourceware.org/bugzilla/show_bug.cgi?id=25380).
747  Flags &= ~ELF::SHF_MERGE;
748  EntrySize = 0;
749  }
750  }
751 
753  SectionName, getELFSectionType(SectionName, Kind), Flags, EntrySize,
754  Group, IsComdat, UniqueID, LinkedToSym);
755  // Make sure that we did not get some other section with incompatible sh_link.
756  // This should not be possible due to UniqueID code above.
757  assert(Section->getLinkedToSymbol() == LinkedToSym &&
758  "Associated symbol mismatch between sections");
759 
760  if (!(getContext().getAsmInfo()->useIntegratedAssembler() ||
761  getContext().getAsmInfo()->binutilsIsAtLeast(2, 35))) {
762  // If we are using GNU as before 2.35, then this symbol might have
763  // been placed in an incompatible mergeable section. Emit an error if this
764  // is the case to avoid creating broken output.
765  if ((Section->getFlags() & ELF::SHF_MERGE) &&
766  (Section->getEntrySize() != getEntrySizeForKind(Kind)))
767  GO->getContext().diagnose(LoweringDiagnosticInfo(
768  "Symbol '" + GO->getName() + "' from module '" +
769  (GO->getParent() ? GO->getParent()->getSourceFileName() : "unknown") +
770  "' required a section with entry-size=" +
771  Twine(getEntrySizeForKind(Kind)) + " but was placed in section '" +
772  SectionName + "' with entry-size=" + Twine(Section->getEntrySize()) +
773  ": Explicit assignment by pragma or attribute of an incompatible "
774  "symbol to this section?"));
775  }
776 
777  return Section;
778 }
779 
781  MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang,
782  const TargetMachine &TM, bool EmitUniqueSection, unsigned Flags,
783  unsigned *NextUniqueID, const MCSymbolELF *AssociatedSymbol) {
784 
785  StringRef Group = "";
786  bool IsComdat = false;
787  if (const Comdat *C = getELFComdat(GO)) {
788  Flags |= ELF::SHF_GROUP;
789  Group = C->getName();
790  IsComdat = C->getSelectionKind() == Comdat::Any;
791  }
792 
793  // Get the section entry size based on the kind.
794  unsigned EntrySize = getEntrySizeForKind(Kind);
795 
796  bool UniqueSectionName = false;
797  unsigned UniqueID = MCContext::GenericSectionID;
798  if (EmitUniqueSection) {
799  if (TM.getUniqueSectionNames()) {
800  UniqueSectionName = true;
801  } else {
802  UniqueID = *NextUniqueID;
803  (*NextUniqueID)++;
804  }
805  }
807  GO, Kind, Mang, TM, EntrySize, UniqueSectionName);
808 
809  // Use 0 as the unique ID for execute-only text.
810  if (Kind.isExecuteOnly())
811  UniqueID = 0;
812  return Ctx.getELFSection(Name, getELFSectionType(Name, Kind), Flags,
813  EntrySize, Group, IsComdat, UniqueID,
814  AssociatedSymbol);
815 }
816 
818  MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang,
819  const TargetMachine &TM, bool Retain, bool EmitUniqueSection,
820  unsigned Flags, unsigned *NextUniqueID) {
821  const MCSymbolELF *LinkedToSym = getLinkedToSymbol(GO, TM);
822  if (LinkedToSym) {
823  EmitUniqueSection = true;
824  Flags |= ELF::SHF_LINK_ORDER;
825  }
826  if (Retain && (Ctx.getAsmInfo()->useIntegratedAssembler() ||
827  Ctx.getAsmInfo()->binutilsIsAtLeast(2, 36))) {
828  EmitUniqueSection = true;
829  Flags |= ELF::SHF_GNU_RETAIN;
830  }
831 
833  Ctx, GO, Kind, Mang, TM, EmitUniqueSection, Flags,
834  NextUniqueID, LinkedToSym);
835  assert(Section->getLinkedToSymbol() == LinkedToSym);
836  return Section;
837 }
838 
840  const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
841  unsigned Flags = getELFSectionFlags(Kind);
842 
843  // If we have -ffunction-section or -fdata-section then we should emit the
844  // global value to a uniqued section specifically for it.
845  bool EmitUniqueSection = false;
846  if (!(Flags & ELF::SHF_MERGE) && !Kind.isCommon()) {
847  if (Kind.isText())
848  EmitUniqueSection = TM.getFunctionSections();
849  else
850  EmitUniqueSection = TM.getDataSections();
851  }
852  EmitUniqueSection |= GO->hasComdat();
854  Used.count(GO), EmitUniqueSection, Flags,
855  &NextUniqueID);
856 }
857 
859  const Function &F, const TargetMachine &TM) const {
861  unsigned Flags = getELFSectionFlags(Kind);
863  getContext(), &F, Kind, getMangler(), TM, Used.count(&F),
864  /*EmitUniqueSection=*/true, Flags, &NextUniqueID);
865 }
866 
868  const Function &F, const TargetMachine &TM) const {
869  // If the function can be removed, produce a unique section so that
870  // the table doesn't prevent the removal.
871  const Comdat *C = F.getComdat();
872  bool EmitUniqueSection = TM.getFunctionSections() || C;
873  if (!EmitUniqueSection)
874  return ReadOnlySection;
875 
877  getMangler(), TM, EmitUniqueSection,
878  ELF::SHF_ALLOC, &NextUniqueID,
879  /* AssociatedSymbol */ nullptr);
880 }
881 
883  const Function &F, const MCSymbol &FnSym, const TargetMachine &TM) const {
884  // If neither COMDAT nor function sections, use the monolithic LSDA section.
885  // Re-use this path if LSDASection is null as in the Arm EHABI.
886  if (!LSDASection || (!F.hasComdat() && !TM.getFunctionSections()))
887  return LSDASection;
888 
889  const auto *LSDA = cast<MCSectionELF>(LSDASection);
890  unsigned Flags = LSDA->getFlags();
891  const MCSymbolELF *LinkedToSym = nullptr;
892  StringRef Group;
893  if (const Comdat *C = getELFComdat(&F)) {
894  Flags |= ELF::SHF_GROUP;
895  Group = C->getName();
896  }
897  // Use SHF_LINK_ORDER to facilitate --gc-sections if we can use GNU ld>=2.36
898  // or LLD, which support mixed SHF_LINK_ORDER & non-SHF_LINK_ORDER.
899  if (TM.getFunctionSections() &&
900  (getContext().getAsmInfo()->useIntegratedAssembler() &&
901  getContext().getAsmInfo()->binutilsIsAtLeast(2, 36))) {
902  Flags |= ELF::SHF_LINK_ORDER;
903  LinkedToSym = cast<MCSymbolELF>(&FnSym);
904  }
905 
906  // Append the function name as the suffix like GCC, assuming
907  // -funique-section-names applies to .gcc_except_table sections.
908  return getContext().getELFSection(
909  (TM.getUniqueSectionNames() ? LSDA->getName() + "." + F.getName()
910  : LSDA->getName()),
911  LSDA->getType(), Flags, 0, Group, F.hasComdat(), MCSection::NonUniqueID,
912  LinkedToSym);
913 }
914 
916  bool UsesLabelDifference, const Function &F) const {
917  // We can always create relative relocations, so use another section
918  // that can be marked non-executable.
919  return false;
920 }
921 
922 /// Given a mergeable constant with the specified size and relocation
923 /// information, return a section that it should be placed in.
925  const DataLayout &DL, SectionKind Kind, const Constant *C,
926  Align &Alignment) const {
927  if (Kind.isMergeableConst4() && MergeableConst4Section)
928  return MergeableConst4Section;
929  if (Kind.isMergeableConst8() && MergeableConst8Section)
930  return MergeableConst8Section;
931  if (Kind.isMergeableConst16() && MergeableConst16Section)
933  if (Kind.isMergeableConst32() && MergeableConst32Section)
935  if (Kind.isReadOnly())
936  return ReadOnlySection;
937 
938  assert(Kind.isReadOnlyWithRel() && "Unknown section kind");
939  return DataRelROSection;
940 }
941 
942 /// Returns a unique section for the given machine basic block.
944  const Function &F, const MachineBasicBlock &MBB,
945  const TargetMachine &TM) const {
946  assert(MBB.isBeginSection() && "Basic block does not start a section!");
947  unsigned UniqueID = MCContext::GenericSectionID;
948 
949  // For cold sections use the .text.split. prefix along with the parent
950  // function name. All cold blocks for the same function go to the same
951  // section. Similarly all exception blocks are grouped by symbol name
952  // under the .text.eh prefix. For regular sections, we either use a unique
953  // name, or a unique ID for the section.
957  Name += MBB.getParent()->getName();
959  Name += ".text.eh.";
960  Name += MBB.getParent()->getName();
961  } else {
962  Name += MBB.getParent()->getSection()->getName();
964  if (!Name.endswith("."))
965  Name += ".";
966  Name += MBB.getSymbol()->getName();
967  } else {
968  UniqueID = NextUniqueID++;
969  }
970  }
971 
972  unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_EXECINSTR;
973  std::string GroupName;
974  if (F.hasComdat()) {
975  Flags |= ELF::SHF_GROUP;
976  GroupName = F.getComdat()->getName().str();
977  }
979  0 /* Entry Size */, GroupName,
980  F.hasComdat(), UniqueID, nullptr);
981 }
982 
983 static MCSectionELF *getStaticStructorSection(MCContext &Ctx, bool UseInitArray,
984  bool IsCtor, unsigned Priority,
985  const MCSymbol *KeySym) {
986  std::string Name;
987  unsigned Type;
988  unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE;
989  StringRef Comdat = KeySym ? KeySym->getName() : "";
990 
991  if (KeySym)
992  Flags |= ELF::SHF_GROUP;
993 
994  if (UseInitArray) {
995  if (IsCtor) {
997  Name = ".init_array";
998  } else {
1000  Name = ".fini_array";
1001  }
1002  if (Priority != 65535) {
1003  Name += '.';
1004  Name += utostr(Priority);
1005  }
1006  } else {
1007  // The default scheme is .ctor / .dtor, so we have to invert the priority
1008  // numbering.
1009  if (IsCtor)
1010  Name = ".ctors";
1011  else
1012  Name = ".dtors";
1013  if (Priority != 65535)
1014  raw_string_ostream(Name) << format(".%05u", 65535 - Priority);
1016  }
1017 
1018  return Ctx.getELFSection(Name, Type, Flags, 0, Comdat, /*IsComdat=*/true);
1019 }
1020 
1022  unsigned Priority, const MCSymbol *KeySym) const {
1023  return getStaticStructorSection(getContext(), UseInitArray, true, Priority,
1024  KeySym);
1025 }
1026 
1028  unsigned Priority, const MCSymbol *KeySym) const {
1029  return getStaticStructorSection(getContext(), UseInitArray, false, Priority,
1030  KeySym);
1031 }
1032 
1034  const GlobalValue *LHS, const GlobalValue *RHS,
1035  const TargetMachine &TM) const {
1036  // We may only use a PLT-relative relocation to refer to unnamed_addr
1037  // functions.
1038  if (!LHS->hasGlobalUnnamedAddr() || !LHS->getValueType()->isFunctionTy())
1039  return nullptr;
1040 
1041  // Basic sanity checks.
1042  if (LHS->getType()->getPointerAddressSpace() != 0 ||
1043  RHS->getType()->getPointerAddressSpace() != 0 || LHS->isThreadLocal() ||
1044  RHS->isThreadLocal())
1045  return nullptr;
1046 
1047  return MCBinaryExpr::createSub(
1049  getContext()),
1051 }
1052 
1054  const DSOLocalEquivalent *Equiv, const TargetMachine &TM) const {
1056 
1057  const auto *GV = Equiv->getGlobalValue();
1058 
1059  // A PLT entry is not needed for dso_local globals.
1060  if (GV->isDSOLocal() || GV->isImplicitDSOLocal())
1062 
1064  getContext());
1065 }
1066 
1068  // Use ".GCC.command.line" since this feature is to support clang's
1069  // -frecord-gcc-switches which in turn attempts to mimic GCC's switch of the
1070  // same name.
1071  return getContext().getELFSection(".GCC.command.line", ELF::SHT_PROGBITS,
1073 }
1074 
1075 void
1077  UseInitArray = UseInitArray_;
1078  MCContext &Ctx = getContext();
1079  if (!UseInitArray) {
1082 
1085  return;
1086  }
1087 
1092 }
1093 
1094 //===----------------------------------------------------------------------===//
1095 // MachO
1096 //===----------------------------------------------------------------------===//
1097 
1101 }
1102 
1104  const TargetMachine &TM) {
1106  if (TM.getRelocationModel() == Reloc::Static) {
1107  StaticCtorSection = Ctx.getMachOSection("__TEXT", "__constructor", 0,
1109  StaticDtorSection = Ctx.getMachOSection("__TEXT", "__destructor", 0,
1111  } else {
1112  StaticCtorSection = Ctx.getMachOSection("__DATA", "__mod_init_func",
1115  StaticDtorSection = Ctx.getMachOSection("__DATA", "__mod_term_func",
1118  }
1119 
1123  TTypeEncoding =
1125 }
1126 
1128  Module &M) const {
1129  // Emit the linker options if present.
1130  if (auto *LinkerOptions = M.getNamedMetadata("llvm.linker.options")) {
1131  for (const auto *Option : LinkerOptions->operands()) {
1132  SmallVector<std::string, 4> StrOptions;
1133  for (const auto &Piece : cast<MDNode>(Option)->operands())
1134  StrOptions.push_back(std::string(cast<MDString>(Piece)->getString()));
1135  Streamer.emitLinkerOptions(StrOptions);
1136  }
1137  }
1138 
1139  unsigned VersionVal = 0;
1140  unsigned ImageInfoFlags = 0;
1141  StringRef SectionVal;
1142 
1143  GetObjCImageInfo(M, VersionVal, ImageInfoFlags, SectionVal);
1144 
1145  // The section is mandatory. If we don't have it, then we don't have GC info.
1146  if (SectionVal.empty())
1147  return;
1148 
1149  StringRef Segment, Section;
1150  unsigned TAA = 0, StubSize = 0;
1151  bool TAAParsed;
1153  SectionVal, Segment, Section, TAA, TAAParsed, StubSize)) {
1154  // If invalid, report the error with report_fatal_error.
1155  report_fatal_error("Invalid section specifier '" + Section +
1156  "': " + toString(std::move(E)) + ".");
1157  }
1158 
1159  // Get the section.
1161  Segment, Section, TAA, StubSize, SectionKind::getData());
1162  Streamer.SwitchSection(S);
1163  Streamer.emitLabel(getContext().
1164  getOrCreateSymbol(StringRef("L_OBJC_IMAGE_INFO")));
1165  Streamer.emitInt32(VersionVal);
1166  Streamer.emitInt32(ImageInfoFlags);
1167  Streamer.AddBlankLine();
1168 }
1169 
1170 static void checkMachOComdat(const GlobalValue *GV) {
1171  const Comdat *C = GV->getComdat();
1172  if (!C)
1173  return;
1174 
1175  report_fatal_error("MachO doesn't support COMDATs, '" + C->getName() +
1176  "' cannot be lowered.");
1177 }
1178 
1180  const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
1181 
1183 
1184  const Function *F = dyn_cast<Function>(GO);
1185  if (F && F->hasFnAttribute("implicit-section-name")) {
1186  SectionName = F->getFnAttribute("implicit-section-name").getValueAsString();
1187  }
1188 
1189  // Parse the section specifier and create it if valid.
1190  StringRef Segment, Section;
1191  unsigned TAA = 0, StubSize = 0;
1192  bool TAAParsed;
1193 
1194  checkMachOComdat(GO);
1195 
1197  SectionName, Segment, Section, TAA, TAAParsed, StubSize)) {
1198  // If invalid, report the error with report_fatal_error.
1199  report_fatal_error("Global variable '" + GO->getName() +
1200  "' has an invalid section specifier '" +
1201  GO->getSection() + "': " + toString(std::move(E)) + ".");
1202  }
1203 
1204  // Get the section.
1205  MCSectionMachO *S =
1206  getContext().getMachOSection(Segment, Section, TAA, StubSize, Kind);
1207 
1208  // If TAA wasn't set by ParseSectionSpecifier() above,
1209  // use the value returned by getMachOSection() as a default.
1210  if (!TAAParsed)
1211  TAA = S->getTypeAndAttributes();
1212 
1213  // Okay, now that we got the section, verify that the TAA & StubSize agree.
1214  // If the user declared multiple globals with different section flags, we need
1215  // to reject it here.
1216  if (S->getTypeAndAttributes() != TAA || S->getStubSize() != StubSize) {
1217  // If invalid, report the error with report_fatal_error.
1218  report_fatal_error("Global variable '" + GO->getName() +
1219  "' section type or attributes does not match previous"
1220  " section specifier");
1221  }
1222 
1223  return S;
1224 }
1225 
1227  const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
1228  checkMachOComdat(GO);
1229 
1230  // Handle thread local data.
1231  if (Kind.isThreadBSS()) return TLSBSSSection;
1232  if (Kind.isThreadData()) return TLSDataSection;
1233 
1234  if (Kind.isText())
1235  return GO->isWeakForLinker() ? TextCoalSection : TextSection;
1236 
1237  // If this is weak/linkonce, put this in a coalescable section, either in text
1238  // or data depending on if it is writable.
1239  if (GO->isWeakForLinker()) {
1240  if (Kind.isReadOnly())
1241  return ConstTextCoalSection;
1242  if (Kind.isReadOnlyWithRel())
1243  return ConstDataCoalSection;
1244  return DataCoalSection;
1245  }
1246 
1247  // FIXME: Alignment check should be handled by section classifier.
1248  if (Kind.isMergeable1ByteCString() &&
1250  cast<GlobalVariable>(GO)) < Align(32))
1251  return CStringSection;
1252 
1253  // Do not put 16-bit arrays in the UString section if they have an
1254  // externally visible label, this runs into issues with certain linker
1255  // versions.
1256  if (Kind.isMergeable2ByteCString() && !GO->hasExternalLinkage() &&
1258  cast<GlobalVariable>(GO)) < Align(32))
1259  return UStringSection;
1260 
1261  // With MachO only variables whose corresponding symbol starts with 'l' or
1262  // 'L' can be merged, so we only try merging GVs with private linkage.
1263  if (GO->hasPrivateLinkage() && Kind.isMergeableConst()) {
1264  if (Kind.isMergeableConst4())
1265  return FourByteConstantSection;
1266  if (Kind.isMergeableConst8())
1267  return EightByteConstantSection;
1268  if (Kind.isMergeableConst16())
1270  }
1271 
1272  // Otherwise, if it is readonly, but not something we can specially optimize,
1273  // just drop it in .const.
1274  if (Kind.isReadOnly())
1275  return ReadOnlySection;
1276 
1277  // If this is marked const, put it into a const section. But if the dynamic
1278  // linker needs to write to it, put it in the data segment.
1279  if (Kind.isReadOnlyWithRel())
1280  return ConstDataSection;
1281 
1282  // Put zero initialized globals with strong external linkage in the
1283  // DATA, __common section with the .zerofill directive.
1284  if (Kind.isBSSExtern())
1285  return DataCommonSection;
1286 
1287  // Put zero initialized globals with local linkage in __DATA,__bss directive
1288  // with the .zerofill directive (aka .lcomm).
1289  if (Kind.isBSSLocal())
1290  return DataBSSSection;
1291 
1292  // Otherwise, just drop the variable in the normal data section.
1293  return DataSection;
1294 }
1295 
1297  const DataLayout &DL, SectionKind Kind, const Constant *C,
1298  Align &Alignment) const {
1299  // If this constant requires a relocation, we have to put it in the data
1300  // segment, not in the text segment.
1301  if (Kind.isData() || Kind.isReadOnlyWithRel())
1302  return ConstDataSection;
1303 
1304  if (Kind.isMergeableConst4())
1305  return FourByteConstantSection;
1306  if (Kind.isMergeableConst8())
1307  return EightByteConstantSection;
1308  if (Kind.isMergeableConst16())
1310  return ReadOnlySection; // .const
1311 }
1312 
1314  const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
1315  MachineModuleInfo *MMI, MCStreamer &Streamer) const {
1316  // The mach-o version of this method defaults to returning a stub reference.
1317 
1318  if (Encoding & DW_EH_PE_indirect) {
1319  MachineModuleInfoMachO &MachOMMI =
1321 
1322  MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", TM);
1323 
1324  // Add information about the stub reference to MachOMMI so that the stub
1325  // gets emitted by the asmprinter.
1326  MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
1327  if (!StubSym.getPointer()) {
1328  MCSymbol *Sym = TM.getSymbol(GV);
1329  StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
1330  }
1331 
1334  Encoding & ~DW_EH_PE_indirect, Streamer);
1335  }
1336 
1338  MMI, Streamer);
1339 }
1340 
1342  const GlobalValue *GV, const TargetMachine &TM,
1343  MachineModuleInfo *MMI) const {
1344  // The mach-o version of this method defaults to returning a stub reference.
1345  MachineModuleInfoMachO &MachOMMI =
1347 
1348  MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", TM);
1349 
1350  // Add information about the stub reference to MachOMMI so that the stub
1351  // gets emitted by the asmprinter.
1352  MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
1353  if (!StubSym.getPointer()) {
1354  MCSymbol *Sym = TM.getSymbol(GV);
1355  StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
1356  }
1357 
1358  return SSym;
1359 }
1360 
1362  const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV,
1363  int64_t Offset, MachineModuleInfo *MMI, MCStreamer &Streamer) const {
1364  // Although MachO 32-bit targets do not explicitly have a GOTPCREL relocation
1365  // as 64-bit do, we replace the GOT equivalent by accessing the final symbol
1366  // through a non_lazy_ptr stub instead. One advantage is that it allows the
1367  // computation of deltas to final external symbols. Example:
1368  //
1369  // _extgotequiv:
1370  // .long _extfoo
1371  //
1372  // _delta:
1373  // .long _extgotequiv-_delta
1374  //
1375  // is transformed to:
1376  //
1377  // _delta:
1378  // .long L_extfoo$non_lazy_ptr-(_delta+0)
1379  //
1380  // .section __IMPORT,__pointers,non_lazy_symbol_pointers
1381  // L_extfoo$non_lazy_ptr:
1382  // .indirect_symbol _extfoo
1383  // .long 0
1384  //
1385  // The indirect symbol table (and sections of non_lazy_symbol_pointers type)
1386  // may point to both local (same translation unit) and global (other
1387  // translation units) symbols. Example:
1388  //
1389  // .section __DATA,__pointers,non_lazy_symbol_pointers
1390  // L1:
1391  // .indirect_symbol _myGlobal
1392  // .long 0
1393  // L2:
1394  // .indirect_symbol _myLocal
1395  // .long _myLocal
1396  //
1397  // If the symbol is local, instead of the symbol's index, the assembler
1398  // places the constant INDIRECT_SYMBOL_LOCAL into the indirect symbol table.
1399  // Then the linker will notice the constant in the table and will look at the
1400  // content of the symbol.
1401  MachineModuleInfoMachO &MachOMMI =
1403  MCContext &Ctx = getContext();
1404 
1405  // The offset must consider the original displacement from the base symbol
1406  // since 32-bit targets don't have a GOTPCREL to fold the PC displacement.
1407  Offset = -MV.getConstant();
1408  const MCSymbol *BaseSym = &MV.getSymB()->getSymbol();
1409 
1410  // Access the final symbol via sym$non_lazy_ptr and generate the appropriated
1411  // non_lazy_ptr stubs.
1413  StringRef Suffix = "$non_lazy_ptr";
1415  Name += Sym->getName();
1416  Name += Suffix;
1417  MCSymbol *Stub = Ctx.getOrCreateSymbol(Name);
1418 
1419  MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(Stub);
1420 
1421  if (!StubSym.getPointer())
1422  StubSym = MachineModuleInfoImpl::StubValueTy(const_cast<MCSymbol *>(Sym),
1423  !GV->hasLocalLinkage());
1424 
1425  const MCExpr *BSymExpr =
1427  const MCExpr *LHS =
1429 
1430  if (!Offset)
1431  return MCBinaryExpr::createSub(LHS, BSymExpr, Ctx);
1432 
1433  const MCExpr *RHS =
1435  return MCBinaryExpr::createSub(LHS, RHS, Ctx);
1436 }
1437 
1438 static bool canUsePrivateLabel(const MCAsmInfo &AsmInfo,
1439  const MCSection &Section) {
1440  if (!AsmInfo.isSectionAtomizableBySymbols(Section))
1441  return true;
1442 
1443  // If it is not dead stripped, it is safe to use private labels.
1444  const MCSectionMachO &SMO = cast<MCSectionMachO>(Section);
1446  return true;
1447 
1448  return false;
1449 }
1450 
1452  SmallVectorImpl<char> &OutName, const GlobalValue *GV,
1453  const TargetMachine &TM) const {
1454  bool CannotUsePrivateLabel = true;
1455  if (auto *GO = GV->getBaseObject()) {
1457  const MCSection *TheSection = SectionForGlobal(GO, GOKind, TM);
1458  CannotUsePrivateLabel =
1459  !canUsePrivateLabel(*TM.getMCAsmInfo(), *TheSection);
1460  }
1461  getMangler().getNameWithPrefix(OutName, GV, CannotUsePrivateLabel);
1462 }
1463 
1464 //===----------------------------------------------------------------------===//
1465 // COFF
1466 //===----------------------------------------------------------------------===//
1467 
1468 static unsigned
1470  unsigned Flags = 0;
1471  bool isThumb = TM.getTargetTriple().getArch() == Triple::thumb;
1472 
1473  if (K.isMetadata())
1474  Flags |=
1476  else if (K.isText())
1477  Flags |=
1482  else if (K.isBSS())
1483  Flags |=
1487  else if (K.isThreadLocal())
1488  Flags |=
1492  else if (K.isReadOnly() || K.isReadOnlyWithRel())
1493  Flags |=
1496  else if (K.isWriteable())
1497  Flags |=
1501 
1502  return Flags;
1503 }
1504 
1505 static const GlobalValue *getComdatGVForCOFF(const GlobalValue *GV) {
1506  const Comdat *C = GV->getComdat();
1507  assert(C && "expected GV to have a Comdat!");
1508 
1509  StringRef ComdatGVName = C->getName();
1510  const GlobalValue *ComdatGV = GV->getParent()->getNamedValue(ComdatGVName);
1511  if (!ComdatGV)
1512  report_fatal_error("Associative COMDAT symbol '" + ComdatGVName +
1513  "' does not exist.");
1514 
1515  if (ComdatGV->getComdat() != C)
1516  report_fatal_error("Associative COMDAT symbol '" + ComdatGVName +
1517  "' is not a key for its COMDAT.");
1518 
1519  return ComdatGV;
1520 }
1521 
1522 static int getSelectionForCOFF(const GlobalValue *GV) {
1523  if (const Comdat *C = GV->getComdat()) {
1524  const GlobalValue *ComdatKey = getComdatGVForCOFF(GV);
1525  if (const auto *GA = dyn_cast<GlobalAlias>(ComdatKey))
1526  ComdatKey = GA->getBaseObject();
1527  if (ComdatKey == GV) {
1528  switch (C->getSelectionKind()) {
1529  case Comdat::Any:
1531  case Comdat::ExactMatch:
1533  case Comdat::Largest:
1535  case Comdat::NoDuplicates:
1537  case Comdat::SameSize:
1539  }
1540  } else {
1542  }
1543  }
1544  return 0;
1545 }
1546 
1548  const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
1549  int Selection = 0;
1550  unsigned Characteristics = getCOFFSectionFlags(Kind, TM);
1551  StringRef Name = GO->getSection();
1552  StringRef COMDATSymName = "";
1553  if (GO->hasComdat()) {
1555  const GlobalValue *ComdatGV;
1557  ComdatGV = getComdatGVForCOFF(GO);
1558  else
1559  ComdatGV = GO;
1560 
1561  if (!ComdatGV->hasPrivateLinkage()) {
1562  MCSymbol *Sym = TM.getSymbol(ComdatGV);
1563  COMDATSymName = Sym->getName();
1565  } else {
1566  Selection = 0;
1567  }
1568  }
1569 
1570  return getContext().getCOFFSection(Name, Characteristics, Kind, COMDATSymName,
1571  Selection);
1572 }
1573 
1575  if (Kind.isText())
1576  return ".text";
1577  if (Kind.isBSS())
1578  return ".bss";
1579  if (Kind.isThreadLocal())
1580  return ".tls$";
1581  if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1582  return ".rdata";
1583  return ".data";
1584 }
1585 
1587  const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
1588  // If we have -ffunction-sections then we should emit the global value to a
1589  // uniqued section specifically for it.
1590  bool EmitUniquedSection;
1591  if (Kind.isText())
1592  EmitUniquedSection = TM.getFunctionSections();
1593  else
1594  EmitUniquedSection = TM.getDataSections();
1595 
1596  if ((EmitUniquedSection && !Kind.isCommon()) || GO->hasComdat()) {
1598 
1599  unsigned Characteristics = getCOFFSectionFlags(Kind, TM);
1600 
1602  int Selection = getSelectionForCOFF(GO);
1603  if (!Selection)
1605  const GlobalValue *ComdatGV;
1606  if (GO->hasComdat())
1607  ComdatGV = getComdatGVForCOFF(GO);
1608  else
1609  ComdatGV = GO;
1610 
1611  unsigned UniqueID = MCContext::GenericSectionID;
1612  if (EmitUniquedSection)
1613  UniqueID = NextUniqueID++;
1614 
1615  if (!ComdatGV->hasPrivateLinkage()) {
1616  MCSymbol *Sym = TM.getSymbol(ComdatGV);
1617  StringRef COMDATSymName = Sym->getName();
1618 
1619  if (const auto *F = dyn_cast<Function>(GO))
1620  if (Optional<StringRef> Prefix = F->getSectionPrefix())
1621  raw_svector_ostream(Name) << '$' << *Prefix;
1622 
1623  // Append "$symbol" to the section name *before* IR-level mangling is
1624  // applied when targetting mingw. This is what GCC does, and the ld.bfd
1625  // COFF linker will not properly handle comdats otherwise.
1626  if (getTargetTriple().isWindowsGNUEnvironment())
1627  raw_svector_ostream(Name) << '$' << ComdatGV->getName();
1628 
1630  COMDATSymName, Selection, UniqueID);
1631  } else {
1632  SmallString<256> TmpData;
1633  getMangler().getNameWithPrefix(TmpData, GO, /*CannotUsePrivateLabel=*/true);
1634  return getContext().getCOFFSection(Name, Characteristics, Kind, TmpData,
1635  Selection, UniqueID);
1636  }
1637  }
1638 
1639  if (Kind.isText())
1640  return TextSection;
1641 
1642  if (Kind.isThreadLocal())
1643  return TLSDataSection;
1644 
1645  if (Kind.isReadOnly() || Kind.isReadOnlyWithRel())
1646  return ReadOnlySection;
1647 
1648  // Note: we claim that common symbols are put in BSSSection, but they are
1649  // really emitted with the magic .comm directive, which creates a symbol table
1650  // entry but not a section.
1651  if (Kind.isBSS() || Kind.isCommon())
1652  return BSSSection;
1653 
1654  return DataSection;
1655 }
1656 
1658  SmallVectorImpl<char> &OutName, const GlobalValue *GV,
1659  const TargetMachine &TM) const {
1660  bool CannotUsePrivateLabel = false;
1661  if (GV->hasPrivateLinkage() &&
1662  ((isa<Function>(GV) && TM.getFunctionSections()) ||
1663  (isa<GlobalVariable>(GV) && TM.getDataSections())))
1664  CannotUsePrivateLabel = true;
1665 
1666  getMangler().getNameWithPrefix(OutName, GV, CannotUsePrivateLabel);
1667 }
1668 
1670  const Function &F, const TargetMachine &TM) const {
1671  // If the function can be removed, produce a unique section so that
1672  // the table doesn't prevent the removal.
1673  const Comdat *C = F.getComdat();
1674  bool EmitUniqueSection = TM.getFunctionSections() || C;
1675  if (!EmitUniqueSection)
1676  return ReadOnlySection;
1677 
1678  // FIXME: we should produce a symbol for F instead.
1679  if (F.hasPrivateLinkage())
1680  return ReadOnlySection;
1681 
1682  MCSymbol *Sym = TM.getSymbol(&F);
1683  StringRef COMDATSymName = Sym->getName();
1684 
1687  unsigned Characteristics = getCOFFSectionFlags(Kind, TM);
1689  unsigned UniqueID = NextUniqueID++;
1690 
1691  return getContext().getCOFFSection(
1692  SecName, Characteristics, Kind, COMDATSymName,
1694 }
1695 
1697  Module &M) const {
1698  emitLinkerDirectives(Streamer, M);
1699 
1700  unsigned Version = 0;
1701  unsigned Flags = 0;
1703 
1704  GetObjCImageInfo(M, Version, Flags, Section);
1705  if (!Section.empty()) {
1706  auto &C = getContext();
1707  auto *S = C.getCOFFSection(Section,
1711  Streamer.SwitchSection(S);
1712  Streamer.emitLabel(C.getOrCreateSymbol(StringRef("OBJC_IMAGE_INFO")));
1713  Streamer.emitInt32(Version);
1714  Streamer.emitInt32(Flags);
1715  Streamer.AddBlankLine();
1716  }
1717 
1718  emitCGProfileMetadata(Streamer, M);
1719 }
1720 
1721 void TargetLoweringObjectFileCOFF::emitLinkerDirectives(
1722  MCStreamer &Streamer, Module &M) const {
1723  if (NamedMDNode *LinkerOptions = M.getNamedMetadata("llvm.linker.options")) {
1724  // Emit the linker options to the linker .drectve section. According to the
1725  // spec, this section is a space-separated string containing flags for
1726  // linker.
1727  MCSection *Sec = getDrectveSection();
1728  Streamer.SwitchSection(Sec);
1729  for (const auto *Option : LinkerOptions->operands()) {
1730  for (const auto &Piece : cast<MDNode>(Option)->operands()) {
1731  // Lead with a space for consistency with our dllexport implementation.
1732  std::string Directive(" ");
1733  Directive.append(std::string(cast<MDString>(Piece)->getString()));
1734  Streamer.emitBytes(Directive);
1735  }
1736  }
1737  }
1738 
1739  // Emit /EXPORT: flags for each exported global as necessary.
1740  std::string Flags;
1741  for (const GlobalValue &GV : M.global_values()) {
1742  raw_string_ostream OS(Flags);
1744  OS.flush();
1745  if (!Flags.empty()) {
1746  Streamer.SwitchSection(getDrectveSection());
1747  Streamer.emitBytes(Flags);
1748  }
1749  Flags.clear();
1750  }
1751 
1752  // Emit /INCLUDE: flags for each used global as necessary.
1753  if (const auto *LU = M.getNamedGlobal("llvm.used")) {
1754  assert(LU->hasInitializer() && "expected llvm.used to have an initializer");
1755  assert(isa<ArrayType>(LU->getValueType()) &&
1756  "expected llvm.used to be an array type");
1757  if (const auto *A = cast<ConstantArray>(LU->getInitializer())) {
1758  for (const Value *Op : A->operands()) {
1759  const auto *GV = cast<GlobalValue>(Op->stripPointerCasts());
1760  // Global symbols with internal or private linkage are not visible to
1761  // the linker, and thus would cause an error when the linker tried to
1762  // preserve the symbol due to the `/include:` directive.
1763  if (GV->hasLocalLinkage())
1764  continue;
1765 
1766  raw_string_ostream OS(Flags);
1768  OS.flush();
1769 
1770  if (!Flags.empty()) {
1771  Streamer.SwitchSection(getDrectveSection());
1772  Streamer.emitBytes(Flags);
1773  }
1774  Flags.clear();
1775  }
1776  }
1777  }
1778 }
1779 
1781  const TargetMachine &TM) {
1783  this->TM = &TM;
1784  const Triple &T = TM.getTargetTriple();
1785  if (T.isWindowsMSVCEnvironment() || T.isWindowsItaniumEnvironment()) {
1794  } else {
1803  }
1804 }
1805 
1807  const Triple &T, bool IsCtor,
1808  unsigned Priority,
1809  const MCSymbol *KeySym,
1810  MCSectionCOFF *Default) {
1811  if (T.isWindowsMSVCEnvironment() || T.isWindowsItaniumEnvironment()) {
1812  // If the priority is the default, use .CRT$XCU, possibly associative.
1813  if (Priority == 65535)
1814  return Ctx.getAssociativeCOFFSection(Default, KeySym, 0);
1815 
1816  // Otherwise, we need to compute a new section name. Low priorities should
1817  // run earlier. The linker will sort sections ASCII-betically, and we need a
1818  // string that sorts between .CRT$XCA and .CRT$XCU. In the general case, we
1819  // make a name like ".CRT$XCT12345", since that runs before .CRT$XCU. Really
1820  // low priorities need to sort before 'L', since the CRT uses that
1821  // internally, so we use ".CRT$XCA00001" for them.
1824  OS << ".CRT$X" << (IsCtor ? "C" : "T") <<
1825  (Priority < 200 ? 'A' : 'T') << format("%05u", Priority);
1826  MCSectionCOFF *Sec = Ctx.getCOFFSection(
1829  return Ctx.getAssociativeCOFFSection(Sec, KeySym, 0);
1830  }
1831 
1832  std::string Name = IsCtor ? ".ctors" : ".dtors";
1833  if (Priority != 65535)
1834  raw_string_ostream(Name) << format(".%05u", 65535 - Priority);
1835 
1836  return Ctx.getAssociativeCOFFSection(
1841  KeySym, 0);
1842 }
1843 
1845  unsigned Priority, const MCSymbol *KeySym) const {
1847  Priority, KeySym,
1848  cast<MCSectionCOFF>(StaticCtorSection));
1849 }
1850 
1852  unsigned Priority, const MCSymbol *KeySym) const {
1854  Priority, KeySym,
1855  cast<MCSectionCOFF>(StaticDtorSection));
1856 }
1857 
1859  const GlobalValue *LHS, const GlobalValue *RHS,
1860  const TargetMachine &TM) const {
1861  const Triple &T = TM.getTargetTriple();
1862  if (T.isOSCygMing())
1863  return nullptr;
1864 
1865  // Our symbols should exist in address space zero, cowardly no-op if
1866  // otherwise.
1867  if (LHS->getType()->getPointerAddressSpace() != 0 ||
1868  RHS->getType()->getPointerAddressSpace() != 0)
1869  return nullptr;
1870 
1871  // Both ptrtoint instructions must wrap global objects:
1872  // - Only global variables are eligible for image relative relocations.
1873  // - The subtrahend refers to the special symbol __ImageBase, a GlobalVariable.
1874  // We expect __ImageBase to be a global variable without a section, externally
1875  // defined.
1876  //
1877  // It should look something like this: @__ImageBase = external constant i8
1878  if (!isa<GlobalObject>(LHS) || !isa<GlobalVariable>(RHS) ||
1879  LHS->isThreadLocal() || RHS->isThreadLocal() ||
1880  RHS->getName() != "__ImageBase" || !RHS->hasExternalLinkage() ||
1881  cast<GlobalVariable>(RHS)->hasInitializer() || RHS->hasSection())
1882  return nullptr;
1883 
1884  return MCSymbolRefExpr::create(TM.getSymbol(LHS),
1886  getContext());
1887 }
1888 
1889 static std::string APIntToHexString(const APInt &AI) {
1890  unsigned Width = (AI.getBitWidth() / 8) * 2;
1891  std::string HexString = AI.toString(16, /*Signed=*/false);
1892  llvm::transform(HexString, HexString.begin(), tolower);
1893  unsigned Size = HexString.size();
1894  assert(Width >= Size && "hex string is too large!");
1895  HexString.insert(HexString.begin(), Width - Size, '0');
1896 
1897  return HexString;
1898 }
1899 
1900 static std::string scalarConstantToHexString(const Constant *C) {
1901  Type *Ty = C->getType();
1902  if (isa<UndefValue>(C)) {
1904  } else if (const auto *CFP = dyn_cast<ConstantFP>(C)) {
1905  return APIntToHexString(CFP->getValueAPF().bitcastToAPInt());
1906  } else if (const auto *CI = dyn_cast<ConstantInt>(C)) {
1907  return APIntToHexString(CI->getValue());
1908  } else {
1909  unsigned NumElements;
1910  if (auto *VTy = dyn_cast<VectorType>(Ty))
1911  NumElements = cast<FixedVectorType>(VTy)->getNumElements();
1912  else
1913  NumElements = Ty->getArrayNumElements();
1914  std::string HexString;
1915  for (int I = NumElements - 1, E = -1; I != E; --I)
1916  HexString += scalarConstantToHexString(C->getAggregateElement(I));
1917  return HexString;
1918  }
1919 }
1920 
1922  const DataLayout &DL, SectionKind Kind, const Constant *C,
1923  Align &Alignment) const {
1924  if (Kind.isMergeableConst() && C &&
1925  getContext().getAsmInfo()->hasCOFFComdatConstants()) {
1926  // This creates comdat sections with the given symbol name, but unless
1927  // AsmPrinter::GetCPISymbol actually makes the symbol global, the symbol
1928  // will be created with a null storage class, which makes GNU binutils
1929  // error out.
1933  std::string COMDATSymName;
1934  if (Kind.isMergeableConst4()) {
1935  if (Alignment <= 4) {
1936  COMDATSymName = "__real@" + scalarConstantToHexString(C);
1937  Alignment = Align(4);
1938  }
1939  } else if (Kind.isMergeableConst8()) {
1940  if (Alignment <= 8) {
1941  COMDATSymName = "__real@" + scalarConstantToHexString(C);
1942  Alignment = Align(8);
1943  }
1944  } else if (Kind.isMergeableConst16()) {
1945  // FIXME: These may not be appropriate for non-x86 architectures.
1946  if (Alignment <= 16) {
1947  COMDATSymName = "__xmm@" + scalarConstantToHexString(C);
1948  Alignment = Align(16);
1949  }
1950  } else if (Kind.isMergeableConst32()) {
1951  if (Alignment <= 32) {
1952  COMDATSymName = "__ymm@" + scalarConstantToHexString(C);
1953  Alignment = Align(32);
1954  }
1955  }
1956 
1957  if (!COMDATSymName.empty())
1958  return getContext().getCOFFSection(".rdata", Characteristics, Kind,
1959  COMDATSymName,
1961  }
1962 
1964  Alignment);
1965 }
1966 
1967 //===----------------------------------------------------------------------===//
1968 // Wasm
1969 //===----------------------------------------------------------------------===//
1970 
1971 static const Comdat *getWasmComdat(const GlobalValue *GV) {
1972  const Comdat *C = GV->getComdat();
1973  if (!C)
1974  return nullptr;
1975 
1976  if (C->getSelectionKind() != Comdat::Any)
1977  report_fatal_error("WebAssembly COMDATs only support "
1978  "SelectionKind::Any, '" + C->getName() + "' cannot be "
1979  "lowered.");
1980 
1981  return C;
1982 }
1983 
1985  const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
1986  // We don't support explict section names for functions in the wasm object
1987  // format. Each function has to be in its own unique section.
1988  if (isa<Function>(GO)) {
1989  return SelectSectionForGlobal(GO, Kind, TM);
1990  }
1991 
1992  StringRef Name = GO->getSection();
1993 
1994  // Certain data sections we treat as named custom sections rather than
1995  // segments within the data section.
1996  // This could be avoided if all data segements (the wasm sense) were
1997  // represented as their own sections (in the llvm sense).
1998  // TODO(sbc): https://github.com/WebAssembly/tool-conventions/issues/138
1999  if (Name == ".llvmcmd" || Name == ".llvmbc")
2001 
2002  StringRef Group = "";
2003  if (const Comdat *C = getWasmComdat(GO)) {
2004  Group = C->getName();
2005  }
2006 
2008  getContext().getWasmSection(Name, Kind, Group,
2010 
2011  return Section;
2012 }
2013 
2015  MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang,
2016  const TargetMachine &TM, bool EmitUniqueSection, unsigned *NextUniqueID) {
2017  StringRef Group = "";
2018  if (const Comdat *C = getWasmComdat(GO)) {
2019  Group = C->getName();
2020  }
2021 
2022  bool UniqueSectionNames = TM.getUniqueSectionNames();
2024 
2025  if (const auto *F = dyn_cast<Function>(GO)) {
2026  const auto &OptionalPrefix = F->getSectionPrefix();
2027  if (OptionalPrefix)
2028  raw_svector_ostream(Name) << '.' << *OptionalPrefix;
2029  }
2030 
2031  if (EmitUniqueSection && UniqueSectionNames) {
2032  Name.push_back('.');
2033  TM.getNameWithPrefix(Name, GO, Mang, true);
2034  }
2035  unsigned UniqueID = MCContext::GenericSectionID;
2036  if (EmitUniqueSection && !UniqueSectionNames) {
2037  UniqueID = *NextUniqueID;
2038  (*NextUniqueID)++;
2039  }
2040 
2041  return Ctx.getWasmSection(Name, Kind, Group, UniqueID);
2042 }
2043 
2045  const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
2046 
2047  if (Kind.isCommon())
2048  report_fatal_error("mergable sections not supported yet on wasm");
2049 
2050  // If we have -ffunction-section or -fdata-section then we should emit the
2051  // global value to a uniqued section specifically for it.
2052  bool EmitUniqueSection = false;
2053  if (Kind.isText())
2054  EmitUniqueSection = TM.getFunctionSections();
2055  else
2056  EmitUniqueSection = TM.getDataSections();
2057  EmitUniqueSection |= GO->hasComdat();
2058 
2060  EmitUniqueSection, &NextUniqueID);
2061 }
2062 
2064  bool UsesLabelDifference, const Function &F) const {
2065  // We can always create relative relocations, so use another section
2066  // that can be marked non-executable.
2067  return false;
2068 }
2069 
2071  const GlobalValue *LHS, const GlobalValue *RHS,
2072  const TargetMachine &TM) const {
2073  // We may only use a PLT-relative relocation to refer to unnamed_addr
2074  // functions.
2075  if (!LHS->hasGlobalUnnamedAddr() || !LHS->getValueType()->isFunctionTy())
2076  return nullptr;
2077 
2078  // Basic sanity checks.
2079  if (LHS->getType()->getPointerAddressSpace() != 0 ||
2080  RHS->getType()->getPointerAddressSpace() != 0 || LHS->isThreadLocal() ||
2081  RHS->isThreadLocal())
2082  return nullptr;
2083 
2084  return MCBinaryExpr::createSub(
2086  getContext()),
2088 }
2089 
2092  getContext().getWasmSection(".init_array", SectionKind::getData());
2093 
2094  // We don't use PersonalityEncoding and LSDAEncoding because we don't emit
2095  // .cfi directives. We use TTypeEncoding to encode typeinfo global variables.
2097 }
2098 
2100  unsigned Priority, const MCSymbol *KeySym) const {
2101  return Priority == UINT16_MAX ?
2103  getContext().getWasmSection(".init_array." + utostr(Priority),
2105 }
2106 
2108  unsigned Priority, const MCSymbol *KeySym) const {
2109  llvm_unreachable("@llvm.global_dtors should have been lowered already");
2110  return nullptr;
2111 }
2112 
2113 //===----------------------------------------------------------------------===//
2114 // XCOFF
2115 //===----------------------------------------------------------------------===//
2117  const MachineFunction *MF) {
2118  if (!MF->getLandingPads().empty())
2119  return true;
2120 
2121  const Function &F = MF->getFunction();
2122  if (!F.hasPersonalityFn() || !F.needsUnwindTableEntry())
2123  return false;
2124 
2125  const Function *Per =
2126  dyn_cast<Function>(F.getPersonalityFn()->stripPointerCasts());
2128  return false;
2129 
2130  return true;
2131 }
2132 
2133 MCSymbol *
2135  return MF->getMMI().getContext().getOrCreateSymbol(
2136  "__ehinfo." + Twine(MF->getFunctionNumber()));
2137 }
2138 
2139 MCSymbol *
2141  const TargetMachine &TM) const {
2142  // We always use a qualname symbol for a GV that represents
2143  // a declaration, a function descriptor, or a common symbol.
2144  // If a GV represents a GlobalVariable and -fdata-sections is enabled, we
2145  // also return a qualname so that a label symbol could be avoided.
2146  // It is inherently ambiguous when the GO represents the address of a
2147  // function, as the GO could either represent a function descriptor or a
2148  // function entry point. We choose to always return a function descriptor
2149  // here.
2150  if (const GlobalObject *GO = dyn_cast<GlobalObject>(GV)) {
2151  if (GO->isDeclarationForLinker())
2152  return cast<MCSectionXCOFF>(getSectionForExternalReference(GO, TM))
2153  ->getQualNameSymbol();
2154 
2155  SectionKind GOKind = getKindForGlobal(GO, TM);
2156  if (GOKind.isText())
2157  return cast<MCSectionXCOFF>(
2158  getSectionForFunctionDescriptor(cast<Function>(GO), TM))
2159  ->getQualNameSymbol();
2160  if ((TM.getDataSections() && !GO->hasSection()) || GO->hasCommonLinkage() ||
2161  GOKind.isBSSLocal() || GOKind.isThreadBSSLocal())
2162  return cast<MCSectionXCOFF>(SectionForGlobal(GO, GOKind, TM))
2163  ->getQualNameSymbol();
2164  }
2165 
2166  // For all other cases, fall back to getSymbol to return the unqualified name.
2167  return nullptr;
2168 }
2169 
2171  const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
2172  if (!GO->hasSection())
2173  report_fatal_error("#pragma clang section is not yet supported");
2174 
2176  XCOFF::StorageMappingClass MappingClass;
2177  if (Kind.isText())
2178  MappingClass = XCOFF::XMC_PR;
2179  else if (Kind.isData() || Kind.isReadOnlyWithRel() || Kind.isBSS())
2180  MappingClass = XCOFF::XMC_RW;
2181  else if (Kind.isReadOnly())
2182  MappingClass = XCOFF::XMC_RO;
2183  else
2184  report_fatal_error("XCOFF other section types not yet implemented.");
2185 
2186  return getContext().getXCOFFSection(
2188  /* MultiSymbolsAllowed*/ true);
2189 }
2190 
2192  const GlobalObject *GO, const TargetMachine &TM) const {
2194  "Tried to get ER section for a defined global.");
2195 
2197  getNameWithPrefix(Name, GO, TM);
2198 
2200  isa<Function>(GO) ? XCOFF::XMC_DS : XCOFF::XMC_UA;
2201  if (GO->isThreadLocal())
2202  SMC = XCOFF::XMC_UL;
2203 
2204  // Externals go into a csect of type ER.
2205  return getContext().getXCOFFSection(
2208 }
2209 
2211  const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
2212  // Common symbols go into a csect with matching name which will get mapped
2213  // into the .bss section.
2214  // Zero-initialized local TLS symbols go into a csect with matching name which
2215  // will get mapped into the .tbss section.
2216  if (Kind.isBSSLocal() || GO->hasCommonLinkage() || Kind.isThreadBSSLocal()) {
2218  getNameWithPrefix(Name, GO, TM);
2219  XCOFF::StorageMappingClass SMC = Kind.isBSSLocal() ? XCOFF::XMC_BS
2220  : Kind.isCommon() ? XCOFF::XMC_RW
2221  : XCOFF::XMC_UL;
2222  return getContext().getXCOFFSection(
2224  }
2225 
2226  if (Kind.isMergeableCString()) {
2227  Align Alignment = GO->getParent()->getDataLayout().getPreferredAlign(
2228  cast<GlobalVariable>(GO));
2229 
2230  unsigned EntrySize = getEntrySizeForKind(Kind);
2231  std::string SizeSpec = ".rodata.str" + utostr(EntrySize) + ".";
2233  Name = SizeSpec + utostr(Alignment.value());
2234 
2235  if (TM.getDataSections())
2236  getNameWithPrefix(Name, GO, TM);
2237 
2238  return getContext().getXCOFFSection(
2240  /* MultiSymbolsAllowed*/ !TM.getDataSections());
2241  }
2242 
2243  if (Kind.isText()) {
2244  if (TM.getFunctionSections()) {
2245  return cast<MCSymbolXCOFF>(getFunctionEntryPointSymbol(GO, TM))
2246  ->getRepresentedCsect();
2247  }
2248  return TextSection;
2249  }
2250 
2251  // TODO: We may put Kind.isReadOnlyWithRel() under option control, because
2252  // user may want to have read-only data with relocations placed into a
2253  // read-only section by the compiler.
2254  // For BSS kind, zero initialized data must be emitted to the .data section
2255  // because external linkage control sections that get mapped to the .bss
2256  // section will be linked as tentative defintions, which is only appropriate
2257  // for SectionKind::Common.
2258  if (Kind.isData() || Kind.isReadOnlyWithRel() || Kind.isBSS()) {
2259  if (TM.getDataSections()) {
2261  getNameWithPrefix(Name, GO, TM);
2262  return getContext().getXCOFFSection(
2265  }
2266  return DataSection;
2267  }
2268 
2269  if (Kind.isReadOnly()) {
2270  if (TM.getDataSections()) {
2272  getNameWithPrefix(Name, GO, TM);
2273  return getContext().getXCOFFSection(
2276  }
2277  return ReadOnlySection;
2278  }
2279 
2280  // External/weak TLS data and initialized local TLS data are not eligible
2281  // to be put into common csect. If data sections are enabled, thread
2282  // data are emitted into separate sections. Otherwise, thread data
2283  // are emitted into the .tdata section.
2284  if (Kind.isThreadLocal()) {
2285  if (TM.getDataSections()) {
2287  getNameWithPrefix(Name, GO, TM);
2288  return getContext().getXCOFFSection(
2290  }
2291  return TLSDataSection;
2292  }
2293 
2294  report_fatal_error("XCOFF other section types not yet implemented.");
2295 }
2296 
2298  const Function &F, const TargetMachine &TM) const {
2299  assert (!F.getComdat() && "Comdat not supported on XCOFF.");
2300 
2301  if (!TM.getFunctionSections())
2302  return ReadOnlySection;
2303 
2304  // If the function can be removed, produce a unique section so that
2305  // the table doesn't prevent the removal.
2306  SmallString<128> NameStr(".rodata.jmp..");
2307  getNameWithPrefix(NameStr, &F, TM);
2308  return getContext().getXCOFFSection(
2309  NameStr, SectionKind::getReadOnly(),
2311 }
2312 
2314  bool UsesLabelDifference, const Function &F) const {
2315  return false;
2316 }
2317 
2318 /// Given a mergeable constant with the specified size and relocation
2319 /// information, return a section that it should be placed in.
2321  const DataLayout &DL, SectionKind Kind, const Constant *C,
2322  Align &Alignment) const {
2323  //TODO: Enable emiting constant pool to unique sections when we support it.
2324  return ReadOnlySection;
2325 }
2326 
2328  const TargetMachine &TgtM) {
2330  TTypeEncoding =
2334  PersonalityEncoding = 0;
2335  LSDAEncoding = 0;
2337 }
2338 
2340  unsigned Priority, const MCSymbol *KeySym) const {
2341  report_fatal_error("no static constructor section on AIX");
2342 }
2343 
2345  unsigned Priority, const MCSymbol *KeySym) const {
2346  report_fatal_error("no static destructor section on AIX");
2347 }
2348 
2350  const GlobalValue *LHS, const GlobalValue *RHS,
2351  const TargetMachine &TM) const {
2352  report_fatal_error("XCOFF not yet implemented.");
2353 }
2354 
2357  assert(!isa<GlobalIFunc>(GV) && "GlobalIFunc is not supported on AIX.");
2358 
2359  switch (GV->getLinkage()) {
2362  return XCOFF::C_HIDEXT;
2366  return XCOFF::C_EXT;
2372  return XCOFF::C_WEAKEXT;
2375  "There is no mapping that implements AppendingLinkage for XCOFF.");
2376  }
2377  llvm_unreachable("Unknown linkage type!");
2378 }
2379 
2381  const GlobalValue *Func, const TargetMachine &TM) const {
2382  assert(
2383  (isa<Function>(Func) ||
2384  (isa<GlobalAlias>(Func) &&
2385  isa_and_nonnull<Function>(cast<GlobalAlias>(Func)->getBaseObject()))) &&
2386  "Func must be a function or an alias which has a function as base "
2387  "object.");
2388 
2389  SmallString<128> NameStr;
2390  NameStr.push_back('.');
2391  getNameWithPrefix(NameStr, Func, TM);
2392 
2393  // When -function-sections is enabled and explicit section is not specified,
2394  // it's not necessary to emit function entry point label any more. We will use
2395  // function entry point csect instead. And for function delcarations, the
2396  // undefined symbols gets treated as csect with XTY_ER property.
2397  if (((TM.getFunctionSections() && !Func->hasSection()) ||
2398  Func->isDeclaration()) &&
2399  isa<Function>(Func)) {
2400  return getContext()
2401  .getXCOFFSection(
2402  NameStr, SectionKind::getText(),
2403  XCOFF::CsectProperties(XCOFF::XMC_PR, Func->isDeclaration()
2404  ? XCOFF::XTY_ER
2405  : XCOFF::XTY_SD))
2406  ->getQualNameSymbol();
2407  }
2408 
2409  return getContext().getOrCreateSymbol(NameStr);
2410 }
2411 
2413  const Function *F, const TargetMachine &TM) const {
2414  SmallString<128> NameStr;
2415  getNameWithPrefix(NameStr, F, TM);
2416  return getContext().getXCOFFSection(
2417  NameStr, SectionKind::getData(),
2419 }
2420 
2422  const MCSymbol *Sym, const TargetMachine &TM) const {
2423  // Use TE storage-mapping class when large code model is enabled so that
2424  // the chance of needing -bbigtoc is decreased.
2425  return getContext().getXCOFFSection(
2426  cast<MCSymbolXCOFF>(Sym)->getSymbolTableName(), SectionKind::getData(),
2429  XCOFF::XTY_SD));
2430 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::MCObjectFileInfo::TextCoalSection
MCSection * TextCoalSection
Definition: MCObjectFileInfo.h:202
llvm::SectionKind::isText
bool isText() const
Definition: SectionKind.h:121
llvm::EngineKind::Kind
Kind
Definition: ExecutionEngine.h:524
llvm::MCObjectFileInfo::ConstTextCoalSection
MCSection * ConstTextCoalSection
Definition: MCObjectFileInfo.h:203
llvm::Triple::riscv64
@ riscv64
Definition: Triple.h:74
llvm::TargetLoweringObjectFile::StaticDtorSection
MCSection * StaticDtorSection
This section contains the static destructor pointer list.
Definition: TargetLoweringObjectFile.h:64
llvm::SectionKind::isWriteable
bool isWriteable() const
Definition: SectionKind.h:147
llvm::COFF::IMAGE_COMDAT_SELECT_EXACT_MATCH
@ IMAGE_COMDAT_SELECT_EXACT_MATCH
Definition: COFF.h:410
llvm::TargetLoweringObjectFileELF::getSectionForLSDA
MCSection * getSectionForLSDA(const Function &F, const MCSymbol &FnSym, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:882
llvm::DK_Lowering
@ DK_Lowering
Definition: DiagnosticInfo.h:60
MachineModuleInfoImpls.h
Attrs
Function Attrs
Definition: README_ALTIVEC.txt:215
llvm::XCOFF::XTY_ER
@ XTY_ER
External reference.
Definition: XCOFF.h:176
llvm::SectionKind::isThreadLocal
bool isThreadLocal() const
Definition: SectionKind.h:151
llvm
Definition: AllocatorList.h:23
getCOFFStaticStructorSection
static MCSectionCOFF * getCOFFStaticStructorSection(MCContext &Ctx, const Triple &T, bool IsCtor, unsigned Priority, const MCSymbol *KeySym, MCSectionCOFF *Default)
Definition: TargetLoweringObjectFileImpl.cpp:1806
llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA
@ IMAGE_SCN_CNT_UNINITIALIZED_DATA
Definition: COFF.h:290
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::dwarf::DW_EH_PE_sdata4
@ DW_EH_PE_sdata4
Definition: Dwarf.h:440
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:156
llvm::Triple::GNUILP32
@ GNUILP32
Definition: Triple.h:213
Comdat.h
selectELFSectionForGlobal
static MCSectionELF * selectELFSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool EmitUniqueSection, unsigned Flags, unsigned *NextUniqueID, const MCSymbolELF *AssociatedSymbol)
Definition: TargetLoweringObjectFileImpl.cpp:780
llvm::SystemZISD::TM
@ TM
Definition: SystemZISelLowering.h:65
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1386
llvm::SectionKind::getMetadata
static SectionKind getMetadata()
Definition: SectionKind.h:182
llvm::MCContext::GenericSectionID
@ GenericSectionID
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
Definition: MCContext.h:504
llvm::GlobalValue::hasCommonLinkage
bool hasCommonLinkage() const
Definition: GlobalValue.h:449
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::TargetLoweringObjectFileELF::TargetLoweringObjectFileELF
TargetLoweringObjectFileELF()
Definition: TargetLoweringObjectFileImpl.cpp:109
llvm::ELF::SHF_MERGE
@ SHF_MERGE
Definition: ELF.h:987
llvm::MCObjectFileInfo::EightByteConstantSection
MCSection * EightByteConstantSection
Definition: MCObjectFileInfo.h:210
llvm::TargetLoweringObjectFileELF::SelectSectionForGlobal
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:839
llvm::Comdat::NoDuplicates
@ NoDuplicates
No other Module may specify this COMDAT.
Definition: Comdat.h:37
llvm::GlobalValue::LinkOnceAnyLinkage
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
Definition: GlobalValue.h:50
print
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
Definition: ArchiveWriter.cpp:147
Metadata.h
llvm::TargetLoweringObjectFileMachO::getIndirectSymViaGOTPCRel
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:1361
llvm::TargetLoweringObjectFile::getNameWithPrefix
virtual void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const
Definition: TargetLoweringObjectFile.cpp:433
llvm::DataLayout::getPreferredAlign
Align getPreferredAlign(const GlobalVariable *GV) const
Returns the preferred alignment of the specified global.
Definition: DataLayout.cpp:905
llvm::Comdat::ExactMatch
@ ExactMatch
The data referenced by the COMDAT must be the same.
Definition: Comdat.h:35
llvm::MachineModuleInfo::getContext
const MCContext & getContext() const
Definition: MachineModuleInfo.h:167
llvm::GlobalValue::hasExternalLinkage
bool hasExternalLinkage() const
Definition: GlobalValue.h:431
llvm::BBSectionsColdTextPrefix
cl::opt< std::string > BBSectionsColdTextPrefix
llvm::TargetMachine::getUniqueBasicBlockSectionNames
bool getUniqueBasicBlockSectionNames() const
Return true if unique basic block section names must be generated.
Definition: TargetMachine.h:264
llvm::MCObjectFileInfo::MergeableConst16Section
MCSection * MergeableConst16Section
Definition: MCObjectFileInfo.h:185
llvm::MCAsmInfo::useIntegratedAssembler
bool useIntegratedAssembler() const
Return true if assembly (inline or otherwise) should be parsed.
Definition: MCAsmInfo.h:722
llvm::MCObjectFileInfo::ReadOnlySection
MCSection * ReadOnlySection
Section that is readonly and can contain arbitrary initialized data.
Definition: MCObjectFileInfo.h:67
llvm::TargetLoweringObjectFileXCOFF::getSectionForTOCEntry
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:2421
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:161
getELFSectionType
static unsigned getELFSectionType(StringRef Name, SectionKind K)
Definition: TargetLoweringObjectFileImpl.cpp:479
llvm::GlobalValue::getLinkage
LinkageTypes getLinkage() const
Definition: GlobalValue.h:461
llvm::COFF::IMAGE_COMDAT_SELECT_NODUPLICATES
@ IMAGE_COMDAT_SELECT_NODUPLICATES
Definition: COFF.h:407
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:71
getELFSectionNameForGlobal
static SmallString< 128 > getELFSectionNameForGlobal(const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, unsigned EntrySize, bool UniqueSectionName)
Definition: TargetLoweringObjectFileImpl.cpp:605
llvm::Function
Definition: Function.h:61
llvm::SectionKind::isReadOnly
bool isReadOnly() const
Definition: SectionKind.h:125
llvm::TargetLoweringObjectFileELF::getStaticCtorSection
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition: TargetLoweringObjectFileImpl.cpp:1021
llvm::MCStreamer::emitELFSize
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
Definition: MCStreamer.cpp:1163
StringRef.h
llvm::SectionKind::isBSS
bool isBSS() const
Definition: SectionKind.h:163
llvm::TargetLoweringObjectFileELF::emitModuleMetadata
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit Obj-C garbage collection and linker options.
Definition: TargetLoweringObjectFileImpl.cpp:304
llvm::ELF::SHT_NOTE
@ SHT_NOTE
Definition: ELF.h:909
llvm::MCSA_ELF_TypeObject
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
Definition: MCDirectives.h:25
llvm::SectionKind::isThreadBSS
bool isThreadBSS() const
Definition: SectionKind.h:155
llvm::MCStreamer::emitInt64
void emitInt64(uint64_t Value)
Definition: MCStreamer.h:703
llvm::Triple::x86
@ x86
Definition: Triple.h:83
llvm::XCOFF::XMC_TE
@ XMC_TE
Symbol mapped at the end of TOC.
Definition: XCOFF.h:63
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:614
llvm::TargetLoweringObjectFile::getSymbolWithGlobalValueBase
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...
Definition: TargetLoweringObjectFile.cpp:129
llvm::GlobalObject::getSection
StringRef getSection() const
Get the custom section of this global if it has one.
Definition: GlobalObject.h:114
llvm::MCConstantExpr::create
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:194
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
llvm::toString
std::string toString(Error E)
Write all error messages (if any) in E to a string.
Definition: Error.h:991
llvm::TargetLoweringObjectFileELF::getExplicitSectionGlobal
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:655
llvm::CodeModel::Medium
@ Medium
Definition: CodeGen.h:28
MCSectionELF.h
llvm::MCStreamer::emitInt8
void emitInt8(uint64_t Value)
Definition: MCStreamer.h:700
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::MCObjectFileInfo::SixteenByteConstantSection
MCSection * SixteenByteConstantSection
Definition: MCObjectFileInfo.h:211
llvm::MCObjectFileInfo::FourByteConstantSection
MCSection * FourByteConstantSection
Definition: MCObjectFileInfo.h:209
llvm::COFF::IMAGE_SCN_MEM_DISCARDABLE
@ IMAGE_SCN_MEM_DISCARDABLE
Definition: COFF.h:316
llvm::TargetLoweringObjectFileMachO::SelectSectionForGlobal
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:1226
llvm::TargetLoweringObjectFileWasm::getExplicitSectionGlobal
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:1984
ErrorHandling.h
llvm::ELF::SHF_LINK_ORDER
@ SHF_LINK_ORDER
Definition: ELF.h:996
llvm::Type::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition: DerivedTypes.h:693
MCSectionCOFF.h
llvm::TargetLoweringObjectFile::SectionForGlobal
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...
Definition: TargetLoweringObjectFile.cpp:316
llvm::GlobalVariable
Definition: GlobalVariable.h:40
llvm::GlobalObject::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1191
llvm::TargetLoweringObjectFileMachO::TargetLoweringObjectFileMachO
TargetLoweringObjectFileMachO()
Definition: TargetLoweringObjectFileImpl.cpp:1098
llvm::XCOFF::XMC_PR
@ XMC_PR
Program Code.
Definition: XCOFF.h:40
llvm::ELF::SHF_ALLOC
@ SHF_ALLOC
Definition: ELF.h:981
llvm::dwarf::DW_EH_PE_sdata8
@ DW_EH_PE_sdata8
Definition: Dwarf.h:441
llvm::MachineFunction::getFunctionNumber
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
Definition: MachineFunction.h:530
checkMachOComdat
static void checkMachOComdat(const GlobalValue *GV)
Definition: TargetLoweringObjectFileImpl.cpp:1170
llvm::MCObjectFileInfo::DataBSSSection
MCSection * DataBSSSection
Definition: MCObjectFileInfo.h:208
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
MachineBasicBlock.h
COFF.h
llvm::TargetLoweringObjectFileELF::InitializeELF
void InitializeELF(bool UseInitArray_)
Definition: TargetLoweringObjectFileImpl.cpp:1076
llvm::ELF::SHT_PROGBITS
@ SHT_PROGBITS
Definition: ELF.h:903
llvm::MachineModuleInfoImpl::StubValueTy
PointerIntPair< MCSymbol *, 1, bool > StubValueTy
Definition: MachineModuleInfo.h:62
llvm::XCOFF::XMC_UA
@ XMC_UA
Unclassified - Treated as Read Write.
Definition: XCOFF.h:57
llvm::TargetLoweringObjectFileXCOFF::getSectionForJumpTable
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:2297
llvm::TargetLoweringObjectFileXCOFF::getEHInfoTableSymbol
static MCSymbol * getEHInfoTableSymbol(const MachineFunction *MF)
Definition: TargetLoweringObjectFileImpl.cpp:2134
llvm::TargetMachine::getRelocationModel
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
Definition: TargetMachine.cpp:70
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
llvm::APInt::getBitWidth
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition: APInt.h:1582
Module.h
llvm::Triple::x86_64
@ x86_64
Definition: Triple.h:84
llvm::MCStreamer::emitInt32
void emitInt32(uint64_t Value)
Definition: MCStreamer.h:702
llvm::XCOFF::XMC_TC
@ XMC_TC
General TOC item.
Definition: XCOFF.h:54
llvm::TargetMachine::getUniqueSectionNames
bool getUniqueSectionNames() const
Definition: TargetMachine.h:261
llvm::GlobalValue::hasSection
bool hasSection() const
Definition: GlobalValue.h:267
llvm::Triple::ppc
@ ppc
Definition: Triple.h:67
llvm::SectionKind::isMergeableConst
bool isMergeableConst() const
Definition: SectionKind.h:138
llvm::ExceptionHandling::ARM
@ ARM
ARM EHABI.
llvm::COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE
@ IMAGE_COMDAT_SELECT_ASSOCIATIVE
Definition: COFF.h:411
llvm::Optional
Definition: APInt.h:34
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::Triple::hexagon
@ hexagon
Definition: Triple.h:60
llvm::MCStreamer::AddBlankLine
virtual void AddBlankLine()
AddBlankLine - Emit a blank line to a .s file to pretty it up.
Definition: MCStreamer.h:361
GlobalObject.h
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::Comdat::Largest
@ Largest
The linker will choose the largest COMDAT.
Definition: Comdat.h:36
llvm::MCObjectFileInfo::ConstDataCoalSection
MCSection * ConstDataCoalSection
Definition: MCObjectFileInfo.h:206
llvm::MCStreamer::emitLinkerOptions
virtual void emitLinkerOptions(ArrayRef< std::string > Kind)
Emit the given list Options of strings as linker options into the output.
Definition: MCStreamer.h:481
llvm::MachineModuleInfoMachO::getGVStubEntry
StubValueTy & getGVStubEntry(MCSymbol *Sym)
Definition: MachineModuleInfoImpls.h:43
llvm::TargetLoweringObjectFile::StaticCtorSection
MCSection * StaticCtorSection
This section contains the static constructor pointer list.
Definition: TargetLoweringObjectFile.h:61
llvm::TargetLoweringObjectFileXCOFF::getSectionForExternalReference
MCSection * getSectionForExternalReference(const GlobalObject *GO, const TargetMachine &TM) const override
For external functions, this will always return a function descriptor csect.
Definition: TargetLoweringObjectFileImpl.cpp:2191
llvm::MCSectionELF
This represents a section on linux, lots of unix variants and some bare metal systems.
Definition: MCSectionELF.h:28
llvm::Mangler
Definition: Mangler.h:27
llvm::Triple::aarch64_32
@ aarch64_32
Definition: Triple.h:54
llvm::TargetLoweringObjectFileMachO::getTTypeGlobalReference
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:1313
llvm::TargetLoweringObjectFileXCOFF::ShouldEmitEHBlock
static bool ShouldEmitEHBlock(const MachineFunction *MF)
Definition: TargetLoweringObjectFileImpl.cpp:2116
Format.h
llvm::MCObjectFileInfo::getContext
MCContext & getContext() const
Definition: MCObjectFileInfo.h:232
getELFKindForNamedSection
static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K)
Definition: TargetLoweringObjectFileImpl.cpp:436
llvm::Triple::mips64
@ mips64
Definition: Triple.h:64
llvm::TargetLoweringObjectFileELF::getSectionForJumpTable
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:867
llvm::MachO::S_MOD_TERM_FUNC_POINTERS
@ S_MOD_TERM_FUNC_POINTERS
S_MOD_TERM_FUNC_POINTERS - Section with only function pointers for termination.
Definition: MachO.h:148
llvm::TargetLoweringObjectFile::CallSiteEncoding
unsigned CallSiteEncoding
Definition: TargetLoweringObjectFile.h:58
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::collectUsedGlobalVariables
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 ...
Definition: Module.cpp:711
llvm::XCOFF::CsectProperties
Definition: XCOFF.h:409
llvm::MCContext::getMachOSection
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.
Definition: MCContext.cpp:385
llvm::MachineBasicBlock::isBeginSection
bool isBeginSection() const
Returns true if this block begins any section.
Definition: MachineBasicBlock.h:473
llvm::MCSymbolELF
Definition: MCSymbolELF.h:14
llvm::TargetLoweringObjectFile
Definition: TargetLoweringObjectFile.h:43
llvm::TargetLoweringObjectFileCOFF::getNameWithPrefix
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:1657
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::classifyEHPersonality
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
Definition: EHPersonalities.cpp:21
llvm::TargetLoweringObjectFileXCOFF::Initialize
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Definition: TargetLoweringObjectFileImpl.cpp:2327
llvm::SectionKind::getReadOnly
static SectionKind getReadOnly()
Definition: SectionKind.h:185
llvm::MachineBasicBlock::getSymbol
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Definition: MachineBasicBlock.cpp:59
llvm::TargetLoweringObjectFileXCOFF::getStaticCtorSection
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition: TargetLoweringObjectFileImpl.cpp:2339
getELFSectionFlags
static unsigned getELFSectionFlags(SectionKind K)
Definition: TargetLoweringObjectFileImpl.cpp:501
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:197
llvm::MCObjectFileInfo::LSDASection
MCSection * LSDASection
If exception handling is supported by the target, this is the section the Language Specific Data Area...
Definition: MCObjectFileInfo.h:71
llvm::TargetLoweringObjectFileMachO::getSectionForConstant
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:1296
llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA
@ IMAGE_SCN_CNT_INITIALIZED_DATA
Definition: COFF.h:289
llvm::Triple::sparc
@ sparc
Definition: Triple.h:75
llvm::MCContext::getOrCreateSymbol
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:157
llvm::TargetLoweringObjectFileELF::shouldPutJumpTableInFunctionSection
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
Definition: TargetLoweringObjectFileImpl.cpp:915
GlobalValue.h
llvm::Triple::sparcv9
@ sparcv9
Definition: Triple.h:76
llvm::SectionKind::getThreadBSS
static SectionKind getThreadBSS()
Definition: SectionKind.h:199
llvm::Triple::sparcel
@ sparcel
Definition: Triple.h:77
ELF.h
llvm::TargetLoweringObjectFileXCOFF::getExplicitSectionGlobal
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:2170
TargetMachine.h
llvm::XCOFF::XMC_RO
@ XMC_RO
Read Only Constant.
Definition: XCOFF.h:41
llvm::dwarf::DW_EH_PE_indirect
@ DW_EH_PE_indirect
Definition: Dwarf.h:448
Constants.h
llvm::ELF::SHF_TLS
@ SHF_TLS
Definition: ELF.h:1006
llvm::COFF::IMAGE_COMDAT_SELECT_SAME_SIZE
@ IMAGE_COMDAT_SELECT_SAME_SIZE
Definition: COFF.h:409
llvm::TargetLoweringObjectFileELF::PLTRelativeVariantKind
MCSymbolRefExpr::VariantKind PLTRelativeVariantKind
Definition: TargetLoweringObjectFileImpl.h:39
SmallString.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::TargetLoweringObjectFileWasm::InitializeWasm
void InitializeWasm()
Definition: TargetLoweringObjectFileImpl.cpp:2090
llvm::MCSectionWasm
This represents a section on wasm.
Definition: MCSectionWasm.h:26
llvm::TargetLoweringObjectFileWasm::getStaticCtorSection
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition: TargetLoweringObjectFileImpl.cpp:2099
llvm::TargetOptions::UseInitArray
unsigned UseInitArray
UseInitArray - Use .init_array instead of .ctors for static constructors.
Definition: TargetOptions.h:236
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::TargetLoweringObjectFileELF::lowerRelativeReference
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:1033
scalarConstantToHexString
static std::string scalarConstantToHexString(const Constant *C)
Definition: TargetLoweringObjectFileImpl.cpp:1900
llvm::ARM_PROC::A
@ A
Definition: ARMBaseInfo.h:34
llvm::MCObjectFileInfo::MergeableConst8Section
MCSection * MergeableConst8Section
Definition: MCObjectFileInfo.h:184
llvm::Triple::mips64el
@ mips64el
Definition: Triple.h:65
llvm::ELF::SHT_FINI_ARRAY
@ SHT_FINI_ARRAY
Definition: ELF.h:915
llvm::TargetMachine::getFunctionSections
bool getFunctionSections() const
Return true if functions should be emitted into their own section, corresponding to -ffunction-sectio...
Definition: TargetMachine.h:276
llvm::GlobalObject
Definition: GlobalObject.h:30
MCSymbolELF.h
MCContext.h
llvm::MCSectionMachO::ParseSectionSpecifier
static Error ParseSectionSpecifier(StringRef Spec, StringRef &Segment, StringRef &Section, unsigned &TAA, bool &TAAParsed, unsigned &StubSize)
Parse the section specifier indicated by "Spec".
Definition: MCSectionMachO.cpp:177
llvm::COFF::IMAGE_SCN_MEM_READ
@ IMAGE_SCN_MEM_READ
Definition: COFF.h:321
MCSectionMachO.h
llvm::MCStreamer::emitLabel
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:414
MCSymbol.h
llvm::TargetLoweringObjectFileXCOFF::getStaticDtorSection
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition: TargetLoweringObjectFileImpl.cpp:2344
llvm::MCStreamer::emitSymbolValue
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.
Definition: MCStreamer.cpp:180
llvm::MCObjectFileInfo::isPositionIndependent
bool isPositionIndependent() const
Definition: MCObjectFileInfo.h:422
llvm::GlobalValue::hasPrivateLinkage
bool hasPrivateLinkage() const
Definition: GlobalValue.h:444
llvm::MCContext::getELFSection
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:521
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:481
llvm::PseudoProbeDescMetadataName
constexpr const char * PseudoProbeDescMetadataName
Definition: PseudoProbe.h:26
llvm::SectionKind::getBSS
static SectionKind getBSS()
Definition: SectionKind.h:202
llvm::Comdat::Any
@ Any
The linker may choose any COMDAT.
Definition: Comdat.h:34
llvm::Mangler::getNameWithPrefix
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
Definition: Mangler.cpp:114
llvm::CodeModel::Small
@ Small
Definition: CodeGen.h:28
llvm::Triple::ppc64
@ ppc64
Definition: Triple.h:69
llvm::TargetLoweringObjectFileELF::getModuleMetadata
void getModuleMetadata(Module &M) override
Get the module-level metadata that the platform cares about.
Definition: TargetLoweringObjectFileImpl.cpp:296
GetObjCImageInfo
static void GetObjCImageInfo(Module &M, unsigned &Version, unsigned &Flags, StringRef &Section)
Definition: TargetLoweringObjectFileImpl.cpp:71
llvm::MachineModuleInfo
This class contains meta information specific to a module.
Definition: MachineModuleInfo.h:78
llvm::DiagnosticSeverity
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
Definition: DiagnosticInfo.h:44
llvm::TargetLoweringObjectFileMachO::getNameWithPrefix
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:1451
InstrProf.h
llvm::isNoOpWithoutInvoke
bool isNoOpWithoutInvoke(EHPersonality Pers)
Return true if this personality may be safely removed if there are no invoke instructions remaining i...
Definition: EHPersonalities.h:96
llvm::report_fatal_error
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
llvm::MCContext::getXCOFFSection
MCSectionXCOFF * getXCOFFSection(StringRef Section, SectionKind K, Optional< XCOFF::CsectProperties > CsectProp=None, bool MultiSymbolsAllowed=false, const char *BeginSymName=nullptr, Optional< XCOFF::DwarfSectionSubtypeFlags > DwarfSubtypeFlags=None)
Definition: MCContext.cpp:689
llvm::TargetLoweringObjectFileXCOFF::SelectSectionForGlobal
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:2210
llvm::TargetLoweringObjectFile::emitCGProfileMetadata
void emitCGProfileMetadata(MCStreamer &Streamer, Module &M) const
Emit Call Graph Profile metadata.
Definition: TargetLoweringObjectFile.cpp:151
llvm::MCSymbolRefExpr::getSymbol
const MCSymbol & getSymbol() const
Definition: MCExpr.h:395
llvm::MCValue::getConstant
int64_t getConstant() const
Definition: MCValue.h:44
llvm::TargetLoweringObjectFile::Initialize
virtual void Initialize(MCContext &ctx, const TargetMachine &TM)
This method must be called before any actual lowering is done.
Definition: TargetLoweringObjectFile.cpp:42
llvm::Comdat::SameSize
@ SameSize
The data referenced by the COMDAT must be the same size.
Definition: Comdat.h:38
llvm::ELF::SHT_NOBITS
@ SHT_NOBITS
Definition: ELF.h:910
llvm::MCSA_Hidden
@ MCSA_Hidden
.hidden (ELF)
Definition: MCDirectives.h:33
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:991
llvm::Triple::lanai
@ lanai
Definition: Triple.h:98
llvm::MCSymbol::getName
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:197
isThumb
static bool isThumb(const MCSubtargetInfo &STI)
Definition: ARMAsmPrinter.cpp:470
llvm::DiagnosticInfo
This is the base abstract class for diagnostic reporting in the backend.
Definition: DiagnosticInfo.h:101
llvm::TargetMachine::getSymbol
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: TargetMachine.cpp:219
llvm::GlobalValue::hasGlobalUnnamedAddr
bool hasGlobalUnnamedAddr() const
Definition: GlobalValue.h:196
llvm::ELF::SHF_EXECINSTR
@ SHF_EXECINSTR
Definition: ELF.h:984
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::SectionKind::getText
static SectionKind getText()
Definition: SectionKind.h:183
llvm::XCOFF::XTY_SD
@ XTY_SD
Csect definition for initialized storage.
Definition: XCOFF.h:177
llvm::DiagnosticPrinter
Interface for custom diagnostic printing.
Definition: DiagnosticPrinter.h:31
llvm::GlobalValue::InternalLinkage
@ InternalLinkage
Rename collisions when linking (static functions).
Definition: GlobalValue.h:55
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::Comdat
Definition: Comdat.h:31
llvm::TargetLoweringObjectFileXCOFF::getSectionForConstant
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:2320
llvm::Triple::getArch
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:307
llvm::MCObjectFileInfo::TLSDataSection
MCSection * TLSDataSection
Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
Definition: MCObjectFileInfo.h:153
llvm::Type::isFunctionTy
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:220
llvm::TargetLoweringObjectFileXCOFF::getSectionForFunctionDescriptor
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:2412
MCSectionXCOFF.h
llvm::MCContext::getAssociativeCOFFSection
MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=GenericSectionID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym.
Definition: MCContext.cpp:624
getLinkedToSymbol
static const MCSymbolELF * getLinkedToSymbol(const GlobalObject *GO, const TargetMachine &TM)
Definition: TargetLoweringObjectFileImpl.cpp:542
llvm::Attribute::getValueAsString
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:304
llvm::MCObjectFileInfo::ConstDataSection
MCSection * ConstDataSection
Definition: MCObjectFileInfo.h:204
llvm::ELF::SHF_GNU_RETAIN
@ SHF_GNU_RETAIN
Definition: ELF.h:1012
llvm::ELF::SHT_LLVM_LINKER_OPTIONS
@ SHT_LLVM_LINKER_OPTIONS
Definition: ELF.h:928
llvm::TargetLoweringObjectFile::getKindForGlobal
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...
Definition: TargetLoweringObjectFile.cpp:202
getCOFFSectionNameForUniqueGlobal
static StringRef getCOFFSectionNameForUniqueGlobal(SectionKind Kind)
Definition: TargetLoweringObjectFileImpl.cpp:1574
llvm::MCSectionMachO::hasAttribute
bool hasAttribute(unsigned Value) const
Definition: MCSectionMachO.h:54
Type.h
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::TargetLoweringObjectFileELF::emitPersonalityValue
void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &DL, const MCSymbol *Sym) const override
Definition: TargetLoweringObjectFileImpl.cpp:389
llvm::XCOFF::StorageMappingClass
StorageMappingClass
Storage Mapping Class definitions.
Definition: XCOFF.h:38
llvm::SmallString< 64 >
llvm::XCOFF::C_EXT
@ C_EXT
Definition: XCOFF.h:133
llvm::dwarf::DW_EH_PE_udata4
@ DW_EH_PE_udata4
Definition: Dwarf.h:436
llvm::TargetLoweringObjectFile::TM
const TargetMachine * TM
Definition: TargetLoweringObjectFile.h:66
llvm::TargetLoweringObjectFileCOFF::emitModuleMetadata
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit Obj-C garbage collection and linker options.
Definition: TargetLoweringObjectFileImpl.cpp:1696
llvm::MachO::S_ATTR_NO_DEAD_STRIP
@ S_ATTR_NO_DEAD_STRIP
S_ATTR_NO_DEAD_STRIP - No dead stripping.
Definition: MachO.h:195
getCOFFSectionFlags
static unsigned getCOFFSectionFlags(SectionKind K, const TargetMachine &TM)
Definition: TargetLoweringObjectFileImpl.cpp:1469
llvm::CodeModel::Model
Model
Definition: CodeGen.h:28
llvm::MDNode::getOperand
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:1102
llvm::PointerIntPair::getPointer
PointerTy getPointer() const
Definition: PointerIntPair.h:59
llvm::MachineFunction::getMMI
MachineModuleInfo & getMMI() const
Definition: MachineFunction.h:506
llvm::Triple::ppc64le
@ ppc64le
Definition: Triple.h:70
llvm::SectionKind::isThreadBSSLocal
bool isThreadBSSLocal() const
Definition: SectionKind.h:157
llvm::XCOFF::StorageClass
StorageClass
Definition: XCOFF.h:105
llvm::TargetLoweringObjectFileWasm::getStaticDtorSection
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition: TargetLoweringObjectFileImpl.cpp:2107
llvm::GlobalObject::hasSection
bool hasSection() const
Check if this global has a custom object file section.
Definition: GlobalObject.h:106
llvm::MCAsmInfo::isSectionAtomizableBySymbols
virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const
True if the section is atomized using the symbols in it.
Definition: MCAsmInfo.cpp:85
llvm::Triple::ELF
@ ELF
Definition: Triple.h:235
llvm::TargetLoweringObjectFile::SupportIndirectSymViaGOTPCRel
bool SupportIndirectSymViaGOTPCRel
Definition: TargetLoweringObjectFile.h:48
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::dwarf::DW_EH_PE_udata8
@ DW_EH_PE_udata8
Definition: Dwarf.h:437
llvm::GlobalValue::isWeakForLinker
static bool isWeakForLinker(LinkageTypes Linkage)
Whether the definition of this global may be replaced at link time.
Definition: GlobalValue.h:378
llvm::MachO::S_MOD_INIT_FUNC_POINTERS
@ S_MOD_INIT_FUNC_POINTERS
S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for initialization.
Definition: MachO.h:145
llvm::dwarf::DW_EH_PE_pcrel
@ DW_EH_PE_pcrel
Definition: Dwarf.h:443
getEntrySizeForKind
static unsigned getEntrySizeForKind(SectionKind Kind)
Definition: TargetLoweringObjectFileImpl.cpp:560
llvm::MCContext::getAsmInfo
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:406
llvm::MCObjectFileInfo::UStringSection
MCSection * UStringSection
Definition: MCObjectFileInfo.h:201
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:572
llvm::SectionKind::isMetadata
bool isMetadata() const
Definition: SectionKind.h:119
llvm::TargetLoweringObjectFile::getPersonalityEncoding
unsigned getPersonalityEncoding() const
Definition: TargetLoweringObjectFile.h:166
llvm::XCOFF::XTY_CM
@ XTY_CM
Common csect definition. For uninitialized storage.
Definition: XCOFF.h:180
llvm::APInt::toString
void toString(SmallVectorImpl< char > &Str, unsigned Radix, bool Signed, bool formatAsCLiteral=false) const
Converts an APInt to a string and append it to Str.
Definition: APInt.cpp:2167
llvm::Triple::isOSFreeBSD
bool isOSFreeBSD() const
Definition: Triple.h:510
llvm::MCObjectFileInfo::CStringSection
MCSection * CStringSection
Definition: MCObjectFileInfo.h:200
llvm::GlobalVariable::hasImplicitSection
bool hasImplicitSection() const
Check if section name is present.
Definition: GlobalVariable.h:243
llvm::Triple::isArch32Bit
bool isArch32Bit() const
Test whether the architecture is 32-bit.
Definition: Triple.cpp:1340
llvm::XCOFF::XMC_TL
@ XMC_TL
Initialized thread-local variable.
Definition: XCOFF.h:61
llvm::GlobalValue::WeakAnyLinkage
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
Definition: GlobalValue.h:52
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::DSOLocalEquivalent::getGlobalValue
GlobalValue * getGlobalValue() const
Definition: Constants.h:908
BasicBlockSectionUtils.h
llvm::TargetLoweringObjectFileWasm::shouldPutJumpTableInFunctionSection
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
Definition: TargetLoweringObjectFileImpl.cpp:2063
I
#define I(x, y, z)
Definition: MD5.cpp:59
StringExtras.h
llvm::TargetLoweringObjectFileMachO::Initialize
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Definition: TargetLoweringObjectFileImpl.cpp:1103
llvm::SectionKind::isMergeableCString
bool isMergeableCString() const
Definition: SectionKind.h:130
llvm::ELF::SHT_LLVM_DEPENDENT_LIBRARIES
@ SHT_LLVM_DEPENDENT_LIBRARIES
Definition: ELF.h:932
llvm::XCOFF::C_HIDEXT
@ C_HIDEXT
Definition: XCOFF.h:141
llvm::TargetLoweringObjectFileXCOFF::getTargetSymbol
MCSymbol * getTargetSymbol(const GlobalValue *GV, const TargetMachine &TM) const override
For functions, this will always return a function descriptor symbol.
Definition: TargetLoweringObjectFileImpl.cpp:2140
llvm::MCSection::NonUniqueID
static constexpr unsigned NonUniqueID
Definition: MCSection.h:41
llvm::MachineFunction::getName
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Definition: MachineFunction.cpp:522
llvm::MBBSectionID::ExceptionSectionID
const static MBBSectionID ExceptionSectionID
Definition: MachineBasicBlock.h:65
llvm::TargetMachine::Options
TargetOptions Options
Definition: TargetMachine.h:115
llvm::TargetLoweringObjectFile::getTTypeReference
const MCExpr * getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, MCStreamer &Streamer) const
Definition: TargetLoweringObjectFile.cpp:408
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
llvm::MCSectionCOFF
This represents a section on Windows.
Definition: MCSectionCOFF.h:26
llvm::Type::getArrayNumElements
uint64_t getArrayNumElements() const
Definition: DerivedTypes.h:386
llvm::MachineBasicBlock::getParent
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Definition: MachineBasicBlock.h:225
llvm::GlobalValue::hasLocalLinkage
bool hasLocalLinkage() const
Definition: GlobalValue.h:445
llvm::MCBinaryExpr::createSub
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:606
llvm::COFF::IMAGE_SCN_LNK_COMDAT
@ IMAGE_SCN_LNK_COMDAT
Definition: COFF.h:294
llvm::TargetLoweringObjectFile::supportDSOLocalEquivalentLowering
bool supportDSOLocalEquivalentLowering() const
Target supports a native lowering of a dso_local_equivalent constant without needing to replace it wi...
Definition: TargetLoweringObjectFile.h:196
llvm::GlobalValue::isThreadLocal
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
Definition: GlobalValue.h:244
llvm::MachineFunction::getLandingPads
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
Definition: MachineFunction.h:976
PreferPredicateTy::Option
Option
Definition: LoopVectorize.cpp:212
llvm::Function::hasAttribute
bool hasAttribute(unsigned i, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
Definition: Function.h:434
MachineModuleInfo.h
APIntToHexString
static std::string APIntToHexString(const APInt &AI)
Definition: TargetLoweringObjectFileImpl.cpp:1889
llvm::TargetLoweringObjectFileMachO::emitModuleMetadata
void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override
Emit the module flags that specify the garbage collection information.
Definition: TargetLoweringObjectFileImpl.cpp:1127
llvm::SectionKind::getThreadData
static SectionKind getThreadData()
Definition: SectionKind.h:200
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:897
llvm::TargetLoweringObjectFileELF::getSectionForConstant
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:924
llvm::TargetLoweringObjectFileELF::lowerDSOLocalEquivalent
const MCExpr * lowerDSOLocalEquivalent(const DSOLocalEquivalent *Equiv, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:1053
llvm::Triple::armeb
@ armeb
Definition: Triple.h:51
llvm::COFF::IMAGE_COMDAT_SELECT_LARGEST
@ IMAGE_COMDAT_SELECT_LARGEST
Definition: COFF.h:412
llvm::GlobalObject::hasComdat
bool hasComdat() const
Definition: GlobalObject.h:124
llvm::TargetLoweringObjectFileWasm::SelectSectionForGlobal
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:2044
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:71
llvm::MachineFunction
Definition: MachineFunction.h:227
llvm::TargetLoweringObjectFileCOFF::Initialize
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Definition: TargetLoweringObjectFileImpl.cpp:1780
llvm::TargetLoweringObjectFileXCOFF::getFunctionEntryPointSymbol
MCSymbol * getFunctionEntryPointSymbol(const GlobalValue *Func, const TargetMachine &TM) const override
If supported, return the function entry point symbol.
Definition: TargetLoweringObjectFileImpl.cpp:2380
llvm::GlobalValue::AppendingLinkage
@ AppendingLinkage
Special purpose, only applies to global arrays.
Definition: GlobalValue.h:54
Mangler.h
Triple.h
llvm::dwarf::DW_EH_PE_datarel
@ DW_EH_PE_datarel
Definition: Dwarf.h:445
llvm::MCBinaryExpr::createAdd
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:521
llvm::TargetMachine::getMCAsmInfo
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
Definition: TargetMachine.h:202
llvm::TargetLoweringObjectFile::getMangler
Mangler & getMangler() const
Definition: TargetLoweringObjectFile.h:75
llvm::MachineModuleInfoELF::getGVStubEntry
StubValueTy & getGVStubEntry(MCSymbol *Sym)
Definition: MachineModuleInfoImpls.h:72
llvm::TargetLoweringObjectFileELF::getStaticDtorSection
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition: TargetLoweringObjectFileImpl.cpp:1027
llvm::Triple::arm
@ arm
Definition: Triple.h:50
MCAsmInfo.h
DataLayout.h
llvm::ELF::SHF_STRINGS
@ SHF_STRINGS
Definition: ELF.h:990
llvm::Triple::aarch64_be
@ aarch64_be
Definition: Triple.h:53
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
Dwarf.h
llvm::TargetLoweringObjectFileELF::getCFIPersonalitySymbol
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
Definition: TargetLoweringObjectFileImpl.cpp:377
llvm::Triple::ppcle
@ ppcle
Definition: Triple.h:68
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::transform
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.
Definition: STLExtras.h:1602
llvm::Reloc::Static
@ Static
Definition: CodeGen.h:22
llvm::GlobalValue::WeakODRLinkage
@ WeakODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:53
getSelectionForCOFF
static int getSelectionForCOFF(const GlobalValue *GV)
Definition: TargetLoweringObjectFileImpl.cpp:1522
llvm::XCOFF::C_WEAKEXT
@ C_WEAKEXT
Definition: XCOFF.h:134
canUsePrivateLabel
static bool canUsePrivateLabel(const MCAsmInfo &AsmInfo, const MCSection &Section)
Definition: TargetLoweringObjectFileImpl.cpp:1438
llvm::Triple::thumb
@ thumb
Definition: Triple.h:81
llvm::MCObjectFileInfo::getDrectveSection
MCSection * getDrectveSection() const
Definition: MCObjectFileInfo.h:405
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:940
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::emitLinkerFlagsForUsedCOFF
void emitLinkerFlagsForUsedCOFF(raw_ostream &OS, const GlobalValue *GV, const Triple &T, Mangler &M)
Definition: Mangler.cpp:242
llvm::format
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:124
llvm::GlobalValue::AvailableExternallyLinkage
@ AvailableExternallyLinkage
Available for inspection, not emission.
Definition: GlobalValue.h:49
llvm::MCContext::getCOFFSection
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
Definition: MCContext.cpp:584
getSectionPrefixForGlobal
static StringRef getSectionPrefixForGlobal(SectionKind Kind)
Return the section prefix name used by options FunctionsSections and DataSections.
Definition: TargetLoweringObjectFileImpl.cpp:586
getWasmComdat
static const Comdat * getWasmComdat(const GlobalValue *GV)
Definition: TargetLoweringObjectFileImpl.cpp:1971
LLVM_FALLTHROUGH
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:281
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:298
llvm::TargetLoweringObjectFileELF::getUniqueSectionForFunction
MCSection * getUniqueSectionForFunction(const Function &F, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:858
llvm::Module::getSourceFileName
const std::string & getSourceFileName() const
Get the module's original source file name.
Definition: Module.h:238
llvm::GlobalValue::CommonLinkage
@ CommonLinkage
Tentative definitions.
Definition: GlobalValue.h:58
llvm::MachineBasicBlock::getSectionID
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
Definition: MachineBasicBlock.h:483
llvm::SectionKind::isBSSLocal
bool isBSSLocal() const
Definition: SectionKind.h:164
llvm::TargetLoweringObjectFile::PersonalityEncoding
unsigned PersonalityEncoding
PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values for EH.
Definition: TargetLoweringObjectFile.h:55
llvm::MCSection::getName
StringRef getName() const
Definition: MCSection.h:115
llvm::MachineFunction::getSection
MCSection * getSection() const
Returns the Section this function belongs to.
Definition: MachineFunction.h:510
llvm::APInt::getNullValue
static APInt getNullValue(unsigned numBits)
Get the '0' value.
Definition: APInt.h:575
llvm::MCObjectFileInfo::DataRelROSection
MCSection * DataRelROSection
Definition: MCObjectFileInfo.h:182
llvm::SectionKind::getData
static SectionKind getData()
Definition: SectionKind.h:206
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::TargetLoweringObjectFileMachO::getCFIPersonalitySymbol
MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const override
Definition: TargetLoweringObjectFileImpl.cpp:1341
llvm::dwarf::DW_EH_PE_absptr
@ DW_EH_PE_absptr
Definition: Dwarf.h:432
llvm::LLVMContext::diagnose
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Definition: LLVMContext.cpp:228
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
llvm::SectionKind
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::ELF::SHF_ARM_PURECODE
@ SHF_ARM_PURECODE
Definition: ELF.h:1073
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:521
llvm::MCStreamer::emitSymbolAttribute
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:314
llvm::MCObjectFileInfo::DataSection
MCSection * DataSection
Section directive for standard data.
Definition: MCObjectFileInfo.h:58
llvm::MBBSectionID::ColdSectionID
const static MBBSectionID ColdSectionID
Definition: MachineBasicBlock.h:64
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
llvm::DataLayout::getPrivateGlobalPrefix
StringRef getPrivateGlobalPrefix() const
Definition: DataLayout.h:330
llvm::MCObjectFileInfo::MergeableConst32Section
MCSection * MergeableConst32Section
Definition: MCObjectFileInfo.h:186
llvm::SectionName
Definition: DWARFSection.h:21
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
GlobalVariable.h
llvm::MCSectionMachO
This represents a section on a Mach-O system (used by Mac OS X).
Definition: MCSectionMachO.h:24
llvm::COFF::IMAGE_SCN_CNT_CODE
@ IMAGE_SCN_CNT_CODE
Definition: COFF.h:288
llvm::ELF::SHF_WRITE
@ SHF_WRITE
Definition: ELF.h:978
llvm::GlobalValue::getComdat
const Comdat * getComdat() const
Definition: Globals.cpp:172
llvm::Triple::riscv32
@ riscv32
Definition: Triple.h:73
Casting.h
DiagnosticInfo.h
Function.h
llvm::Triple::mipsel
@ mipsel
Definition: Triple.h:63
llvm::TargetLoweringObjectFileELF::getSectionForCommandLines
MCSection * getSectionForCommandLines() const override
If supported, return the section to use for the llvm.commandline metadata.
Definition: TargetLoweringObjectFileImpl.cpp:1067
llvm::TargetLoweringObjectFileMachO::getExplicitSectionGlobal
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:1179
llvm::TargetLoweringObjectFileELF::Initialize
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
Definition: TargetLoweringObjectFileImpl.cpp:114
llvm::TargetMachine::getCodeModel
CodeModel::Model getCodeModel() const
Returns the code model.
Definition: TargetMachine.cpp:74
DP
So we should use XX3Form_Rcr to implement instrinsic Convert DP outs ins xscvdpsp No builtin are required Round &Convert QP DP(dword[1] is set to zero) No builtin are required Round to Quad Precision because you need to assign rounding mode in instruction Provide builtin(set f128:$vT,(int_ppc_vsx_xsrqpi f128:$vB))(set f128 yields< n x< ty > >< result > yields< ty >< result > No builtin are required Load Store load store see def memrix16 in PPCInstrInfo td Load Store Vector load store outs ins lxsdx set load store with conversion from to DP
Definition: README_P9.txt:520
llvm::MCSymbolRefExpr::VK_COFF_IMGREL32
@ VK_COFF_IMGREL32
Definition: MCExpr.h:313
PseudoProbe.h
llvm::MCSymbolRefExpr::create
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:382
llvm::GlobalVariable::getAttributes
AttributeSet getAttributes() const
Return the attribute set for this global.
Definition: GlobalVariable.h:223
llvm::Module::Require
@ Require
Adds a requirement that another module flag be present and have a specified value after linking is pe...
Definition: Module.h:133
llvm::TargetLoweringObjectFileCOFF::getExplicitSectionGlobal
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:1547
llvm::GlobalValue::getBaseObject
const GlobalObject * getBaseObject() const
Definition: Globals.cpp:283
llvm::Triple::systemz
@ systemz
Definition: Triple.h:78
MCValue.h
SectionKind.h
GlobalAlias.h
llvm::AMDGPU::Hwreg::Width
Width
Definition: SIDefines.h:403
llvm::TargetLoweringObjectFile::getSectionForConstant
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.
Definition: TargetLoweringObjectFile.cpp:375
llvm::MCContext::getWasmSection
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K)
Definition: MCContext.h:598
llvm::XCOFF::XMC_DS
@ XMC_DS
Descriptor csect.
Definition: XCOFF.h:56
Selection
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
Definition: AMDGPUISelDAGToDAG.cpp:376
llvm::MCAsmInfo::binutilsIsAtLeast
bool binutilsIsAtLeast(int Major, int Minor) const
Definition: MCAsmInfo.h:724
llvm::getInstrProfSectionName
std::string getInstrProfSectionName(InstrProfSectKind IPSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)
Return the name of the profile section corresponding to IPSK.
Definition: InstrProf.cpp:174
llvm::GlobalValue::ExternalLinkage
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:48
CodeGen.h
llvm::MCAsmInfo::getExceptionHandlingType
ExceptionHandling getExceptionHandlingType() const
Definition: MCAsmInfo.h:672
llvm::MCObjectFileInfo::DataCoalSection
MCSection * DataCoalSection
Definition: MCObjectFileInfo.h:205
llvm::CodeModel::Large
@ Large
Definition: CodeGen.h:28
llvm::MCSA_Weak
@ MCSA_Weak
.weak
Definition: MCDirectives.h:44
llvm::TargetLoweringObjectFile::LSDAEncoding
unsigned LSDAEncoding
Definition: TargetLoweringObjectFile.h:56
llvm::ELF::SHF_GROUP
@ SHF_GROUP
Definition: ELF.h:1003
llvm::TargetLoweringObjectFileXCOFF::getStorageClassForGlobal
static XCOFF::StorageClass getStorageClassForGlobal(const GlobalValue *GV)
Definition: TargetLoweringObjectFileImpl.cpp:2356
llvm::GlobalValue::PrivateLinkage
@ PrivateLinkage
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:56
llvm::ELF::SHF_EXCLUDE
@ SHF_EXCLUDE
Definition: ELF.h:1015
llvm::MCStreamer::emitULEB128IntValue
void emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:160
llvm::PointerIntPair
PointerIntPair - This class implements a pair of a pointer and small integer.
Definition: PointerIntPair.h:45
llvm::ELF::SHT_PREINIT_ARRAY
@ SHT_PREINIT_ARRAY
Definition: ELF.h:916
SmallVector.h
llvm::emitLinkerFlagsForGlobalCOFF
void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV, const Triple &TT, Mangler &Mangler)
Definition: Mangler.cpp:206
llvm::TargetLoweringObjectFileCOFF::SelectSectionForGlobal
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:1586
llvm::XCOFF::XMC_RW
@ XMC_RW
Read Write Data.
Definition: XCOFF.h:52
llvm::Triple::thumbeb
@ thumbeb
Definition: Triple.h:82
llvm::TargetLoweringObjectFileXCOFF::lowerRelativeReference
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:2349
llvm::MCSectionXCOFF::getQualNameSymbol
MCSymbolXCOFF * getQualNameSymbol() const
Definition: MCSectionXCOFF.h:102
MCStreamer.h
llvm::MCObjectFileInfo::BSSSection
MCSection * BSSSection
Section that is default initialized to zero.
Definition: MCObjectFileInfo.h:61
llvm::MCObjectFileInfo::MergeableConst4Section
MCSection * MergeableConst4Section
Definition: MCObjectFileInfo.h:183
llvm::MCContext::getELFUniqueIDForEntsize
Optional< unsigned > getELFUniqueIDForEntsize(StringRef SectionName, unsigned Flags, unsigned EntrySize)
Definition: MCContext.cpp:576
Characteristics
COFFYAML::WeakExternalCharacteristics Characteristics
Definition: COFFYAML.cpp:325
llvm::MCObjectFileInfo::TLSBSSSection
MCSection * TLSBSSSection
Section directive for Thread Local uninitialized data.
Definition: MCObjectFileInfo.h:158
llvm::SectionKind::isReadOnlyWithRel
bool isReadOnlyWithRel() const
Definition: SectionKind.h:171
llvm::TargetMachine::getTargetTriple
const Triple & getTargetTriple() const
Definition: TargetMachine.h:123
llvm::MachineModuleInfoELF
MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation for ELF targets.
Definition: MachineModuleInfoImpls.h:62
llvm::TargetLoweringObjectFileELF::getSectionForMachineBasicBlock
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:943
selectWasmSectionForGlobal
static MCSectionWasm * selectWasmSectionForGlobal(MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang, const TargetMachine &TM, bool EmitUniqueSection, unsigned *NextUniqueID)
Definition: TargetLoweringObjectFileImpl.cpp:2014
llvm::GlobalValue::isDeclarationForLinker
bool isDeclarationForLinker() const
Definition: GlobalValue.h:534
llvm::raw_svector_ostream
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:647
llvm::MCStreamer::emitValueToAlignment
virtual void emitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
Definition: MCStreamer.cpp:1182
llvm::Function::getAttribute
Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const
gets the attribute from the list of attributes.
Definition: Function.h:449
llvm::TargetLoweringObjectFileELF::getTTypeGlobalReference
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:411
llvm::COFF::IMAGE_SCN_MEM_EXECUTE
@ IMAGE_SCN_MEM_EXECUTE
Definition: COFF.h:320
llvm::MCStreamer::emitBytes
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
Definition: MCStreamer.cpp:1172
llvm::Triple::getEnvironment
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:325
llvm::TargetLoweringObjectFileWasm::lowerRelativeReference
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:2070
llvm::SmallVectorImpl< char >
llvm::GlobalValue::getType
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:271
llvm::Module::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:397
DerivedTypes.h
llvm::GlobalValue::getValueType
Type * getValueType() const
Definition: GlobalValue.h:273
llvm::TargetLoweringObjectFile::TTypeEncoding
unsigned TTypeEncoding
Definition: TargetLoweringObjectFile.h:57
getStaticStructorSection
static MCSectionELF * getStaticStructorSection(MCContext &Ctx, bool UseInitArray, bool IsCtor, unsigned Priority, const MCSymbol *KeySym)
Definition: TargetLoweringObjectFileImpl.cpp:983
llvm::MCValue
This represents an "assembler immediate".
Definition: MCValue.h:37
llvm::COFF::IMAGE_SCN_MEM_16BIT
@ IMAGE_SCN_MEM_16BIT
Definition: COFF.h:297
llvm::MCSymbolRefExpr::VK_None
@ VK_None
Definition: MCExpr.h:195
llvm::TargetLoweringObjectFileCOFF::getSectionForConstant
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:1921
llvm::ELF::SHT_INIT_ARRAY
@ SHT_INIT_ARRAY
Definition: ELF.h:914
MachO.h
llvm::TargetLoweringObjectFileCOFF::getSectionForJumpTable
MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:1669
llvm::MCObjectFileInfo::DataCommonSection
MCSection * DataCommonSection
Definition: MCObjectFileInfo.h:207
llvm::MCContext::getELFNamedSection
MCSectionELF * getELFNamedSection(const Twine &Prefix, const Twine &Suffix, unsigned Type, unsigned Flags, unsigned EntrySize=0)
Get a section with the provided group identifier.
Definition: MCContext.cpp:483
llvm::GlobalValue::ExternalWeakLinkage
@ ExternalWeakLinkage
ExternalWeak linkage description.
Definition: GlobalValue.h:57
raw_ostream.h
llvm::MCObjectFileInfo::getTargetTriple
const Triple & getTargetTriple() const
Definition: MCObjectFileInfo.h:439
llvm::XCOFF::XMC_UL
@ XMC_UL
Uninitialized thread-local variable.
Definition: XCOFF.h:62
llvm::TargetLoweringObjectFileCOFF::getStaticCtorSection
MCSection * getStaticCtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition: TargetLoweringObjectFileImpl.cpp:1844
MachineFunction.h
getELFComdat
static const Comdat * getELFComdat(const GlobalValue *GV)
Definition: TargetLoweringObjectFileImpl.cpp:528
DiagnosticPrinter.h
llvm::GlobalValue::LinkOnceODRLinkage
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:51
llvm::TargetLoweringObjectFileCOFF::getStaticDtorSection
MCSection * getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override
Definition: TargetLoweringObjectFileImpl.cpp:1851
llvm::MCStreamer::SwitchSection
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Definition: MCStreamer.cpp:1194
getComdatGVForCOFF
static const GlobalValue * getComdatGVForCOFF(const GlobalValue *GV)
Definition: TargetLoweringObjectFileImpl.cpp:1505
MCExpr.h
llvm::TargetLoweringObjectFile::SupportDSOLocalEquivalentLowering
bool SupportDSOLocalEquivalentLowering
Definition: TargetLoweringObjectFile.h:51
llvm::COFF::SectionCharacteristics
SectionCharacteristics
Definition: COFF.h:283
llvm::MachineModuleInfo::getModule
const Module * getModule() const
Definition: MachineModuleInfo.h:174
llvm::TargetLoweringObjectFile::getTTypeGlobalReference
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...
Definition: TargetLoweringObjectFile.cpp:398
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::DSOLocalEquivalent
Wrapper for a function that represents a value that functionally represents the original function.
Definition: Constants.h:891
llvm::Directive
Definition: DirectiveEmitter.h:100
llvm::DS_Error
@ DS_Error
Definition: DiagnosticInfo.h:45
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
llvm::SectionKind::isExecuteOnly
bool isExecuteOnly() const
Definition: SectionKind.h:123
llvm::Triple::mips
@ mips
Definition: Triple.h:62
llvm::TargetLoweringObjectFileXCOFF::shouldPutJumpTableInFunctionSection
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
Definition: TargetLoweringObjectFileImpl.cpp:2313
llvm::MachineModuleInfo::getObjFileInfo
Ty & getObjFileInfo()
Keep track of various per-function pieces of information for backends that would like to do so.
Definition: MachineModuleInfo.h:191
llvm::Triple::aarch64
@ aarch64
Definition: Triple.h:52
llvm::MDOperand
Tracking metadata reference owned by Metadata.
Definition: Metadata.h:744
llvm::COFF::IMAGE_COMDAT_SELECT_ANY
@ IMAGE_COMDAT_SELECT_ANY
Definition: COFF.h:408
llvm::COFF::IMAGE_SCN_MEM_WRITE
@ IMAGE_SCN_MEM_WRITE
Definition: COFF.h:322
llvm::XCOFF::XMC_BS
@ XMC_BS
BSS class (uninitialized static internal)
Definition: XCOFF.h:58
llvm::Module::getNamedValue
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type.
Definition: Module.cpp:113
llvm::MCValue::getSymB
const MCSymbolRefExpr * getSymB() const
Definition: MCValue.h:46
llvm::MachineModuleInfoMachO
MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation for MachO targets.
Definition: MachineModuleInfoImpls.h:27
llvm::TargetLoweringObjectFileCOFF::lowerRelativeReference
const MCExpr * lowerRelativeReference(const GlobalValue *LHS, const GlobalValue *RHS, const TargetMachine &TM) const override
Definition: TargetLoweringObjectFileImpl.cpp:1858
llvm::Type::getPrimitiveSizeInBits
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Definition: Type.cpp:129
MCSectionWasm.h
llvm::TargetMachine::getDataSections
bool getDataSections() const
Return true if data objects should be emitted into their own section, corresponds to -fdata-sections.
Definition: TargetMachine.h:270
llvm::MCObjectFileInfo::TextSection
MCSection * TextSection
Section directive for standard text.
Definition: MCObjectFileInfo.h:55
TargetLoweringObjectFileImpl.h