77      std::memcpy(&Val, &DR, 
sizeof(Val));
 
 
   83      std::memcpy(&DR, &Val, 
sizeof(Val));
 
 
 
   88  static_assert(
sizeof(
uint64_t) == 
sizeof(LocalVarDef));
 
   96  bool EmitDebugGlobalHashes = 
false;
 
  105  static LocalVarDef createDefRangeMem(
uint16_t CVRegister, 
int Offset);
 
  108  struct LocalVariable {
 
  113    bool UseReferenceType = 
false;
 
  114    std::optional<APSInt> ConstantValue;
 
  117  struct CVGlobalVariable {
 
  118    const DIGlobalVariable *DIGV;
 
  119    PointerUnion<const GlobalVariable *, const DIExpression *> GVInfo;
 
  123    SmallVector<LocalVariable, 1> InlinedLocals;
 
  124    SmallVector<const DILocation *, 1> ChildSites;
 
  125    const DISubprogram *
Inlinee = 
nullptr;
 
  129    unsigned SiteFuncId = 0;
 
  133  struct LexicalBlock {
 
  134    SmallVector<LocalVariable, 1> 
Locals;
 
  135    SmallVector<CVGlobalVariable, 1> Globals;
 
  136    SmallVector<LexicalBlock *, 1> 
Children;
 
  142  struct JumpTableInfo {
 
  143    codeview::JumpTableEntrySize EntrySize;
 
  149    std::vector<const MCSymbol *> Cases;
 
  154  struct FunctionInfo {
 
  155    FunctionInfo() = 
default;
 
  158    FunctionInfo(
const FunctionInfo &FI) = 
delete;
 
  162    std::unordered_map<const DILocation *, InlineSite> InlineSites;
 
  165    SmallVector<const DILocation *, 1> ChildSites;
 
  168    SmallSet<codeview::TypeIndex, 1> Inlinees;
 
  170    SmallVector<LocalVariable, 1> 
Locals;
 
  171    SmallVector<CVGlobalVariable, 1> Globals;
 
  173    std::unordered_map<const DILexicalBlockBase*, LexicalBlock> LexicalBlocks;
 
  176    SmallVector<LexicalBlock *, 1> ChildBlocks;
 
  178    std::vector<std::pair<MCSymbol *, MDNode *>> Annotations;
 
  179    std::vector<std::tuple<const MCSymbol *, const MCSymbol *, const DIType *>>
 
  182    std::vector<JumpTableInfo> JumpTables;
 
  187    unsigned LastFileId = 0;
 
  190    unsigned FrameSize = 0;
 
  193    unsigned ParamSize = 0;
 
  196    unsigned CSRSize = 0;
 
  199    int OffsetAdjustment = 0;
 
  203    codeview::EncodedFramePtrReg EncodedLocalFramePtrReg =
 
  204        codeview::EncodedFramePtrReg::None;
 
  208    codeview::EncodedFramePtrReg EncodedParamFramePtrReg =
 
  209        codeview::EncodedFramePtrReg::None;
 
  211    codeview::FrameProcedureOptions FrameProcOpts;
 
  213    bool HasStackRealignment = 
false;
 
  215    bool HaveLineInfo = 
false;
 
  217    bool HasFramePointer = 
false;
 
  219  FunctionInfo *CurFn = 
nullptr;
 
  221  codeview::SourceLanguage CurrentSourceLanguage =
 
  222      codeview::SourceLanguage::Masm;
 
  226  DenseMap<const DIGlobalVariable *, uint64_t> CVGlobalVariableOffsets;
 
  232  DenseMap<const LexicalScope *, SmallVector<LocalVariable, 1>> ScopeVariables;
 
  236  typedef SmallVector<CVGlobalVariable, 1> GlobalVariableList;
 
  237  DenseMap<const DIScope*, std::unique_ptr<GlobalVariableList> > ScopeGlobals;
 
  240  SmallVector<CVGlobalVariable, 1> ComdatVariables;
 
  243  SmallVector<CVGlobalVariable, 1> GlobalVariables;
 
  246  SmallVector<const DIDerivedType *, 4> StaticConstMembers;
 
  251  DenseSet<MCSectionCOFF *> ComdatDebugSections;
 
  258  void switchToDebugSectionForSymbol(
const MCSymbol *GVSym);
 
  262  unsigned NextFuncId = 0;
 
  264  InlineSite &getInlineSite(
const DILocation *InlinedAt,
 
  265                            const DISubprogram *Inlinee);
 
  267  codeview::TypeIndex getFuncIdForSubprogram(
const DISubprogram *SP);
 
  269  void calculateRanges(LocalVariable &Var,
 
  270                       const DbgValueHistoryMap::Entries &Entries);
 
  274  MapVector<const Function *, std::unique_ptr<FunctionInfo>> FnDebugInfo;
 
  278  DenseMap<StringRef, unsigned> FileIdMap;
 
  281  SmallSetVector<const DISubprogram *, 4> InlinedSubprograms;
 
  289  DenseMap<std::pair<const DINode *, const DIType *>, codeview::TypeIndex>
 
  294  DenseMap<const DICompositeType *, codeview::TypeIndex> CompleteTypeIndices;
 
  298  SmallVector<const DICompositeType *, 4> DeferredCompleteTypes;
 
  301  unsigned TypeEmissionLevel = 0;
 
  303  codeview::TypeIndex VBPType;
 
  305  const DISubprogram *CurrentSubprogram = 
nullptr;
 
  309  std::vector<std::pair<std::string, const DIType *>> LocalUDTs;
 
  310  std::vector<std::pair<std::string, const DIType *>> GlobalUDTs;
 
  312  using FileToFilepathMapTy = std::map<const DIFile *, std::string>;
 
  313  FileToFilepathMapTy FileToFilepathMap;
 
  315  StringRef getFullFilepath(
const DIFile *File);
 
  317  unsigned maybeRecordFile(
const DIFile *
F);
 
  319  void maybeRecordLocation(
const DebugLoc &
DL, 
const MachineFunction *MF);
 
  323  void setCurrentSubprogram(
const DISubprogram *SP) {
 
  324    CurrentSubprogram = 
SP;
 
  331  void emitCodeViewMagicVersion();
 
  333  void emitTypeInformation();
 
  335  void emitTypeGlobalHashes();
 
  339  void emitCompilerInformation();
 
  341  void emitSecureHotPatchInformation();
 
  343  void emitBuildInfo();
 
  345  void emitInlineeLinesSubsection();
 
  347  void emitDebugInfoForThunk(
const Function *GV,
 
  351  void emitDebugInfoForFunction(
const Function *GV, FunctionInfo &FI);
 
  353  void emitDebugInfoForRetainedTypes();
 
  355  void emitDebugInfoForUDTs(
 
  356      const std::vector<std::pair<std::string, const DIType *>> &UDTs);
 
  358  void collectDebugInfoForGlobals();
 
  359  void emitDebugInfoForGlobals();
 
  360  void emitGlobalVariableList(ArrayRef<CVGlobalVariable> Globals);
 
  361  void emitConstantSymbolRecord(
const DIType *DTy, APSInt &
Value,
 
  362                                const std::string &QualifiedName);
 
  363  void emitDebugInfoForGlobal(
const CVGlobalVariable &CVGV);
 
  364  void emitStaticConstMemberList();
 
  369  MCSymbol *beginCVSubsection(codeview::DebugSubsectionKind Kind);
 
  370  void endCVSubsection(MCSymbol *EndLabel);
 
  374  MCSymbol *beginSymbolRecord(codeview::SymbolKind Kind);
 
  375  void endSymbolRecord(MCSymbol *SymEnd);
 
  380  void emitEndSymbolRecord(codeview::SymbolKind EndKind);
 
  382  void emitInlinedCallSite(
const FunctionInfo &FI, 
const DILocation *InlinedAt,
 
  383                           const InlineSite &Site);
 
  385  void emitInlinees(
const SmallSet<codeview::TypeIndex, 1> &Inlinees);
 
  387  using InlinedEntity = DbgValueHistoryMap::InlinedEntity;
 
  389  void collectGlobalVariableInfo();
 
  390  void collectVariableInfo(
const DISubprogram *SP);
 
  392  void collectVariableInfoFromMFTable(DenseSet<InlinedEntity> &Processed);
 
  396  void collectLexicalBlockInfo(SmallVectorImpl<LexicalScope *> &Scopes,
 
  397                               SmallVectorImpl<LexicalBlock *> &Blocks,
 
  398                               SmallVectorImpl<LocalVariable> &Locals,
 
  399                               SmallVectorImpl<CVGlobalVariable> &Globals);
 
  400  void collectLexicalBlockInfo(LexicalScope &Scope,
 
  401                               SmallVectorImpl<LexicalBlock *> &ParentBlocks,
 
  402                               SmallVectorImpl<LocalVariable> &ParentLocals,
 
  403                               SmallVectorImpl<CVGlobalVariable> &ParentGlobals);
 
  407  void recordLocalVariable(LocalVariable &&Var, 
const LexicalScope *LS);
 
  410  void emitLocalVariableList(
const FunctionInfo &FI,
 
  411                             ArrayRef<LocalVariable> Locals);
 
  414  void emitLocalVariable(
const FunctionInfo &FI, 
const LocalVariable &Var);
 
  417  void emitLexicalBlockList(ArrayRef<LexicalBlock *> Blocks,
 
  418                            const FunctionInfo& FI);
 
  421  void emitLexicalBlock(
const LexicalBlock &Block, 
const FunctionInfo& FI);
 
  425  codeview::TypeIndex getTypeIndex(
const DIType *Ty,
 
  426                                   const DIType *ClassTy = 
nullptr);
 
  429  getTypeIndexForThisPtr(
const DIDerivedType *PtrTy,
 
  430                         const DISubroutineType *SubroutineTy);
 
  432  codeview::TypeIndex getTypeIndexForReferenceTo(
const DIType *Ty);
 
  434  codeview::TypeIndex getMemberFunctionType(
const DISubprogram *SP,
 
  435                                            const DICompositeType *Class);
 
  437  codeview::TypeIndex getScopeIndex(
const DIScope *Scope);
 
  439  codeview::TypeIndex getVBPTypeIndex();
 
  441  void addToUDTs(
const DIType *Ty);
 
  443  void addUDTSrcLine(
const DIType *Ty, codeview::TypeIndex TI);
 
  445  codeview::TypeIndex lowerType(
const DIType *Ty, 
const DIType *ClassTy);
 
  446  codeview::TypeIndex lowerTypeAlias(
const DIDerivedType *Ty);
 
  447  codeview::TypeIndex lowerTypeArray(
const DICompositeType *Ty);
 
  448  codeview::TypeIndex lowerTypeString(
const DIStringType *Ty);
 
  449  codeview::TypeIndex lowerTypeBasic(
const DIBasicType *Ty);
 
  450  codeview::TypeIndex lowerTypePointer(
 
  451      const DIDerivedType *Ty,
 
  452      codeview::PointerOptions PO = codeview::PointerOptions::None);
 
  453  codeview::TypeIndex lowerTypeMemberPointer(
 
  454      const DIDerivedType *Ty,
 
  455      codeview::PointerOptions PO = codeview::PointerOptions::None);
 
  456  codeview::TypeIndex lowerTypeModifier(
const DIDerivedType *Ty);
 
  457  codeview::TypeIndex lowerTypeFunction(
const DISubroutineType *Ty);
 
  458  codeview::TypeIndex lowerTypeVFTableShape(
const DIDerivedType *Ty);
 
  459  codeview::TypeIndex lowerTypeMemberFunction(
 
  460      const DISubroutineType *Ty, 
const DIType *ClassTy, 
int ThisAdjustment,
 
  462      codeview::FunctionOptions FO = codeview::FunctionOptions::None);
 
  463  codeview::TypeIndex lowerTypeEnum(
const DICompositeType *Ty);
 
  464  codeview::TypeIndex lowerTypeClass(
const DICompositeType *Ty);
 
  465  codeview::TypeIndex lowerTypeUnion(
const DICompositeType *Ty);
 
  472  codeview::TypeIndex getCompleteTypeIndex(
const DIType *Ty);
 
  474  codeview::TypeIndex lowerCompleteTypeClass(
const DICompositeType *Ty);
 
  475  codeview::TypeIndex lowerCompleteTypeUnion(
const DICompositeType *Ty);
 
  477  struct TypeLoweringScope;
 
  479  void emitDeferredCompleteTypes();
 
  481  void collectMemberInfo(ClassInfo &
Info, 
const DIDerivedType *DDTy);
 
  482  ClassInfo collectClassInfo(
const DICompositeType *Ty);
 
  487  std::tuple<codeview::TypeIndex, codeview::TypeIndex, unsigned, bool>
 
  488  lowerRecordFieldList(
const DICompositeType *Ty);
 
  491  codeview::TypeIndex recordTypeIndexForDINode(
const DINode *Node,
 
  492                                               codeview::TypeIndex TI,
 
  493                                               const DIType *ClassTy = 
nullptr);
 
  499  collectParentScopeNames(
const DIScope *Scope,
 
  500                          SmallVectorImpl<StringRef> &ParentScopeNames);
 
  501  std::string getFullyQualifiedName(
const DIScope *Scope, StringRef Name);
 
  502  std::string getFullyQualifiedName(
const DIScope *Scope);
 
  504  unsigned getPointerSizeInBytes();
 
  506  void discoverJumpTableBranches(
const MachineFunction *MF, 
bool isThumb);
 
  507  void collectDebugInfoForJumpTables(
const MachineFunction *MF, 
bool isThumb);
 
  508  void emitDebugInfoForJumpTables(
const FunctionInfo &FI);
 
  512  void beginFunctionImpl(
const MachineFunction *MF) 
override;
 
  515  void endFunctionImpl(
const MachineFunction *) 
override;
 
  519    return CurrentSourceLanguage == codeview::SourceLanguage::Fortran;
 
 
  525  void beginModule(
Module *M) 
override;
 
  528  void endModule() 
override;