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