Lines Matching +full:- +full:- +full:require +full:- +full:hashes

1 //===- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp ----------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
33 #include "llvm/Config/llvm-config.h"
83 void emitBytes(StringRef Data) override { OS->emitBytes(Data); }
86 OS->emitIntValueInHex(Value, Size);
89 void emitBinaryData(StringRef Data) override { OS->emitBinaryData(Data); }
91 void AddComment(const Twine &T) override { OS->AddComment(T); }
93 void AddRawComment(const Twine &T) override { OS->emitRawComment(T); }
95 bool isVerboseAsm() override { return OS->isVerboseAsm(); }
134 : DebugHandlerBase(AP), OS(*Asm->OutStreamer), TypeTable(Allocator) {}
141 StringRef Dir = File->getDirectory(), Filename = File->getFilename();
143 // If this is a Unix-style path, just use it as is. Don't try to canonicalize
175 // path should be well-formatted, e.g. start with a drive letter, etc.
182 size_t PrevSlash = Filepath.rfind('\\', Cursor - 1);
187 Filepath.erase(PrevSlash, Cursor + 3 - PrevSlash);
208 if (F->getChecksum()) {
209 std::string Checksum = fromHex(F->getChecksum()->Value);
214 switch (F->getChecksum()->Kind) {
231 return Insertion.first->second;
237 auto SiteInsertion = CurFn->InlineSites.insert({InlinedAt, InlineSite()});
238 InlineSite *Site = &SiteInsertion.first->second;
240 unsigned ParentFuncId = CurFn->FuncId;
241 if (const DILocation *OuterIA = InlinedAt->getInlinedAt())
243 getInlineSite(OuterIA, InlinedAt->getScope()->getSubprogram())
246 Site->SiteFuncId = NextFuncId++;
248 Site->SiteFuncId, ParentFuncId, maybeRecordFile(InlinedAt->getFile()),
249 InlinedAt->getLine(), InlinedAt->getColumn(), SMLoc());
250 Site->Inlinee = Inlinee;
254 if (InlinedAt->getInlinedAt() == nullptr)
255 CurFn->Inlinees.insert(InlineeIdx);
261 StringRef ScopeName = Scope->getName();
265 switch (Scope->getTag()) {
270 return "<unnamed-tag>";
294 Scope = Scope->getScope();
318 --CVD.TypeEmissionLevel;
335 const DIScope *Scope = Ty->getScope();
344 // which can trigger a link-time error with the linker in
358 return I->second;
374 for (int i = Name.size() - 1; i >= 0; --i) {
378 --OpenBrackets;
392 return I->second;
397 StringRef DisplayName = removeTemplateArgs(SP->getName());
399 const DIScope *Scope = SP->getScope();
403 // function types take some special handling, and require access to the
412 FuncIdRecord FuncId(ParentScope, getTypeIndex(SP->getType()), DisplayName);
420 return ((DCTy->getFlags() & DINode::FlagNonTrivial) == DINode::FlagNonTrivial);
429 if (auto TypeArray = Ty->getTypeArray()) {
441 if (ClassTy && isNonTrivial(ClassTy) && SPName == ClassTy->getName()) {
454 if (SP->getDeclaration())
455 SP = SP->getDeclaration();
456 assert(!SP->getDeclaration() && "should use declaration as key");
462 return I->second;
468 const bool IsStaticMethod = (SP->getFlags() & DINode::FlagStaticMember) != 0;
470 FunctionOptions FO = getFunctionOptions(SP->getType(), Class, SP->getName());
472 SP->getType(), Class, SP->getThisAdjustment(), IsStaticMethod, FO);
486 return MMI->getModule()->getDataLayout().getPointerSizeInBits() / 8;
491 if (const DILocation *InlinedAt = LS->getInlinedAt()) {
493 const DISubprogram *Inlinee = Var.DIVar->getScope()->getSubprogram();
514 const DIScope *Scope = DL->getScope();
528 if (!CurFn->HaveLineInfo)
529 CurFn->HaveLineInfo = true;
531 if (PrevInstLoc.get() && PrevInstLoc->getFile() == DL->getFile())
532 FileId = CurFn->LastFileId;
534 FileId = CurFn->LastFileId = maybeRecordFile(DL->getFile());
537 unsigned FuncId = CurFn->FuncId;
538 if (const DILocation *SiteLoc = DL->getInlinedAt()) {
544 getInlineSite(SiteLoc, Loc->getScope()->getSubprogram()).SiteFuncId;
548 while ((SiteLoc = Loc->getInlinedAt())) {
550 getInlineSite(SiteLoc, Loc->getScope()->getSubprogram());
556 addLocIfNotPresent(CurFn->ChildSites, Loc);
561 DL->getFilename(), SMLoc());
616 if (!Asm->hasDebugInfo() ||
617 !Asm->getObjFileLowering().getCOFFDebugSymbolsSection()) {
622 TheCPU = mapArchToCVCPUType(Triple(M->getTargetTriple()).getArch());
625 const MDNode *Node = *M->debug_compile_units_begin();
628 CurrentSourceLanguage = MapDWLangToCVLang(CU->getSourceLanguage());
632 // Check if we should emit type record hashes.
634 mdconst::extract_or_null<ConstantInt>(M->getModuleFlag("CodeViewGHash"));
635 EmitDebugGlobalHashes = GH && !GH->isZero();
639 if (!Asm || !Asm->hasDebugInfo())
643 // with a 4-byte control code (e.g. 0xF1, 0xF2, etc) and then a 4-byte length
644 // of the payload followed by the payload itself. The subsections are 4-byte
658 // Emit per-function debug information.
660 if (!P.first->isDeclarationForLinker())
699 // Emit type information and hashes last, so that any types we translate while
717 S.take_front(MaxRecordLength - MaxFixedRecordLength - 1));
727 OS.switchSection(Asm->getObjFileLowering().getCOFFDebugTypesSection());
760 OS.switchSection(Asm->getObjFileLowering().getCOFFGlobalTypeHashesSection());
771 for (const auto &GHR : TypeTable.hashes()) {
773 // Emit an EOL-comment describing which TypeIndex this hash corresponds
791 StringRef PathRef(Asm->TM.Options.ObjectFilenameForDebug);
794 if (PathRef.empty() || PathRef == "-") {
824 V.Part[N] += C - '0';
844 if (MMI->getModule()->getProfileSummary(/*IsCS*/ false) != nullptr) {
848 ArchType Arch = Triple(MMI->getModule()->getTargetTriple()).getArch();
849 if (Asm->TM.Options.Hotpatch || Arch == ArchType::thumb ||
860 NamedMDNode *CUs = MMI->getModule()->getNamedMetadata("llvm.dbg.cu");
861 const MDNode *Node = *CUs->operands().begin();
864 StringRef CompilerVersion = CU->getProducer();
884 OS.AddComment("Null-terminated compiler version string");
899 // - Absolute path of current directory
900 // - Compiler path
901 // - Main source file path, relative to CWD or absolute
902 // - Type server PDB file
903 // - Canonical compiler command line
908 NamedMDNode *CUs = MMI->getModule()->getNamedMetadata("llvm.dbg.cu");
909 const MDNode *Node = *CUs->operands().begin(); // FIXME: Multiple CUs.
911 const DIFile *MainSourceFile = CU->getFile();
913 getStringIdTypeIdx(TypeTable, MainSourceFile->getDirectory());
915 getStringIdTypeIdx(TypeTable, MainSourceFile->getFilename());
920 getStringIdTypeIdx(TypeTable, Asm->TM.Options.MCOptions.Argv0);
922 TypeTable, Asm->TM.Options.MCOptions.CommandlineArgs);
956 unsigned FileId = maybeRecordFile(SP->getFile());
957 OS.AddComment("Inlined function " + SP->getName() + " starts at " +
958 SP->getFilename() + Twine(':') + Twine(SP->getLine()));
965 OS.emitInt32(SP->getLine());
987 unsigned FileId = maybeRecordFile(Site.Inlinee->getFile());
988 unsigned StartLineNum = Site.Inlinee->getLine();
1002 emitInlinedCallSite(FI, ChildSite, I->second);
1011 // comdat key. A section may be comdat because of -ffunction-sections or
1014 GVSym ? dyn_cast<MCSectionCOFF>(&GVSym->getSection()) : nullptr;
1015 const MCSymbol *KeySym = GVSec ? GVSec->getCOMDATSymbol() : nullptr;
1018 Asm->getObjFileLowering().getCOFFDebugSymbolsSection());
1035 std::string(GlobalValue::dropLLVMManglingEscape(GV->getName()));
1075 const MCSymbol *Fn = Asm->getSymbol(GV);
1082 auto *SP = GV->getSubprogram();
1086 if (SP->isThunk()) {
1093 if (!SP->getName().empty())
1094 FuncName = getFullyQualifiedName(SP->getScope(), SP->getName());
1098 FuncName = std::string(GlobalValue::dropLLVMManglingEscape(GV->getName()));
1100 // Emit FPO data, but only on 32-bit x86. No other platforms use it.
1101 if (Triple(MMI->getModule()->getTargetTriple()).getArch() == Triple::x86)
1108 SymbolKind ProcKind = GV->hasLocalLinkage() ? SymbolKind::S_LPROC32_ID
1128 OS.emitInt32(getFuncIdForSubprogram(GV->getSubprogram()).getIndex());
1137 if (GV->hasFnAttribute(Attribute::NoReturn))
1139 if (GV->hasFnAttribute(Attribute::NoInline))
1142 // Emit the function display name as a null-terminated string.
1151 OS.emitInt32(FI.FrameSize - FI.CSRSize);
1178 emitInlinedCallSite(FI, InlinedAt, I->second);
1188 OS.emitInt16(Strs->getNumOperands());
1189 for (Metadata *MD : Strs->operands()) {
1192 StringRef Str = cast<MDString>(MD)->getString();
1193 assert(Str.data()[Str.size()] == '\0' && "non-nullterminated MDString");
1232 DR.InMemory = -1;
1243 const MachineFunction &MF = *Asm->MF;
1252 assert(VI.Var->isValidLocationForIntrinsic(VI.Loc) &&
1253 "Expected inlined-at fields to agree");
1255 Processed.insert(InlinedEntity(VI.Var, VI.Loc->getInlinedAt()));
1268 if (VI.Expr->getNumElements() == 1 &&
1269 VI.Expr->getElement(0) == llvm::dwarf::DW_OP_deref)
1271 else if (!VI.Expr->extractIfOffset(ExprOffset))
1278 TFI->getFrameIndexReference(*Asm->MF, VI.getStackSlot(), FrameReg);
1279 uint16_t CVReg = TRI->getCodeViewRegNum(FrameReg);
1291 for (const InsnRange &Range : Scope->getRanges()) {
1294 End = End ? End : Asm->getFunctionEnd();
1315 const TargetRegisterInfo *TRI = Asm->MF->getSubtarget().getRegisterInfo();
1323 assert(DVInst->isDebugValue() && "Invalid History entry");
1335 auto Op = DVInst->getDebugOperand(0);
1351 Location->LoadChain.pop_back();
1364 if (Location->Register == 0 || Location->LoadChain.size() > 1)
1367 // Codeview can only express byte-aligned offsets, ensure that we have a
1368 // byte-boundaried location.
1369 if (Location->FragmentInfo)
1370 if (Location->FragmentInfo->OffsetInBits % 8)
1374 DR.CVRegister = TRI->getCodeViewRegNum(Location->Register);
1375 DR.InMemory = !Location->LoadChain.empty();
1377 !Location->LoadChain.empty() ? Location->LoadChain.back() : 0;
1378 if (Location->FragmentInfo) {
1380 DR.StructOffset = Location->FragmentInfo->OffsetInBits / 8;
1395 End = Asm->getFunctionEnd();
1412 // Grab the variable info that was squirreled away in the MMI side-table.
1427 Scope = LScopes.findInlinedScope(DIVar->getScope(), InlinedAt);
1429 Scope = LScopes.findLexicalScope(DIVar->getScope());
1443 const TargetSubtargetInfo &TSI = MF->getSubtarget();
1445 const MachineFrameInfo &MFI = MF->getFrameInfo();
1446 const Function &GV = MF->getFunction();
1449 CurFn = Insertion.first->second.get();
1450 CurFn->FuncId = NextFuncId++;
1451 CurFn->Begin = Asm->getFunctionBegin();
1454 // callee-saved registers were used. For targets that don't use a PUSH
1456 CurFn->CSRSize = MFI.getCVBytesOfCalleeSavedRegisters();
1457 CurFn->FrameSize = MFI.getStackSize();
1458 CurFn->OffsetAdjustment = MFI.getOffsetAdjustment();
1459 CurFn->HasStackRealignment = TRI->hasStackRealignment(*MF);
1463 CurFn->EncodedParamFramePtrReg = EncodedFramePtrReg::None; // None.
1464 CurFn->EncodedLocalFramePtrReg = EncodedFramePtrReg::None; // None.
1465 if (CurFn->FrameSize > 0) {
1466 if (!TSI.getFrameLowering()->hasFP(*MF)) {
1467 CurFn->EncodedLocalFramePtrReg = EncodedFramePtrReg::StackPtr;
1468 CurFn->EncodedParamFramePtrReg = EncodedFramePtrReg::StackPtr;
1470 CurFn->HasFramePointer = true;
1472 CurFn->EncodedParamFramePtrReg = EncodedFramePtrReg::FramePtr;
1473 if (CurFn->HasStackRealignment) {
1475 CurFn->EncodedLocalFramePtrReg = EncodedFramePtrReg::StackPtr;
1479 CurFn->EncodedLocalFramePtrReg = EncodedFramePtrReg::FramePtr;
1488 if (MF->exposesReturnsTwice())
1491 if (MF->hasInlineAsm())
1514 FPO |= FrameProcedureOptions(uint32_t(CurFn->EncodedLocalFramePtrReg) << 14U);
1515 FPO |= FrameProcedureOptions(uint32_t(CurFn->EncodedParamFramePtrReg) << 16U);
1516 if (Asm->TM.getOptLevel() != CodeGenOptLevel::None && !GV.hasOptSize() &&
1524 CurFn->FrameProcOpts = FPO;
1526 OS.emitCVFuncIdDirective(CurFn->FuncId);
1528 // Find the end of the function prolog. First known non-DBG_VALUE and
1529 // non-frame setup location marks the beginning of the function body.
1546 // Record beginning of function if we have a non-empty prologue.
1563 bool isThumb = Triple(MMI->getModule()->getTargetTriple()).getArch() ==
1573 if (T->getTag() == dwarf::DW_TAG_typedef) {
1574 if (DIScope *Scope = T->getScope()) {
1575 switch (Scope->getTag()) {
1588 if (!T || T->isForwardDecl())
1594 T = DT->getBaseType();
1601 if (Ty->getName().empty())
1608 collectParentScopeNames(Ty->getScope(), ParentScopeNames);
1629 switch (Ty->getTag()) {
1637 if (cast<DIDerivedType>(Ty)->getName() == "__vtbl_ptr_type")
1669 if (Ty->getName() == "decltype(nullptr)")
1679 TypeIndex UnderlyingTypeIndex = getTypeIndex(Ty->getBaseType());
1680 StringRef TypeName = Ty->getName();
1695 const DIType *ElementType = Ty->getBaseType();
1705 DINodeArray Elements = Ty->getElements();
1706 for (int i = Elements.size() - 1; i >= 0; --i) {
1708 assert(Element->getTag() == dwarf::DW_TAG_subrange_type);
1711 int64_t Count = -1;
1714 // Otherwise, if it has an upperboud, use (upperbound - lowerbound + 1),
1717 if (auto *CI = dyn_cast_if_present<ConstantInt *>(Subrange->getCount()))
1718 Count = CI->getSExtValue();
1720 Subrange->getUpperBound())) {
1723 auto *LI = dyn_cast_if_present<ConstantInt *>(Subrange->getLowerBound());
1724 Lowerbound = (LI) ? LI->getSExtValue() : Lowerbound;
1725 Count = UI->getSExtValue() - Lowerbound + 1;
1728 // Forward declarations of arrays without a size and VLAs use a count of -1.
1732 if (Count == -1)
1741 (i == 0 && ElementSize == 0) ? Ty->getSizeInBits() / 8 : ElementSize;
1743 StringRef Name = (i == 0) ? Ty->getName() : "";
1758 uint64_t ArraySize = Ty->getSizeInBits() >> 3;
1759 StringRef Name = Ty->getName();
1776 Kind = static_cast<dwarf::TypeKind>(Ty->getEncoding());
1777 ByteSize = Ty->getSizeInBits() / 8;
1851 // Apply some fixups based on the source-level type name.
1856 (Ty->getName() == "long int" || Ty->getName() == "long"))
1858 if (STK == SimpleTypeKind::UInt32 && (Ty->getName() == "long unsigned int" ||
1859 Ty->getName() == "unsigned long"))
1862 (Ty->getName() == "wchar_t" || Ty->getName() == "__wchar_t"))
1866 Ty->getName() == "char")
1874 TypeIndex PointeeTI = getTypeIndex(Ty->getBaseType());
1880 Ty->getTag() == dwarf::DW_TAG_pointer_type) {
1881 SimpleTypeMode Mode = Ty->getSizeInBits() == 64
1888 Ty->getSizeInBits() == 64 ? PointerKind::Near64 : PointerKind::Near32;
1890 switch (Ty->getTag()) {
1903 if (Ty->isObjectPointer())
1906 PointerRecord PR(PointeeTI, PK, PM, PO, Ty->getSizeInBits() / 8);
1945 assert(Ty->getTag() == dwarf::DW_TAG_ptr_to_member_type);
1946 bool IsPMF = isa<DISubroutineType>(Ty->getBaseType());
1947 TypeIndex ClassTI = getTypeIndex(Ty->getClassType());
1949 getTypeIndex(Ty->getBaseType(), IsPMF ? Ty->getClassType() : nullptr);
1955 assert(Ty->getSizeInBits() / 8 <= 0xff && "pointer size too big");
1956 uint8_t SizeInBytes = Ty->getSizeInBits() / 8;
1958 ClassTI, translatePtrToMemberRep(SizeInBytes, IsPMF, Ty->getFlags()));
1984 switch (BaseTy->getTag()) {
2003 BaseTy = cast<DIDerivedType>(BaseTy)->getBaseType();
2011 switch (BaseTy->getTag()) {
2026 // metadata could contain restrict wrappers around non-pointer types.
2036 for (const DIType *ArgType : Ty->getTypeArray())
2055 CallingConvention CC = dwarfCCToCodeView(Ty->getCC());
2071 DITypeRefArray ReturnAndArgs = Ty->getTypeArray();
2087 if (PtrTy->getTag() == dwarf::DW_TAG_pointer_type) {
2104 CallingConvention CC = dwarfCCToCodeView(Ty->getCC());
2113 Ty->getSizeInBits() / (8 * Asm->MAI->getCodePointerSize());
2134 if (SP->isArtificial())
2144 if (SP->getFlags() & DINode::FlagStaticMember)
2147 switch (SP->getVirtuality()) {
2163 switch (Ty->getTag()) {
2181 if (!Ty->getIdentifier().empty())
2187 const DIScope *ImmediateScope = Ty->getScope();
2191 // Put the Scoped flag on function-local types. MSVC puts this flag for enum
2195 if (Ty->getTag() == dwarf::DW_TAG_enumeration_type) {
2200 Scope = Scope->getScope()) {
2212 switch (Ty->getTag()) {
2222 if (const auto *File = Ty->getFile()) {
2226 UdtSourceLineRecord USLR(TI, SIDI, Ty->getLine());
2236 if (Ty->isForwardDecl()) {
2241 for (const DINode *Element : Ty->getElements()) {
2247 APSInt(Enumerator->getValue(), true),
2248 Enumerator->getName());
2258 EnumRecord ER(EnumeratorCount, CO, FTI, FullName, Ty->getIdentifier(),
2259 getTypeIndex(Ty->getBaseType()));
2267 //===----------------------------------------------------------------------===//
2269 //===----------------------------------------------------------------------===//
2280 // MethodName -> MethodsList
2311 if (!DDTy->getName().empty()) {
2315 if ((DDTy->getFlags() & DINode::FlagStaticMember) ==
2317 if (DDTy->getConstant() && (isa<ConstantInt>(DDTy->getConstant()) ||
2318 isa<ConstantFP>(DDTy->getConstant())))
2329 assert((DDTy->getOffsetInBits() % 8) == 0 && "Unnamed bitfield member!");
2330 uint64_t Offset = DDTy->getOffsetInBits();
2331 const DIType *Ty = DDTy->getBaseType();
2334 switch (Ty->getTag()) {
2339 Ty = cast<DIDerivedType>(Ty)->getBaseType();
2360 DINodeArray Elements = Ty->getElements();
2367 Info.Methods[SP->getRawName()].push_back(SP);
2369 if (DDTy->getTag() == dwarf::DW_TAG_member) {
2371 } else if (DDTy->getTag() == dwarf::DW_TAG_inheritance) {
2373 } else if (DDTy->getTag() == dwarf::DW_TAG_pointer_type &&
2374 DDTy->getName() == "__vtbl_ptr_type") {
2376 } else if (DDTy->getTag() == dwarf::DW_TAG_typedef) {
2378 } else if (DDTy->getTag() == dwarf::DW_TAG_friend) {
2393 return Ty->getName().empty() && Ty->getIdentifier().empty() &&
2394 !Ty->isForwardDecl();
2400 // be named by the front-end and should not be "unnamed". C unnamed
2407 if (I != CompleteTypeIndices.end() && I->second == TypeIndex())
2419 FullName, Ty->getIdentifier());
2421 if (!Ty->isForwardDecl())
2443 // debug information. For now checking a class's non-triviality seems enough.
2450 uint64_t SizeInBytes = Ty->getSizeInBits() / 8;
2453 SizeInBytes, FullName, Ty->getIdentifier());
2471 UnionRecord UR(0, CO, TypeIndex(), 0, FullName, Ty->getIdentifier());
2473 if (!Ty->isForwardDecl())
2489 uint64_t SizeInBytes = Ty->getSizeInBits() / 8;
2493 Ty->getIdentifier());
2516 if (I->getFlags() & DINode::FlagVirtual) {
2518 unsigned VBPtrOffset = I->getVBPtrOffset();
2520 unsigned VBTableIndex = I->getOffsetInBits() / 4;
2521 auto RecordKind = (I->getFlags() & DINode::FlagIndirectVirtualBase) == DINode::FlagIndirectVirtualBase
2525 RecordKind, translateAccessFlags(Ty->getTag(), I->getFlags()),
2526 getTypeIndex(I->getBaseType()), getVBPTypeIndex(), VBPtrOffset,
2532 assert(I->getOffsetInBits() % 8 == 0 &&
2534 BaseClassRecord BCR(translateAccessFlags(Ty->getTag(), I->getFlags()),
2535 getTypeIndex(I->getBaseType()),
2536 I->getOffsetInBits() / 8);
2545 TypeIndex MemberBaseType = getTypeIndex(Member->getBaseType());
2546 StringRef MemberName = Member->getName();
2548 translateAccessFlags(Ty->getTag(), Member->getFlags());
2550 if (Member->isStaticMember()) {
2558 if ((Member->getFlags() & DINode::FlagArtificial) &&
2559 Member->getName().starts_with("_vptr$")) {
2560 VFPtrRecord VFPR(getTypeIndex(Member->getBaseType()));
2568 Member->getOffsetInBits() + MemberInfo.BaseOffset;
2569 if (Member->isBitField()) {
2572 dyn_cast_or_null<ConstantInt>(Member->getStorageOffsetInBits())) {
2573 MemberOffsetInBits = CI->getZExtValue() + MemberInfo.BaseOffset;
2575 StartBitOffset -= MemberOffsetInBits;
2576 BitFieldRecord BFR(MemberBaseType, Member->getSizeInBits(),
2589 StringRef Name = MethodItr.first->getString();
2594 bool Introduced = SP->getFlags() & DINode::FlagIntroducedVirtual;
2596 unsigned VFTableOffset = -1;
2598 VFTableOffset = SP->getVirtualIndex() * getPointerSizeInBytes();
2601 MethodType, translateAccessFlags(Ty->getTag(), SP->getFlags()),
2622 NestedTypeRecord R(getTypeIndex(Nested), Nested->getName());
2655 // get-or-create style insertion that caches the hash lookup across the
2659 return I->second;
2669 assert(PtrTy->getTag() == dwarf::DW_TAG_pointer_type &&
2673 if (SubroutineTy->getFlags() & DINode::DIFlags::FlagLValueReference)
2675 else if (SubroutineTy->getFlags() & DINode::DIFlags::FlagRValueReference)
2685 return I->second;
2697 Ty->getSizeInBits() / 8);
2709 if (Ty->getTag() == dwarf::DW_TAG_typedef)
2711 while (Ty->getTag() == dwarf::DW_TAG_typedef)
2712 Ty = cast<DIDerivedType>(Ty)->getBaseType();
2714 // If this is a non-record type, the complete type index is the same as the
2716 switch (Ty->getTag()) {
2733 if (!CTy->getName().empty() || !CTy->getIdentifier().empty()) {
2739 if (CTy->isForwardDecl())
2748 return InsertResult.first->second;
2751 switch (CTy->getTag()) {
2790 if (L.DIVar->isParameter())
2793 return L->DIVar->getArg() < R->DIVar->getArg();
2798 // Next emit all non-parameters in the order that we found them.
2800 if (!L.DIVar->isParameter()) {
2804 const DIType *Ty = L.DIVar->getType();
2806 emitConstantSymbolRecord(Ty, Val, std::string(L.DIVar->getName()));
2820 if (Var.DIVar->isParameter())
2827 ? getTypeIndexForReferenceTo(Var.DIVar->getType())
2828 : getCompleteTypeIndex(Var.DIVar->getType());
2833 emitNullTerminatedSymbolName(OS, Var.DIVar->getName());
2848 // 32-bit x86 call sequences often use PUSH instructions, which disrupt
2849 // ESP-relative offsets. Use the virtual frame pointer, VFRAME or $T0,
2960 LI != ScopeVariables.end() ? &LI->second : nullptr;
2963 GI != ScopeGlobals.end() ? GI->second.get() : nullptr;
2995 ParentLocals.append(Locals->begin(), Locals->end());
2997 ParentGlobals.append(Globals->begin(), Globals->end());
3008 auto BlockInsertion = CurFn->LexicalBlocks.insert({DILB, LexicalBlock()});
3016 LexicalBlock &Block = BlockInsertion.first->second;
3021 Block.Name = DILB->getName();
3034 const Function &GV = MF->getFunction();
3043 CurFn->ChildBlocks,
3044 CurFn->Locals,
3045 CurFn->Globals);
3053 // Thunks are compiler-generated and probably won't have source correlation.
3054 if (!CurFn->HaveLineInfo && !GV.getSubprogram()->isThunk()) {
3064 CurFn->HeapAllocSites.push_back(std::make_tuple(getLabelBeforeInsn(&MI),
3071 bool isThumb = Triple(MMI->getModule()->getTargetTriple()).getArch() ==
3075 CurFn->Annotations = MF->getCodeViewAnnotations();
3077 CurFn->End = Asm->getFunctionEnd();
3082 // Usable locations are valid with non-zero line numbers. A line number of zero
3094 if (!Asm || !CurFn || MI->isDebugInstr() ||
3095 MI->getFlag(MachineInstr::FrameSetup))
3100 DebugLoc DL = MI->getDebugLoc();
3101 if (!isUsableDebugLoc(DL) && MI->getParent() != PrevInstBB) {
3102 for (const auto &NextMI : *MI->getParent()) {
3110 // probably require doing a real dataflow analysis.
3112 PrevInstBB = MI->getParent();
3118 maybeRecordLocation(DL, Asm->MF);
3122 MCSymbol *BeginLabel = MMI->getContext().createTempSymbol(),
3123 *EndLabel = MMI->getContext().createTempSymbol();
3133 // Every subsection must be aligned to a 4-byte boundary.
3145 MCSymbol *BeginLabel = MMI->getContext().createTempSymbol(),
3146 *EndLabel = MMI->getContext().createTempSymbol();
3194 for (const GlobalVariable &GV : MMI->getModule()->globals()) {
3201 NamedMDNode *CUs = MMI->getModule()->getNamedMetadata("llvm.dbg.cu");
3202 for (const MDNode *Node : CUs->operands()) {
3204 for (const auto *GVE : CU->getGlobalVariables()) {
3205 const DIGlobalVariable *DIGV = GVE->getVariable();
3206 const DIExpression *DIE = GVE->getExpression();
3211 if (DIGV->getName().empty()) continue;
3213 if ((DIE->getNumElements() == 2) &&
3214 (DIE->getElement(0) == dwarf::DW_OP_plus_uconst))
3220 std::make_pair(DIGV, DIE->getElement(1)));
3223 if (GlobalMap.count(GVE) == 0 && DIE->isConstant()) {
3229 if (!GV || GV->isDeclarationForLinker())
3232 DIScope *Scope = DIGV->getScope();
3240 Insertion.first->second = std::make_unique<GlobalVariableList>();
3241 VariableList = Insertion.first->second.get();
3242 } else if (GV->hasComdat())
3249 VariableList->emplace_back(std::move(CVGV));
3257 const DIScope *Scope = DIGV->getScope();
3258 getCompleteTypeIndex(DIGV->getType());
3259 getFullyQualifiedName(Scope, DIGV->getName());
3264 const DIScope *Scope = DIGV->getScope();
3265 getCompleteTypeIndex(DIGV->getType());
3266 getFullyQualifiedName(Scope, DIGV->getName());
3287 MCSymbol *GVSym = Asm->getSymbol(GV);
3289 Twine(GlobalValue::dropLLVMManglingEscape(GV->getName())));
3299 NamedMDNode *CUs = MMI->getModule()->getNamedMetadata("llvm.dbg.cu");
3300 for (const MDNode *Node : CUs->operands()) {
3301 for (auto *Ty : cast<DICompileUnit>(Node)->getRetainedTypes()) {
3341 const DIScope *Scope = DTy->getScope();
3345 dyn_cast_or_null<ConstantInt>(DTy->getConstant()))
3346 Value = APSInt(CI->getValue(),
3347 DebugHandlerBase::isUnsignedDIType(DTy->getBaseType()));
3349 dyn_cast_or_null<ConstantFP>(DTy->getConstant()))
3350 Value = APSInt(CFP->getValueAPF().bitcastToAPInt(), true);
3354 emitConstantSymbolRecord(DTy->getBaseType(), Value,
3355 getFullyQualifiedName(Scope, DTy->getName()));
3364 dwarf::Tag T = (dwarf::Tag)Ty->getTag();
3370 assert(DTy->getBaseType() && "Expected valid base type");
3371 return isFloatDIType(DTy->getBaseType());
3375 return (BTy->getEncoding() == dwarf::DW_ATE_float);
3381 const DIScope *Scope = DIGV->getScope();
3384 DIGV->getRawStaticDataMemberDeclaration()))
3385 Scope = MemberDecl->getScope();
3391 ? std::string(DIGV->getName())
3392 : getFullyQualifiedName(Scope, DIGV->getName());
3398 MCSymbol *GVSym = Asm->getSymbol(GV);
3399 SymbolKind DataSym = GV->isThreadLocal()
3400 ? (DIGV->isLocalToUnit() ? SymbolKind::S_LTHREAD32
3402 : (DIGV->isLocalToUnit() ? SymbolKind::S_LDATA32
3406 OS.emitInt32(getCompleteTypeIndex(DIGV->getType()).getIndex());
3421 assert(DIE->isConstant() &&
3425 bool isUnsigned = isFloatDIType(DIGV->getType())
3427 : DebugHandlerBase::isUnsignedDIType(DIGV->getType());
3428 APSInt Value(APInt(/*BitWidth=*/64, DIE->getElement(1)), isUnsigned);
3429 emitConstantSymbolRecord(DIGV->getType(), Value, QualifiedName);
3437 auto JTI = MF->getJumpTableInfo();
3438 if (JTI && !JTI->isEmpty()) {
3440 auto UsedJTs = llvm::SmallBitVector(JTI->getJumpTables().size());
3445 if (LastMI != MBB.end() && LastMI->isIndirectBranch()) {
3450 // interferes with this process *but* the resulting pseudo-instruction
3453 for (const auto &MO : LastMI->operands()) {
3468 if (I->isJumpTableDebugInfo()) {
3469 unsigned Index = I->getOperand(0).getImm();
3501 // For label-difference jump tables, find the base expression.
3525 Asm->getCodeViewJumpTableInfo(JumpTableIndex, &BranchMI, Branch);
3529 CurFn->JumpTables.push_back(
3531 MF->getJTISymbol(JumpTableIndex, MMI->getContext()),
3571 (MaxRecordLength - sizeof(SymbolKind) - sizeof(uint32_t)) /
3581 std::min(ChunkSize, SortedInlinees.size() - CurrentIndex);