Lines Matching +full:cs +full:- +full:extra +full:- +full:delay

1 //===- AsmPrinter.cpp - Common AsmPrinter code ----------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
135 #define DEBUG_TYPE "asm-printer"
147 "pgo-analysis-map", cl::Hidden, cl::CommaSeparated,
149 "func-entry-count", "Function Entry Count"),
150 clEnumValN(PGOMapFeaturesEnum::BBFreq, "bb-freq",
152 clEnumValN(PGOMapFeaturesEnum::BrProb, "br-prob",
197 /// This is a per-function list of symbols whose corresponding BasicBlock got
221 assert(BB->hasAddressTaken() &&
227 assert(BB->getParent() == Entry.Fn && "Parent changed");
235 Entry.Index = BBCallbacks.size() - 1;
236 Entry.Fn = BB->getParent();
237 MCSymbol *Sym = BB->hasAddressTaken() ? Context.createNamedTempSymbol()
254 std::swap(Result, I->second);
258 //===- Address of Block Management ----------------------------------------===//
265 return AddrLabelSymbols->getAddrLabelSymbolToEmit(
274 return AddrLabelSymbols->takeDeletedSymbolsForFunction(
289 assert((BB->getParent() == nullptr || BB->getParent() == Entry.Fn) &&
294 if (Sym->isDefined())
327 Map->UpdateForDeletedBlock(cast<BasicBlock>(getValPtr()));
331 Map->UpdateForRAUWBlock(cast<BasicBlock>(getValPtr()), cast<BasicBlock>(V2));
334 /// getGVAlignment - Return the alignment to use for the specified global
347 const MaybeAlign GVAlign(GV->getAlign());
355 if (*GVAlign > Alignment || GV->hasSection())
362 OutContext(Streamer->getContext()), OutStreamer(std::move(Streamer)),
364 VerboseAsm = OutStreamer->isVerboseAsm();
366 MAI->doesDwarfUseRelocationsAcrossSections();
378 /// getFunctionNumber - Return a unique ID for the current function.
380 return MF->getFunctionNumber();
389 return MMI->getModule()->getDataLayout();
393 // (dsymutil, llvm-dwarfdump).
400 return MF->getSubtarget<MCSubtargetInfo>();
409 assert(OutStreamer->hasRawTextSupport() &&
416 (void)DD->emitInitialLocDirective(MF, /*CUID=*/0);
420 /// getCurrentSection() - Return the current section we are emitting to.
422 return OutStreamer->getCurrentSectionOnly();
436 MMI = MMIWP ? &MMIWP->getMMI() : nullptr;
449 // On AIX, we delay emitting any section information until
450 // after emitting the .file pseudo-op. This allows additional
454 OutStreamer->initSections(false, *TM.getMCSubtargetInfo());
456 // Emit the version-min deployment target directive if needed.
458 // FIXME: If we end up with a collection of these sorts of Darwin-specific
459 // or ELF-specific things, it may make sense to have a platform helper class
467 OutStreamer->emitVersionForTarget(
478 if (MAI->hasSingleParameterDotFile()) {
482 if (MAI->hasBasenameOnlyForFileDirective())
486 if (MAI->hasFourStringsDotFile()) {
497 OutStreamer->emitFileDirective(FileName, VerStr, "", "");
499 OutStreamer->emitFileDirective(FileName);
508 OutStreamer->initSections(false, *TM.getMCSubtargetInfo());
511 // a rename for the default text-section symbol name. This call has
514 OutStreamer->getContext().getObjectFileInfo()->getTextSection();
516 static_cast<MCSectionXCOFF *>(TextSection)->getQualNameSymbol();
517 if (XSym->hasRename())
518 OutStreamer->emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
525 MP->beginAssembly(M, *MI, *this);
527 // Emit module-level inline asm if it exists.
529 OutStreamer->AddComment("Start of file scope inline assembly");
530 OutStreamer->addBlankLine();
534 InlineAsm::AsmDialect(TM.getMCAsmInfo()->getAssemblerDialect()));
535 OutStreamer->AddComment("End of file scope inline assembly");
536 OutStreamer->addBlankLine();
539 if (MAI->doesSupportDebugInformation()) {
545 if (MMI->hasDebugInfo()) {
555 switch (MAI->getExceptionHandlingType()) {
570 assert(MAI->getExceptionHandlingType() == ExceptionHandling::DwarfCFI ||
578 switch (MAI->getExceptionHandlingType()) {
592 switch (MAI->getWinEHEncodingType()) {
617 Handler->beginModule(&M);
619 Handler->beginModule(&M);
628 return GV->canBeOmittedFromSymbolTable();
632 GlobalValue::LinkageTypes Linkage = GV->getLinkage();
639 if (MAI->hasWeakDefDirective()) {
641 OutStreamer->emitSymbolAttribute(GVSym, MCSA_Global);
645 OutStreamer->emitSymbolAttribute(GVSym, MCSA_WeakDefinition);
647 OutStreamer->emitSymbolAttribute(GVSym, MCSA_WeakDefAutoPrivate);
648 } else if (MAI->avoidWeakIfComdat() && GV->hasComdat()) {
650 OutStreamer->emitSymbolAttribute(GVSym, MCSA_Global);
654 OutStreamer->emitSymbolAttribute(GVSym, MCSA_Weak);
658 OutStreamer->emitSymbolAttribute(GVSym, MCSA_Global);
681 // On ELF, use .Lfoo$local if GV is a non-interposable GlobalObject with an
697 /// EmitGlobalVariable - Emit the specified global variable to the .s file.
699 bool IsEmuTLSVar = TM.useEmulatedTLS() && GV->isThreadLocal();
700 assert(!(IsEmuTLSVar && GV->hasCommonLinkage()) &&
708 if (GV->hasInitializer()) {
721 GV->printAsOperand(OutStreamer->getCommentOS(),
722 /*PrintType=*/false, GV->getParent());
723 OutStreamer->getCommentOS() << '\n';
733 emitVisibility(EmittedSym, GV->getVisibility(), !GV->isDeclaration());
735 if (GV->isTagged()) {
740 "tagged symbols (-fsanitize=memtag-globals) are "
742 OutStreamer->emitSymbolAttribute(EmittedSym, MAI->getMemtagAttr());
745 if (!GV->hasInitializer()) // External globals require no extra code.
748 GVSym->redefineIfPossible();
749 if (GVSym->isDefined() || GVSym->isVariable())
750 OutContext.reportError(SMLoc(), "symbol '" + Twine(GVSym->getName()) +
753 if (MAI->hasDotTypeDotSizeDirective())
754 OutStreamer->emitSymbolAttribute(EmittedSym, MCSA_ELF_TypeObject);
758 const DataLayout &DL = GV->getDataLayout();
759 uint64_t Size = DL.getTypeAllocSize(GV->getValueType());
767 Handler->setSymbolSize(GVSym, Size);
773 OutStreamer->emitCommonSymbol(GVSym, Size, Alignment);
782 if (GVKind.isBSS() && MAI->hasMachoZeroFillDirective() &&
783 TheSection->isVirtualSection()) {
788 OutStreamer->emitZerofill(TheSection, GVSym, Size, Alignment);
799 // Use .lcomm only if it supports user-specified alignment.
802 // some -unknown- default alignment behavior, which could cause
805 if (MAI->getLCOMMDirectiveAlignmentType() != LCOMM::NoAlignment) {
807 OutStreamer->emitLocalCommonSymbol(GVSym, Size, Alignment);
812 OutStreamer->emitSymbolAttribute(GVSym, MCSA_Local);
814 OutStreamer->emitCommonSymbol(GVSym, Size, Alignment);
818 // Handle thread local data for mach-o which requires us to output an
828 if (GVKind.isThreadLocal() && MAI->hasMachoTBSSDirective()) {
831 OutContext.getOrCreateSymbol(GVSym->getName() + Twine("$tlv$init"));
835 OutStreamer->emitTBSSSymbol(TheSection, MangSym, Size, Alignment);
837 OutStreamer->switchSection(TheSection);
840 OutStreamer->emitLabel(MangSym);
842 emitGlobalConstant(GV->getDataLayout(),
843 GV->getInitializer());
846 OutStreamer->addBlankLine();
851 OutStreamer->switchSection(TLVSect);
854 OutStreamer->emitLabel(GVSym);
857 // - __tlv_bootstrap - used to make sure support exists
858 // - spare pointer, used when mapped by the runtime
859 // - pointer to mangled symbol above with initializer
860 unsigned PtrSize = DL.getPointerTypeSize(GV->getType());
861 OutStreamer->emitSymbolValue(GetExternalSymbolSymbol("_tlv_bootstrap"),
863 OutStreamer->emitIntValue(0, PtrSize);
864 OutStreamer->emitSymbolValue(MangSym, PtrSize);
866 OutStreamer->addBlankLine();
872 OutStreamer->switchSection(TheSection);
877 OutStreamer->emitLabel(EmittedInitSym);
880 OutStreamer->emitLabel(LocalAlias);
882 emitGlobalConstant(GV->getDataLayout(), GV->getInitializer());
884 if (MAI->hasDotTypeDotSizeDirective())
886 OutStreamer->emitELFSize(EmittedInitSym,
889 OutStreamer->addBlankLine();
894 /// \p Value - The value to emit.
895 /// \p Size - The size of the integer (in bytes) to emit.
897 OutStreamer->emitValue(Value, Size);
903 const Function &F = MF->getFunction();
904 if (!MAI->hasSubsectionsViaSymbols()) {
909 // Preserving prefix-like data on platforms which use subsections-via-symbols
910 // is a bit tricky. Here we introduce a symbol for the prefix-like data
913 OutStreamer->emitLabel(OutContext.createLinkerPrivateTempSymbol());
920 OutStreamer->emitSymbolAttribute(CurrentFnSym, MCSA_AltEntry);
923 /// EmitFunctionHeader - This method emits the header for the current
926 const Function &F = MF->getFunction();
929 OutStreamer->getCommentOS()
930 << "-- Begin function "
939 if (MF->front().isBeginSection())
940 MF->setSection(getObjFileLowering().getUniqueSectionForFunction(F, TM));
942 MF->setSection(getObjFileLowering().SectionForGlobal(&F, TM));
943 OutStreamer->switchSection(MF->getSection());
945 if (!MAI->hasVisibilityOnlyWithLinkage())
948 if (MAI->needsFunctionDescriptors())
952 if (MAI->hasFunctionAlignment())
953 emitAlignment(MF->getAlignment(), &F);
955 if (MAI->hasDotTypeDotSizeDirective())
956 OutStreamer->emitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction);
959 OutStreamer->emitSymbolAttribute(CurrentFnSym, MCSA_Cold);
965 // Emit KCFI type information before patchable-function-prefix nops.
968 // Emit M NOPs for -fpatchable-function-entry=N,M where M>0. We arbitrarily
972 (void)F.getFnAttribute("patchable-function-prefix")
975 (void)F.getFnAttribute("patchable-function-entry")
981 OutStreamer->emitLabel(CurrentPatchableFunctionEntrySym);
991 assert(MD->getNumOperands() == 2);
993 auto *PrologueSig = mdconst::extract<Constant>(MD->getOperand(0));
994 auto *TypeHash = mdconst::extract<Constant>(MD->getOperand(1));
999 F.printAsOperand(OutStreamer->getCommentOS(),
1002 OutStreamer->getCommentOS() << '\n';
1007 // the AIX target. The PowerPC 64-bit V1 ELF target also uses function
1009 if (MAI->needsFunctionDescriptors())
1016 // If the function had address-taken blocks that got deleted, then we have
1022 OutStreamer->AddComment("Address taken block that was later removed");
1023 OutStreamer->emitLabel(DeadBlockSym);
1027 if (MAI->useAssignmentForEHBegin()) {
1029 OutStreamer->emitLabel(CurPos);
1030 OutStreamer->emitAssignment(CurrentFnBegin,
1033 OutStreamer->emitLabel(CurrentFnBegin);
1037 // Emit pre-function debug and/or EH information.
1039 Handler->beginFunction(MF);
1040 Handler->beginBasicBlockSection(MF->front());
1043 Handler->beginFunction(MF);
1045 Handler->beginBasicBlockSection(MF->front());
1052 /// EmitFunctionEntryLabel - Emit the label that is the entrypoint for the
1055 CurrentFnSym->redefineIfPossible();
1059 if (CurrentFnSym->isVariable())
1060 report_fatal_error("'" + Twine(CurrentFnSym->getName()) +
1063 OutStreamer->emitLabel(CurrentFnSym);
1066 MCSymbol *Sym = getSymbolPreferLocal(MF->getFunction());
1068 cast<MCSymbolELF>(Sym)->setType(ELF::STT_FUNC);
1070 OutStreamer->emitLabel(Sym);
1071 if (MAI->hasDotTypeDotSizeDirective())
1072 OutStreamer->emitSymbolAttribute(Sym, MCSA_ELF_TypeFunction);
1077 /// emitComments - Pretty-print comments for instructions.
1080 const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo();
1088 CommentOS << Size->getValue() << "-byte Reload\n";
1090 if (!Size->hasValue())
1091 CommentOS << "Unknown-size Folded Reload\n";
1092 else if (Size->getValue())
1093 CommentOS << Size->getValue() << "-byte Folded Reload\n";
1095 CommentOS << Size->getValue() << "-byte Spill\n";
1097 if (!Size->hasValue())
1098 CommentOS << "Unknown-size Folded Spill\n";
1099 else if (Size->getValue())
1100 CommentOS << Size->getValue() << "-byte Folded Spill\n";
1103 // Check for spill-induced copies
1108 /// emitImplicitDef - This method emits the specified machine instruction
1111 Register RegNo = MI->getOperand(0).getReg();
1115 OS << "implicit-def: "
1116 << printReg(RegNo, MF->getSubtarget().getRegisterInfo());
1118 OutStreamer->AddComment(OS.str());
1119 OutStreamer->addBlankLine();
1126 for (const MachineOperand &Op : MI->operands()) {
1129 << printReg(Op.getReg(), AP.MF->getSubtarget().getRegisterInfo());
1131 AP.OutStreamer->AddComment(Str);
1132 AP.OutStreamer->addBlankLine();
1135 /// emitDebugValueComment - This method handles the target-independent form
1139 // This code handles only the 4-operand target-independent form.
1140 if (MI->isNonListDebugValue() && MI->getNumOperands() != 4)
1147 const DILocalVariable *V = MI->getDebugVariable();
1148 if (auto *SP = dyn_cast<DISubprogram>(V->getScope())) {
1149 StringRef Name = SP->getName();
1153 OS << V->getName();
1154 OS << " <- ";
1156 const DIExpression *Expr = MI->getDebugExpression();
1157 // First convert this to a non-variadic expression if possible, to simplify
1161 // Then, output the possibly-simplified expression.
1162 if (Expr->getNumElements()) {
1165 for (auto &Op : Expr->expr_ops()) {
1174 for (const MachineOperand &Op : MI->debug_operands()) {
1175 if (&Op != MI->debug_operands().begin())
1179 APFloat APF = APFloat(Op.getFPImm()->getValueAPF());
1180 Type *ImmTy = Op.getFPImm()->getType();
1181 if (ImmTy->isBFloatTy() || ImmTy->isHalfTy() || ImmTy->isFloatTy() ||
1182 ImmTy->isDoubleTy()) {
1199 Op.getCImm()->getValue().print(OS, false /*isSigned*/);
1203 OS << "!target-index(" << Op.getIndex() << "," << Op.getOffset() << ")";
1214 AP.MF->getSubtarget().getFrameLowering();
1215 Offset = TFI->getFrameIndexReference(*AP.MF, Op.getIndex(), Reg);
1223 if (MI->isIndirectDebugValue())
1224 Offset = StackOffset::getFixed(MI->getDebugOffset().getImm());
1227 OS << printReg(Reg, AP.MF->getSubtarget().getRegisterInfo());
1229 OS << '+' << Offset->getFixed() << ']';
1238 AP.OutStreamer->emitRawComment(Str);
1242 /// This method handles the target-independent form of DBG_LABEL, returning
1246 if (MI->getNumOperands() != 1)
1253 const DILabel *V = MI->getDebugLabel();
1255 V->getScope()->getNonLexicalBlockFileScope())) {
1256 StringRef Name = SP->getName();
1260 OS << V->getName();
1263 AP.OutStreamer->emitRawComment(OS.str());
1273 if (MAI->getExceptionHandlingType() == ExceptionHandling::DwarfCFI &&
1277 if (MAI->usesCFIWithoutEH() && F.hasUWTable())
1281 if (MMI->hasDebugInfo() || TM.Options.ForceDwarfFrameSection)
1293 return MAI->usesWindowsCFI() && MF->getFunction().needsUnwindTableEntry();
1297 return MAI->usesCFIWithoutEH() && ModuleCFISection != CFISection::None;
1301 ExceptionHandling ExceptionHandlingType = MAI->getExceptionHandlingType();
1314 while (I != MBB->end() && I->isTransient())
1316 if (I == MBB->instr_end() &&
1317 MBB->getReverseIterator() == MBB->getParent()->rbegin())
1320 const std::vector<MCCFIInstruction> &Instrs = MF->getFrameInstructions();
1332 OutStreamer->emitAssignment(FrameAllocSym,
1340 const TargetInstrInfo *TII = MBB.getParent()->getSubtarget().getInstrInfo();
1342 MBB.isReturnBlock(), !MBB.empty() && TII->isTailCall(MBB.back()),
1344 !MBB.empty() && MBB.rbegin()->isIndirectBranch()}
1363 OutStreamer->pushSection();
1364 OutStreamer->switchSection(BBAddrMapSection);
1365 OutStreamer->AddComment("version");
1366 uint8_t BBAddrMapVersion = OutStreamer->getContext().getBBAddrMapVersion();
1367 OutStreamer->emitInt8(BBAddrMapVersion);
1368 OutStreamer->AddComment("feature");
1370 OutStreamer->emitInt8(Features.encode());
1373 OutStreamer->AddComment("number of basic block ranges");
1374 OutStreamer->emitULEB128IntValue(MBBSectionRanges.size());
1380 OutStreamer->AddComment("function address");
1381 OutStreamer->emitSymbolValue(FunctionSymbol, getPointerSize());
1382 OutStreamer->AddComment("number of basic blocks");
1383 OutStreamer->emitULEB128IntValue(MF.size());
1404 OutStreamer->AddComment("base address");
1405 OutStreamer->emitSymbolValue(MBBSymbol, getPointerSize());
1406 OutStreamer->AddComment("number of basic blocks");
1407 OutStreamer->emitULEB128IntValue(MBBSectionNumBlocks[MBB.getSectionID()]);
1412 OutStreamer->AddComment("BB id");
1415 // basic-block-sections=labels.
1418 OutStreamer->emitULEB128IntValue(MBB.getBBID()->BaseID);
1427 OutStreamer->emitULEB128IntValue(getBBAddrMapMetadata(MBB));
1436 OutStreamer->AddComment("function entry count");
1438 OutStreamer->emitULEB128IntValue(
1439 MaybeEntryCount ? MaybeEntryCount->getCount() : 0);
1453 OutStreamer->AddComment("basic block frequency");
1454 OutStreamer->emitULEB128IntValue(
1455 MBFI->getBlockFreq(&MBB).getFrequency());
1459 OutStreamer->AddComment("basic block successor count");
1460 OutStreamer->emitULEB128IntValue(SuccCount);
1462 OutStreamer->AddComment("successor BB ID");
1463 OutStreamer->emitULEB128IntValue(SuccMBB->getBBID()->BaseID);
1464 OutStreamer->AddComment("successor branch probability");
1465 OutStreamer->emitULEB128IntValue(
1466 MBPI->getEdgeProbability(&MBB, SuccMBB).getNumerator());
1473 OutStreamer->popSection();
1483 OutStreamer->pushSection();
1484 OutStreamer->switchSection(Section);
1487 OutStreamer->emitLabel(Loc);
1488 OutStreamer->emitAbsoluteSymbolDiff(Symbol, Loc, 4);
1490 OutStreamer->popSection();
1497 mdconst::extract<ConstantInt>(MD->getOperand(0)));
1507 PP->emitPseudoProbe(GUID, Index, Type, Attr, DebugLoc);
1525 OutStreamer->pushSection();
1526 OutStreamer->switchSection(StackSizeSection);
1531 OutStreamer->emitSymbolValue(FunctionSymbol, TM.getProgramPointerSize());
1532 OutStreamer->emitULEB128IntValue(StackSize);
1534 OutStreamer->popSection();
1540 // OutputFilename empty implies -fstack-usage is not passed.
1559 *StackUsageStream << DSP->getFilename() << ':' << DSP->getLine();
1561 *StackUsageStream << MF.getFunction().getParent()->getName();
1573 OutStreamer->emitLabel(S);
1587 // Switch to PCSection, short-circuiting the common case where the current
1594 OutStreamer->switchSection(S);
1608 // Find options for this section "<section>!<opts>" - supported options:
1609 // C = Compress constant integers of size 2-8 bytes as ULEB128.
1610 const StringRef SecWithOpt = S->getString();
1625 OutStreamer->emitLabel(Base);
1626 // Emit relative relocation `addr - base`, which avoids a dynamic
1643 for (const MDOperand &AuxMDO : AuxMDs->operands()) {
1645 const Constant *C = cast<ConstantAsMetadata>(AuxMDO)->getValue();
1647 const uint64_t Size = DL.getTypeStoreSize(C->getType());
1651 emitULEB128(CI->getZExtValue());
1660 OutStreamer->pushSection();
1667 OutStreamer->popSection();
1687 /// EmitFunctionBody - This method emits the body and trailer for a
1692 // Emit target-specific gunk before the function body.
1698 MDT = MDTWrapper ? &MDTWrapper->getDomTree() : nullptr;
1701 OwnedMDT->getBase().recalculate(*MF);
1707 MLI = MLIWrapper ? &MLIWrapper->getLI() : nullptr;
1710 OwnedMLI->analyze(MDT->getBase());
1718 bool IsEHa = MMI->getModule()->getModuleFlag("eh-asynch");
1720 bool CanDoExtraAnalysis = ORE->allowExtraAnalysis(DEBUG_TYPE);
1733 // If there is a pre-instruction symbol, emit a label for it here.
1735 OutStreamer->emitLabel(S);
1741 Handler->beginInstruction(&MI);
1744 emitComments(MI, OutStreamer->getCommentOS());
1755 OutStreamer->emitLabel(MI.getOperand(0).getMCSymbol());
1758 OutStreamer->emitLabel(MI.getOperand(0).getMCSymbol());
1762 // Ignore SDiv/UDiv because a DIV with Const-0 divisor
1769 (MI2->mayLoadOrStore() || MI2->mayRaiseFPException()))
1810 OutStreamer->emitRawComment("ARITH_FENCE");
1813 OutStreamer->emitRawComment("MEMBARRIER");
1824 auto Name = OutStreamer->getMnemonic(MCI);
1826 I.first->second++;
1831 // If there is a post-instruction symbol, emit a label for it here.
1833 OutStreamer->emitLabel(S);
1836 Handler->endInstruction();
1842 if (MF->hasBBLabels() || MF->getTarget().Options.BBAddrMap ||
1843 (MAI->hasDotTypeDotSizeDirective() && MBB.isEndSection()))
1844 OutStreamer->emitLabel(MBB.getEndSymbol());
1849 if (!MBB.sameSection(&MF->front())) {
1850 if (MAI->hasDotTypeDotSizeDirective()) {
1856 OutStreamer->emitELFSize(CurrentSectionBeginSym, SizeExp);
1872 MBB.begin()->getDebugLoc(), &MBB);
1893 ORE->emit(R);
1899 MF->getFunction().getSubprogram(),
1900 &MF->front());
1903 ORE->emit(R);
1911 // https://developercommunity.visualstudio.com/content/problem/45366/vc-linker-creates-invalid-dll-with-clang-cl.html
1914 if (!HasAnyRealCode && (MAI->hasSubsectionsViaSymbols() ||
1916 MCInst Noop = MF->getSubtarget().getInstrInfo()->getNop();
1918 // Targets can opt-out of emitting the noop here by leaving the opcode
1921 OutStreamer->AddComment("avoids zero-length function");
1927 OutStreamer->switchSection(MF->getSection());
1929 const Function &F = MF->getFunction();
1934 if (Sym->isDefined())
1936 OutStreamer->AddComment("Address of block that was removed by CodeGen");
1937 OutStreamer->emitLabel(Sym);
1940 // Emit target-specific gunk after the function body.
1945 bool EmitFunctionSize = MAI->hasDotTypeDotSizeDirective() && !TT.isWasm();
1950 OutStreamer->emitLabel(CurrentFnEnd);
1961 OutStreamer->emitELFSize(CurrentFnSym, SizeExp);
1963 OutStreamer->emitELFSize(CurrentFnBeginLocal, SizeExp);
1968 if (!MF->back().isEndSection()) {
1970 Handler->endBasicBlockSection(MF->back());
1972 Handler->endBasicBlockSection(MF->back());
1975 Handler->markFunctionEnd();
1977 assert(!MBBSectionRanges.contains(MF->front().getSectionID()) &&
1979 MBBSectionRanges[MF->front().getSectionID()] =
1985 // Emit post-function debug and/or EH information.
1987 Handler->endFunction(MF);
1989 Handler->endFunction(MF);
1994 if (MF->hasBBLabels() || MF->getTarget().Options.BBAddrMap)
1997 MF->getContext().reportWarning(
1998 SMLoc(), "pgo-analysis-map is enabled for function " + MF->getName() +
2014 OutStreamer->getCommentOS() << "-- End function\n";
2016 OutStreamer->addBlankLine();
2028 for (const auto *CU : C->users())
2044 if (!GV->hasGlobalUnnamedAddr() || !GV->hasInitializer() ||
2045 !GV->isConstant() || !GV->isDiscardableIfUnused() ||
2046 !isa<GlobalValue>(GV->getOperand(0)))
2051 for (const auto *U : GV->users())
2100 bool IsFunction = GA.getValueType()->isFunctionTy();
2104 IsFunction = isa<Function>(GA.getAliasee()->stripPointerCasts());
2107 // so AIX has to use the extra-label-at-definition strategy. At this
2108 // point, all the extra label is emitted, we just have to emit linkage for
2111 assert(MAI->hasVisibilityOnlyWithLinkage() &&
2127 if (GA.hasExternalLinkage() || !MAI->getWeakRefDirective())
2128 OutStreamer->emitSymbolAttribute(Name, MCSA_Global);
2130 OutStreamer->emitSymbolAttribute(Name, MCSA_WeakReference);
2137 OutStreamer->emitSymbolAttribute(Name, MCSA_ELF_TypeFunction);
2139 OutStreamer->beginCOFFSymbolDef(Name);
2140 OutStreamer->emitCOFFSymbolStorageClass(
2143 OutStreamer->emitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION
2145 OutStreamer->endCOFFSymbolDef();
2153 if (MAI->hasAltEntry() && isa<MCBinaryExpr>(Expr))
2154 OutStreamer->emitSymbolAttribute(Name, MCSA_AltEntry);
2157 OutStreamer->emitAssignment(Name, Expr);
2160 OutStreamer->emitAssignment(LocalAlias, Expr);
2168 if (MAI->hasDotTypeDotSizeDirective() && GA.getValueType()->isSized() &&
2169 (!BaseObject || BaseObject->hasPrivateLinkage())) {
2172 OutStreamer->emitELFSize(Name, MCConstantExpr::create(Size, OutContext));
2181 if (GI.hasExternalLinkage() || !MAI->getWeakRefDirective())
2182 OutStreamer->emitSymbolAttribute(Sym, MCSA_Global);
2184 OutStreamer->emitSymbolAttribute(Sym, MCSA_WeakReference);
2192 OutStreamer->emitSymbolAttribute(Name, MCSA_ELF_TypeIndFunction);
2197 OutStreamer->emitAssignment(Name, Expr);
2200 OutStreamer->emitAssignment(LocalAlias, Expr);
2208 // On Darwin platforms, emit a manually-constructed .symbol_resolver that
2212 // are a few limitations in ld64 and ld-prime's implementation of
2228 OutStreamer->switchSection(OutContext.getObjectFileInfo()->getDataSection());
2232 OutStreamer->emitLabel(LazyPointer);
2234 OutStreamer->emitValue(MCSymbolRefExpr::create(StubHelper, OutContext), 8);
2236 OutStreamer->switchSection(OutContext.getObjectFileInfo()->getTextSection());
2240 const TargetLowering *TLI = STI->getTargetLowering();
2241 Align TextAlign(TLI->getMinFunctionAlignment());
2245 OutStreamer->emitCodeAlignment(TextAlign, getIFuncMCSubtargetInfo());
2246 OutStreamer->emitLabel(Stub);
2250 OutStreamer->emitCodeAlignment(TextAlign, getIFuncMCSubtargetInfo());
2251 OutStreamer->emitLabel(StubHelper);
2266 assert(!Filename->empty() && "The filename can't be empty.");
2272 Filename ? RemarkSerializer.metaSerializer(OS, Filename->str())
2274 MetaSerializer->emit();
2278 OutContext.getObjectFileInfo()->getRemarksSection();
2279 OutStreamer->switchSection(RemarksSection);
2281 OutStreamer->emitBinaryData(Buf);
2347 MachineModuleInfoELF &MMIELF = MMI->getObjFileInfo<MachineModuleInfoELF>();
2352 OutStreamer->switchSection(TLOF.getDataSection());
2357 OutStreamer->emitLabel(Stub.first);
2358 OutStreamer->emitSymbolValue(Stub.second.getPointer(),
2366 MMI->getObjFileInfo<MachineModuleInfoCOFF>();
2375 SectionName += Stub.first->getName();
2376 OutStreamer->switchSection(OutContext.getCOFFSection(
2380 Stub.first->getName(), COFF::IMAGE_COMDAT_SELECT_ANY));
2382 OutStreamer->emitSymbolAttribute(Stub.first, MCSA_Global);
2383 OutStreamer->emitLabel(Stub.first);
2384 OutStreamer->emitSymbolValue(Stub.second.getPointer(),
2392 if (auto *TS = OutStreamer->getTargetStreamer())
2393 TS->emitConstantPools();
2395 // Emit Stack maps before any debug info. Mach-O requires that no data or
2411 Cur = dyn_cast<GlobalAlias>(Cur->getAliasee())) {
2422 // as actual functions, since on Mach-O targets, we cannot create regular
2429 Handler->endModule();
2431 Handler->endModule();
2434 // keeping all the user-added handlers alive until the AsmPrinter is
2442 if (MAI->getWeakRefDirective()) {
2448 // Print out module-level global objects here.
2452 OutStreamer->emitSymbolAttribute(getSymbol(&GO), MCSA_WeakReference);
2462 OutStreamer->emitSymbolAttribute(getSymbol(Global), MCSA_WeakReference);
2469 for (GCModuleInfo::iterator I = MI->end(), E = MI->begin(); I != E; )
2470 if (GCMetadataPrinter *MP = getOrCreateGCPrinter(**--I))
2471 MP->finishAssembly(M, *MI, *this);
2481 // Emit .note.GNU-split-stack and .note.GNU-no-split-stack sections if
2482 // split-stack is used.
2484 OutStreamer->switchSection(OutContext.getELFSection(".note.GNU-split-stack",
2487 OutStreamer->switchSection(OutContext.getELFSection(
2488 ".note.GNU-no-split-stack", ELF::SHT_PROGBITS, 0));
2494 if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->use_empty())
2495 if (MCSection *S = MAI->getNonexecutableStackSection(OutContext))
2496 OutStreamer->switchSection(S);
2499 // Emit address-significance attributes for all globals.
2500 OutStreamer->emitAddrsig();
2506 OutStreamer->emitAddrsigSym(getSymbol(&GV));
2518 OutStreamer->switchSection(
2521 OutStreamer->emitBytes(GV.getPartition());
2522 OutStreamer->emitZeros(1);
2523 OutStreamer->emitValue(
2525 MAI->getCodePointerSize());
2536 OutStreamer->finish();
2537 OutStreamer->reset();
2547 Res.first->second = createTempSymbol("exception");
2548 return Res.first->second;
2552 this->MF = &MF;
2555 // Record that there are split-stack functions, so we will emit a special
2566 if (!MAI->needsFunctionDescriptors()) {
2573 // C-linkage name.
2587 bool NeedsLocalForSize = MAI->needsLocalForSize();
2588 if (F.hasFnAttribute("patchable-function-entry") ||
2589 F.hasFnAttribute("function-instrument") ||
2590 F.hasFnAttribute("xray-instruction-threshold") ||
2615 /// EmitConstantPool - Print to the current output stream assembly
2620 const MachineConstantPool *MCP = MF->getConstantPool();
2621 const std::vector<MachineConstantPoolEntry> &CP = MCP->getConstants();
2645 if (CPSections[--SecIdx].S == S) {
2667 if (!Sym->isUndefined())
2671 OutStreamer->switchSection(CPSections[i].S);
2679 // Emit inter-object padding for alignment.
2681 OutStreamer->emitZeros(NewOffset - Offset);
2685 OutStreamer->emitLabel(Sym);
2697 const DataLayout &DL = MF->getDataLayout();
2698 const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
2700 if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_Inline) return;
2701 const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
2706 const Function &F = MF->getFunction();
2709 MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 ||
2710 MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference64,
2715 OutStreamer->switchSection(ReadOnlySection);
2718 emitAlignment(Align(MJTI->getEntryAlignment(DL)));
2723 OutStreamer->emitDataRegion(MCDR_DataRegionJT32);
2733 if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 &&
2734 MAI->doesSetDirectiveSuppressReloc()) {
2736 const TargetLowering *TLI = MF->getSubtarget().getTargetLowering();
2737 const MCExpr *Base = TLI->getPICJumpTableRelocBaseExpr(MF,JTI,OutContext);
2742 // .set LJTSet, LBB32-base
2744 MCSymbolRefExpr::create(MBB->getSymbol(), OutContext);
2745 OutStreamer->emitAssignment(GetJTSetSymbol(JTI, MBB->getNumber()),
2759 OutStreamer->emitLabel(GetJTISymbol(JTI, true));
2762 OutStreamer->emitLabel(JTISymbol);
2770 OutStreamer->emitDataRegion(MCDR_DataRegionEnd);
2773 /// EmitJumpTableEntry - Emit a jump table entry for the specified MBB to the
2778 assert(MBB && MBB->getNumber() >= 0 && "Invalid basic block");
2780 switch (MJTI->getEntryKind()) {
2784 Value = MF->getSubtarget().getTargetLowering()->LowerCustomJumpTableEntry(
2788 // EK_BlockAddress - Each entry is a plain address of block, e.g.:
2790 Value = MCSymbolRefExpr::create(MBB->getSymbol(), OutContext);
2793 // EK_GPRel32BlockAddress - Each entry is an address of block, encoded
2794 // with a relocation as gp-relative, e.g.:
2796 MCSymbol *MBBSym = MBB->getSymbol();
2797 OutStreamer->emitGPRel32Value(MCSymbolRefExpr::create(MBBSym, OutContext));
2802 // EK_GPRel64BlockAddress - Each entry is an address of block, encoded
2803 // with a relocation as gp-relative, e.g.:
2805 MCSymbol *MBBSym = MBB->getSymbol();
2806 OutStreamer->emitGPRel64Value(MCSymbolRefExpr::create(MBBSym, OutContext));
2815 // .word LBB123 - LJTI1_2
2817 // .set L4_5_set_123, LBB123 - LJTI1_2
2819 if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 &&
2820 MAI->doesSetDirectiveSuppressReloc()) {
2821 Value = MCSymbolRefExpr::create(GetJTSetSymbol(UID, MBB->getNumber()),
2825 Value = MCSymbolRefExpr::create(MBB->getSymbol(), OutContext);
2826 const TargetLowering *TLI = MF->getSubtarget().getTargetLowering();
2827 const MCExpr *Base = TLI->getPICJumpTableRelocBaseExpr(MF, UID, OutContext);
2835 unsigned EntrySize = MJTI->getEntrySize(getDataLayout());
2836 OutStreamer->emitValue(Value, EntrySize);
2839 /// EmitSpecialLLVMGlobal - Check to see if the specified global is a
2843 if (GV->getName() == "llvm.used") {
2844 if (MAI->hasNoDeadStrip()) // No need to emit this at all.
2845 emitLLVMUsedList(cast<ConstantArray>(GV->getInitializer()));
2849 // Ignore debug and non-emitted data. This handles llvm.compiler.used.
2850 if (GV->getSection() == "llvm.metadata" ||
2851 GV->hasAvailableExternallyLinkage())
2854 if (GV->getName() == "llvm.arm64ec.symbolmap") {
2858 OutStreamer->switchSection(
2860 auto *Arr = cast<ConstantArray>(GV->getInitializer());
2861 for (auto &U : Arr->operands()) {
2863 auto *Src = cast<GlobalValue>(C->getOperand(0)->stripPointerCasts());
2864 auto *Dst = cast<GlobalValue>(C->getOperand(1)->stripPointerCasts());
2865 int Kind = cast<ConstantInt>(C->getOperand(2))->getZExtValue();
2867 if (Src->hasDLLImportStorageClass()) {
2870 OutStreamer->emitCOFFSymbolIndex(
2871 OutContext.getOrCreateSymbol("__imp_" + Src->getName()));
2872 OutStreamer->emitCOFFSymbolIndex(getSymbol(Dst));
2873 OutStreamer->emitInt32(Kind);
2875 // FIXME: For non-dllimport functions, MSVC emits the same entry
2879 OutStreamer->emitCOFFSymbolIndex(getSymbol(Src));
2880 OutStreamer->emitCOFFSymbolIndex(getSymbol(Dst));
2881 OutStreamer->emitInt32(Kind);
2887 if (!GV->hasAppendingLinkage()) return false;
2889 assert(GV->hasInitializer() && "Not a special LLVM global!");
2891 if (GV->getName() == "llvm.global_ctors") {
2892 emitXXStructorList(GV->getDataLayout(), GV->getInitializer(),
2898 if (GV->getName() == "llvm.global_dtors") {
2899 emitXXStructorList(GV->getDataLayout(), GV->getInitializer(),
2908 /// EmitLLVMUsedList - For targets that define a MAI::UsedDirective, mark each
2912 for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
2914 dyn_cast<GlobalValue>(InitList->getOperand(i)->stripPointerCasts());
2916 OutStreamer->emitSymbolAttribute(getSymbol(GV), MCSA_NoDeadStrip);
2929 for (Value *O : cast<ConstantArray>(List)->operands()) {
2930 auto *CS = cast<ConstantStruct>(O);
2931 if (CS->getOperand(1)->isNullValue())
2933 ConstantInt *Priority = dyn_cast<ConstantInt>(CS->getOperand(0));
2938 S.Priority = Priority->getLimitedValue(65535);
2939 S.Func = CS->getOperand(1);
2940 if (!CS->getOperand(2)->isNullValue()) {
2945 dyn_cast<GlobalValue>(CS->getOperand(2)->stripPointerCasts());
2949 // Emit the function pointers in the target-specific order
2955 /// EmitXXStructorList - Emit the ctor or dtor list taking into account the init
2974 if (GV->isDeclarationForLinker())
2988 OutStreamer->switchSection(OutputSection);
2989 if (OutStreamer->getCurrentSection() != OutStreamer->getPreviousSection())
2996 if (!MAI->hasIdentDirective())
3000 for (const MDNode *N : NMD->operands()) {
3001 assert(N->getNumOperands() == 1 &&
3003 const MDString *S = cast<MDString>(N->getOperand(0));
3004 OutStreamer->emitIdent(S->getString());
3015 if (!NMD || !NMD->getNumOperands())
3018 OutStreamer->pushSection();
3019 OutStreamer->switchSection(CommandLine);
3020 OutStreamer->emitZeros(1);
3021 for (const MDNode *N : NMD->operands()) {
3022 assert(N->getNumOperands() == 1 &&
3024 const MDString *S = cast<MDString>(N->getOperand(0));
3025 OutStreamer->emitBytes(S->getString());
3026 OutStreamer->emitZeros(1);
3028 OutStreamer->popSection();
3031 //===--------------------------------------------------------------------===//
3037 void AsmPrinter::emitInt8(int Value) const { OutStreamer->emitInt8(Value); }
3040 void AsmPrinter::emitInt16(int Value) const { OutStreamer->emitInt16(Value); }
3043 void AsmPrinter::emitInt32(int Value) const { OutStreamer->emitInt32(Value); }
3045 /// EmitSLEB128 - emit the specified signed leb128 value.
3048 OutStreamer->AddComment(Desc);
3050 OutStreamer->emitSLEB128IntValue(Value);
3056 OutStreamer->AddComment(Desc);
3058 OutStreamer->emitULEB128IntValue(Value, PadTo);
3063 OutStreamer->emitInt64(Value);
3066 /// Emit something like ".long Hi-Lo" where the size in bytes of the directive
3071 OutStreamer->emitAbsoluteSymbolDiff(Hi, Lo, Size);
3074 /// Emit something like ".uleb128 Hi-Lo".
3077 OutStreamer->emitAbsoluteSymbolDiffAsULEB128(Hi, Lo);
3080 /// EmitLabelPlusOffset - Emit something like ".long Label+Offset"
3086 if (MAI->needsDwarfSectionOffsetDirective() && IsSectionRelative) {
3087 OutStreamer->emitCOFFSecRel32(Label, Offset);
3089 OutStreamer->emitZeros(Size - 4);
3099 OutStreamer->emitValue(Expr, Size);
3102 //===----------------------------------------------------------------------===//
3104 // EmitAlignment - Emit an alignment directive to the specified power of
3111 Alignment = getGVAlignment(GV, GV->getDataLayout(), Alignment);
3114 return; // 1-byte aligned: no need to emit alignment.
3116 if (getCurrentSection()->isText()) {
3118 if (this->MF)
3122 OutStreamer->emitCodeAlignment(Alignment, STI, MaxBytesToEmit);
3124 OutStreamer->emitValueToAlignment(Alignment, 0, 1, MaxBytesToEmit);
3127 //===----------------------------------------------------------------------===//
3129 //===----------------------------------------------------------------------===//
3134 if (CV->isNullValue() || isa<UndefValue>(CV))
3138 return MCConstantExpr::create(CI->getZExtValue(), Ctx);
3153 return MCSymbolRefExpr::create(getSymbol(NC->getGlobalValue()), Ctx);
3163 switch (CE->getOpcode()) {
3167 const Constant *Op = CE->getOperand(0);
3168 unsigned DstAS = CE->getType()->getPointerAddressSpace();
3169 unsigned SrcAS = Op->getType()->getPointerAddressSpace();
3177 APInt OffsetAI(getDataLayout().getPointerTypeSizeInBits(CE->getType()), 0);
3178 cast<GEPOperator>(CE)->accumulateConstantOffset(getDataLayout(), OffsetAI);
3180 const MCExpr *Base = lowerConstant(CE->getOperand(0));
3193 // is reasonable to treat their delta as a 32-bit value.
3196 return lowerConstant(CE->getOperand(0));
3203 Constant *Op = CE->getOperand(0);
3204 Op = ConstantFoldIntegerCast(Op, DL.getIntPtrType(CV->getType()),
3217 Constant *Op = CE->getOperand(0);
3218 Type *Ty = CE->getType();
3228 DL.getTypeAllocSize(Op->getType()).getFixedValue())
3238 if (IsConstantOffsetFromGlobal(CE->getOperand(0), LHSGV, LHSOffset,
3242 if (IsConstantOffsetFromGlobal(CE->getOperand(1), RHSGV, RHSOffset,
3256 int64_t Addend = (LHSOffset - RHSOffset).getSExtValue();
3264 const MCExpr *LHS = lowerConstant(CE->getOperand(0));
3265 const MCExpr *RHS = lowerConstant(CE->getOperand(1));
3271 const MCExpr *LHS = lowerConstant(CE->getOperand(0));
3272 const MCExpr *RHS = lowerConstant(CE->getOperand(1));
3288 CE->printAsOperand(OS, /*PrintType=*/false,
3289 !MF ? nullptr : MF->getFunction().getParent());
3302 /// isRepeatedByteSequence - Determine whether the given value is
3304 /// byte value. If it is not a repeated sequence, return -1.
3306 StringRef Data = V->getRawDataValues();
3310 if (Data[i] != C) return -1;
3311 return static_cast<uint8_t>(C); // Ensure 255 is not returned as -1.
3314 /// isRepeatedByteSequence - Determine whether the given value is
3316 /// byte value. If it is not a repeated sequence, return -1.
3319 uint64_t Size = DL.getTypeAllocSizeInBits(V->getType());
3323 APInt Value = CI->getValue().zext(Size);
3325 return -1;
3332 assert(CA->getNumOperands() != 0 && "Should be a CAZ");
3333 Constant *Op0 = CA->getOperand(0);
3335 if (Byte == -1)
3336 return -1;
3339 for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i)
3340 if (CA->getOperand(i) != Op0)
3341 return -1;
3348 return -1;
3354 auto AliasIt = AliasList->find(Offset);
3355 if (AliasIt != AliasList->end()) {
3356 for (const GlobalAlias *GA : AliasIt->second)
3357 AP.OutStreamer->emitLabel(AP.getSymbol(GA));
3358 AliasList->erase(Offset);
3368 if (Value != -1) {
3369 uint64_t Bytes = DL.getTypeAllocSize(CDS->getType());
3370 // Don't emit a 1-byte object as a .fill.
3372 return AP.OutStreamer->emitFill(Bytes, Value);
3376 if (CDS->isString())
3377 return AP.OutStreamer->emitBytes(CDS->getAsString());
3380 unsigned ElementByteSize = CDS->getElementByteSize();
3381 if (isa<IntegerType>(CDS->getElementType())) {
3382 for (unsigned I = 0, E = CDS->getNumElements(); I != E; ++I) {
3385 AP.OutStreamer->getCommentOS()
3386 << format("0x%" PRIx64 "\n", CDS->getElementAsInteger(I));
3387 AP.OutStreamer->emitIntValue(CDS->getElementAsInteger(I),
3391 Type *ET = CDS->getElementType();
3392 for (unsigned I = 0, E = CDS->getNumElements(); I != E; ++I) {
3394 emitGlobalConstantFP(CDS->getElementAsAPFloat(I), ET, AP);
3398 unsigned Size = DL.getTypeAllocSize(CDS->getType());
3400 DL.getTypeAllocSize(CDS->getElementType()) * CDS->getNumElements();
3402 if (unsigned Padding = Size - EmittedSize)
3403 AP.OutStreamer->emitZeros(Padding);
3414 if (Value != -1) {
3415 uint64_t Bytes = DL.getTypeAllocSize(CA->getType());
3416 AP.OutStreamer->emitFill(Bytes, Value);
3418 for (unsigned I = 0, E = CA->getNumOperands(); I != E; ++I) {
3419 emitGlobalConstantImpl(DL, CA->getOperand(I), AP, BaseCV, Offset,
3421 Offset += DL.getTypeAllocSize(CA->getOperand(I)->getType());
3431 Type *ElementType = CV->getType()->getElementType();
3442 IntegerType::get(CV->getContext(), DL.getTypeSizeInBits(CV->getType()));
3451 EmittedSize = DL.getTypeStoreSize(CV->getType());
3453 for (unsigned I = 0, E = CV->getType()->getNumElements(); I != E; ++I) {
3454 emitGlobalAliasInline(AP, DL.getTypeAllocSize(CV->getType()) * I, AliasList);
3455 emitGlobalConstantImpl(DL, CV->getOperand(I), AP);
3458 DL.getTypeAllocSize(ElementType) * CV->getType()->getNumElements();
3461 unsigned Size = DL.getTypeAllocSize(CV->getType());
3462 if (unsigned Padding = Size - EmittedSize)
3463 AP.OutStreamer->emitZeros(Padding);
3467 const ConstantStruct *CS, AsmPrinter &AP,
3471 uint64_t Size = DL.getTypeAllocSize(CS->getType());
3472 const StructLayout *Layout = DL.getStructLayout(CS->getType());
3474 for (unsigned I = 0, E = CS->getNumOperands(); I != E; ++I) {
3475 const Constant *Field = CS->getOperand(I);
3482 uint64_t FieldSize = DL.getTypeAllocSize(Field->getType());
3483 uint64_t PadSize = ((I == E - 1 ? Size : Layout->getElementOffset(I + 1)) -
3484 Layout->getElementOffset(I)) -
3488 // Insert padding - this may include padding to increase the size of the
3491 AP.OutStreamer->emitZeros(PadSize);
3493 assert(SizeSoFar == Layout->getSizeInBytes() &&
3501 // First print a comment with what we think the original floating-point value
3506 ET->print(AP.OutStreamer->getCommentOS());
3507 AP.OutStreamer->getCommentOS() << ' ' << StrVal << '\n';
3510 // Now iterate through the APInt chunks, emitting them in endian-correct
3511 // order, possibly with a smaller chunk at beginning/end (e.g. for x87 80-bit
3519 if (AP.getDataLayout().isBigEndian() && !ET->isPPC_FP128Ty()) {
3520 int Chunk = API.getNumWords() - 1;
3523 AP.OutStreamer->emitIntValueInHexWithPadding(p[Chunk--], TrailingBytes);
3525 for (; Chunk >= 0; --Chunk)
3526 AP.OutStreamer->emitIntValueInHexWithPadding(p[Chunk], sizeof(uint64_t));
3530 AP.OutStreamer->emitIntValueInHexWithPadding(p[Chunk], sizeof(uint64_t));
3533 AP.OutStreamer->emitIntValueInHexWithPadding(p[Chunk], TrailingBytes);
3538 AP.OutStreamer->emitZeros(DL.getTypeAllocSize(ET) - DL.getTypeStoreSize(ET));
3542 emitGlobalConstantFP(CFP->getValueAPF(), CFP->getType(), AP);
3547 unsigned BitWidth = CI->getBitWidth();
3550 // is not a multiple of 64-bits.
3551 APInt Realigned(CI->getValue());
3556 // The bit width of the data is not a multiple of 64-bits.
3557 // The extra bits are expected to be at the end of the chunk of the memory.
3559 // * Nothing to be done, just record the extra bits to emit.
3561 // * Record the extra bits to emit.
3562 // * Realign the raw data to emit the chunks of 64-bits.
3564 // Basically the structure of the raw data is a chunk of 64-bits cells:
3570 // ExtraBits 0 1 (BitWidth / 64) - 1
3571 // chu[nk1 chu][nk2 chu] ... [nkN-1 chunkN]
3574 (((uint64_t)-1) >> (64 - ExtraBitsSize));
3582 // for more than 64 bits, so we emit the data in at most 64-bit
3586 uint64_t Val = DL.isBigEndian() ? RawData[e - i - 1] : RawData[i];
3587 AP.OutStreamer->emitIntValue(Val, 8);
3591 // Emit the extra bits after the 64-bits chunks.
3594 uint64_t Size = AP.getDataLayout().getTypeStoreSize(CI->getType());
3595 Size -= (BitWidth / 64) * 8;
3597 (ExtraBits & (((uint64_t)-1) >> (64 - ExtraBitsSize)))
3598 == ExtraBits && "Directive too small for extra bits.");
3599 AP.OutStreamer->emitIntValue(ExtraBits, Size);
3622 // cstexpr := <gotequiv> - "." + <cst>
3623 // cstexpr := <gotequiv> - (<foo> - <offset from @foo base>) + <cst>
3627 // cstexpr := <gotequiv> - <foo> + gotpcrelcst, where
3630 if (!(*ME)->evaluateAsRelocatable(MV, nullptr, nullptr) || MV.isAbsolute())
3637 const MCSymbol *GOTEquivSym = &SymA->getSymbol();
3649 if (!SymB || BaseSym != &SymB->getSymbol())
3667 // .long gotequiv - "." + <cst>
3678 const GlobalValue *FinalGV = dyn_cast<GlobalValue>(GV->getOperand(0));
3684 --NumUses;
3694 uint64_t Size = DL.getTypeAllocSize(CV->getType());
3696 // Globals with sub-elements such as combinations of arrays and structs
3699 if (!BaseCV && CV->hasOneUse())
3700 BaseCV = dyn_cast<Constant>(CV->user_back());
3703 return AP.OutStreamer->emitZeros(Size);
3706 const uint64_t StoreSize = DL.getTypeStoreSize(CV->getType());
3710 AP.OutStreamer->getCommentOS()
3711 << format("0x%" PRIx64 "\n", CI->getZExtValue());
3712 AP.OutStreamer->emitIntValue(CI->getZExtValue(), StoreSize);
3719 AP.OutStreamer->emitZeros(Size - StoreSize);
3728 AP.OutStreamer->emitIntValue(0, Size);
3744 if (CE->getOpcode() == Instruction::BitCast)
3745 return emitGlobalConstantImpl(DL, CE->getOperand(0), AP);
3748 // If the constant expression's size is greater than 64-bits, then we have
3770 AP.OutStreamer->emitValue(ME, Size);
3773 /// EmitGlobalConstant - Print a general LLVM constant to the .s file.
3776 uint64_t Size = DL.getTypeAllocSize(CV->getType());
3779 else if (MAI->hasSubsectionsViaSymbols()) {
3782 OutStreamer->emitIntValue(0, 1);
3787 // to handle the case where the alias offset doesn't refer to any sub-element.
3790 OutStreamer->emitLabel(getSymbol(GA));
3807 MCInst Nop = MF->getSubtarget().getInstrInfo()->getNop();
3808 for (; N; --N)
3812 //===----------------------------------------------------------------------===//
3814 //===----------------------------------------------------------------------===//
3821 return const_cast<AsmPrinter *>(this)->getAddrLabelSymbol(
3822 BA->getBasicBlock());
3826 return const_cast<AsmPrinter *>(this)->getAddrLabelSymbol(BB);
3833 /// GetCPISymbol - Return the symbol for the specified constant pool entry.
3837 MF->getConstantPool()->getConstants()[CPID];
3839 const DataLayout &DL = MF->getDataLayout();
3846 if (MCSymbol *Sym = S->getCOMDATSymbol()) {
3847 if (Sym->isUndefined())
3848 OutStreamer->emitSymbolAttribute(Sym, MCSA_Global);
3861 /// GetJTISymbol - Return the symbol for the specified jump table entry.
3863 return MF->getJTISymbol(JTID, OutContext, isLinkerPrivate);
3866 /// GetJTSetSymbol - Return the symbol for the specified jump table .set
3887 /// PrintParentLoopComment - Print comments about parent loops of this one.
3891 PrintParentLoopComment(OS, Loop->getParentLoop(), FunctionNumber);
3892 OS.indent(Loop->getLoopDepth()*2)
3894 << Loop->getHeader()->getNumber()
3895 << " Depth=" << Loop->getLoopDepth() << '\n';
3898 /// PrintChildLoopComment - Print comments about child loops within
3904 OS.indent(CL->getLoopDepth()*2)
3906 << CL->getHeader()->getNumber() << " Depth " << CL->getLoopDepth()
3912 /// emitBasicBlockLoopComments - Pretty-print comments for basic blocks.
3917 const MachineLoop *Loop = LI->getLoopFor(&MBB);
3920 MachineBasicBlock *Header = Loop->getHeader();
3926 AP.OutStreamer->AddComment(" in Loop: Header=BB" +
3928 Twine(Loop->getHeader()->getNumber())+
3929 " Depth="+Twine(Loop->getLoopDepth()));
3935 raw_ostream &OS = AP.OutStreamer->getCommentOS();
3937 PrintParentLoopComment(OS, Loop->getParentLoop(), AP.getFunctionNumber());
3940 OS.indent(Loop->getLoopDepth()*2-2);
3943 if (Loop->isInnermost())
3945 OS << "Loop Header: Depth=" + Twine(Loop->getLoopDepth()) << '\n';
3950 /// emitBasicBlockStart - This method prints the label for the specified
3957 Handler->endFunclet();
3958 Handler->beginFunclet(MBB);
3966 OutStreamer->switchSection(
3967 getObjFileLowering().getSectionForMachineBasicBlock(MF->getFunction(),
3983 OutStreamer->AddComment("Block address taken");
3986 assert(BB && BB->hasAddressTaken() && "Missing BB");
3988 OutStreamer->emitLabel(Sym);
3990 OutStreamer->AddComment("Block address taken");
3996 if (BB->hasName()) {
3997 BB->printAsOperand(OutStreamer->getCommentOS(),
3998 /*PrintType=*/false, BB->getModule());
3999 OutStreamer->getCommentOS() << '\n';
4010 OutStreamer->AddComment("Label of block must be emitted");
4011 OutStreamer->emitLabel(MBB.getSymbol());
4015 OutStreamer->emitRawComment(" %bb." + Twine(MBB.getNumber()) + ":",
4021 MAI->getExceptionHandlingType() == ExceptionHandling::WinEH) {
4022 OutStreamer->emitLabel(MBB.getEHCatchretSymbol());
4030 Handler->beginBasicBlockSection(MBB);
4032 Handler->beginBasicBlockSection(MBB);
4041 Handler->endBasicBlockSection(MBB);
4043 Handler->endBasicBlockSection(MBB);
4055 Attr = MAI->getHiddenVisibilityAttr();
4057 Attr = MAI->getHiddenDeclarationVisibilityAttr();
4060 Attr = MAI->getProtectedVisibilityAttr();
4065 OutStreamer->emitSymbolAttribute(Sym, Attr);
4070 // With `-fbasic-block-sections=`, a label is needed for every non-entry block
4073 if ((MF->hasBBLabels() || MF->getTarget().Options.BBAddrMap ||
4085 /// isBlockOnlyReachableByFallthough - Return true if the basic block has
4087 /// the predecessor and this block is a fall-through.
4092 if (MBB->isEHPad() || MBB->pred_empty())
4096 if (MBB->pred_size() > 1)
4100 MachineBasicBlock *Pred = *MBB->pred_begin();
4101 if (!Pred->isLayoutSuccessor(MBB))
4105 if (Pred->empty())
4109 for (const auto &MI : Pred->terminators()) {
4115 // through. Note that targets with delay slots will usually bundle
4116 // terminators with the delay slot instruction.
4118 if (OP->isJTI())
4120 if (OP->isMBB() && OP->getMBB() == MBB)
4134 return GCPI->second.get();
4142 GMP->S = &S;
4143 GCPI->second = std::move(GMP);
4144 return GCPI->second.get();
4154 if (MI->begin() == MI->end())
4160 if (MP->emitStackMaps(SM, *this))
4192 Out->emitBinaryData(StringRef(reinterpret_cast<const char *>(&Kind8), 1));
4193 Out->emitBinaryData(
4195 Out->emitBinaryData(StringRef(reinterpret_cast<const char *>(&Version), 1));
4196 auto Padding = (4 * Bytes) - ((2 * Bytes) + 3);
4198 Out->emitZeros(Padding);
4205 auto PrevSection = OutStreamer->getCurrentSectionOnly();
4206 const Function &F = MF->getFunction();
4210 // Use PC-relative addresses on all targets.
4217 GroupName = F.getComdat()->getName();
4227 } else if (MF->getSubtarget().getTargetTriple().isOSBinFormatMachO()) {
4239 auto WordSizeBytes = MAI->getCodePointerSize();
4242 // per-function, we are able to create an index entry that will represent the
4247 OutStreamer->switchSection(InstMap);
4248 OutStreamer->emitLabel(SledsStart);
4251 OutStreamer->emitLabel(Dot);
4252 OutStreamer->emitValueImpl(
4256 OutStreamer->emitValueImpl(
4267 OutStreamer->emitLabel(SledsEnd);
4272 // pointers. This should work for both 32-bit and 64-bit platforms.
4274 OutStreamer->switchSection(FnSledIndex);
4275 OutStreamer->emitCodeAlignment(Align(2 * WordSizeBytes),
4277 // For Mach-O, use an "l" symbol as the atom of this subsection. The label
4281 OutStreamer->emitLabel(Dot);
4282 OutStreamer->emitValueImpl(
4286 OutStreamer->emitValueImpl(MCConstantExpr::create(Sleds.size(), Ctx),
4288 OutStreamer->switchSection(PrevSection);
4295 const Function &F = MI.getMF()->getFunction();
4296 auto Attr = F.getFnAttribute("function-instrument");
4297 bool LogArgs = F.hasFnAttribute("xray-log-args");
4299 Attr.isStringAttribute() && Attr.getValueAsString() == "xray-always";
4307 const Function &F = MF->getFunction();
4309 (void)F.getFnAttribute("patchable-function-prefix")
4312 (void)F.getFnAttribute("patchable-function-entry")
4324 // support mixed SHF_LINK_ORDER and non-SHF_LINK_ORDER sections.
4325 if (MAI->useIntegratedAssembler() || MAI->binutilsIsAtLeast(2, 36)) {
4329 GroupName = F.getComdat()->getName();
4333 OutStreamer->switchSection(OutContext.getELFSection(
4337 OutStreamer->emitSymbolValue(CurrentPatchableFunctionEntrySym, PointerSize);
4342 return OutStreamer->getContext().getDwarfVersion();
4346 OutStreamer->getContext().setDwarfVersion(Version);
4350 return OutStreamer->getContext().getDwarfFormat() == dwarf::DWARF64;
4355 OutStreamer->getContext().getDwarfFormat());
4359 return {getDwarfVersion(), uint8_t(MAI->getCodePointerSize()),
4360 OutStreamer->getContext().getDwarfFormat(),
4366 OutStreamer->getContext().getDwarfFormat());
4373 const auto TLI = MF->getSubtarget().getTargetLowering();
4375 TLI->getPICJumpTableRelocBaseExpr(MF, JTI, MMI->getContext());
4376 const auto Base = &cast<MCSymbolRefExpr>(BaseExpr)->getSymbol();