Commit 692e0c96 authored by Fangrui Song's avatar Fangrui Song
Browse files

[MC] Add MCStreamer::emitInt{8,16,32,64}

Similar to AsmPrinter::emitInt{8,16,32,64}.
parent 93184a8e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -663,6 +663,11 @@ public:
    emitIntValue(Value, Size);
  }

  void emitInt8(uint64_t Value) { emitIntValue(Value, 1); }
  void emitInt16(uint64_t Value) { emitIntValue(Value, 2); }
  void emitInt32(uint64_t Value) { emitIntValue(Value, 4); }
  void emitInt64(uint64_t Value) { emitIntValue(Value, 8); }

  /// Special case of EmitValue that avoids the client having to pass
  /// in a MCExpr for constant integers & prints in Hex format for certain
  /// modes, pads the field with leading zeros to Size width
+4 −10
Original line number Diff line number Diff line
@@ -2162,23 +2162,17 @@ void AsmPrinter::emitModuleCommandLines(Module &M) {

/// Emit a byte directive and value.
///
void AsmPrinter::emitInt8(int Value) const {
  OutStreamer->emitIntValue(Value, 1);
}
void AsmPrinter::emitInt8(int Value) const { OutStreamer->emitInt8(Value); }

/// Emit a short directive and value.
void AsmPrinter::emitInt16(int Value) const {
  OutStreamer->emitIntValue(Value, 2);
}
void AsmPrinter::emitInt16(int Value) const { OutStreamer->emitInt16(Value); }

/// Emit a long directive and value.
void AsmPrinter::emitInt32(int Value) const {
  OutStreamer->emitIntValue(Value, 4);
}
void AsmPrinter::emitInt32(int Value) const { OutStreamer->emitInt32(Value); }

/// Emit a long long directive and value.
void AsmPrinter::emitInt64(uint64_t Value) const {
  OutStreamer->emitIntValue(Value, 8);
  OutStreamer->emitInt64(Value);
}

/// Emit something like ".long Hi-Lo" where the size in bytes of the directive
+46 −46
Original line number Diff line number Diff line
@@ -551,7 +551,7 @@ void CodeViewDebug::maybeRecordLocation(const DebugLoc &DL,
void CodeViewDebug::emitCodeViewMagicVersion() {
  OS.emitValueToAlignment(4);
  OS.AddComment("Debug section magic");
  OS.emitIntValue(COFF::DEBUG_SECTION_MAGIC, 4);
  OS.emitInt32(COFF::DEBUG_SECTION_MAGIC);
}

void CodeViewDebug::endModule() {
@@ -676,11 +676,11 @@ void CodeViewDebug::emitTypeGlobalHashes() {

  OS.emitValueToAlignment(4);
  OS.AddComment("Magic");
  OS.emitIntValue(COFF::DEBUG_HASHES_SECTION_MAGIC, 4);
  OS.emitInt32(COFF::DEBUG_HASHES_SECTION_MAGIC);
  OS.AddComment("Section Version");
  OS.emitIntValue(0, 2);
  OS.emitInt16(0);
  OS.AddComment("Hash Algorithm");
  OS.emitIntValue(uint16_t(GlobalTypeHashAlg::SHA1_8), 2);
  OS.emitInt16(uint16_t(GlobalTypeHashAlg::SHA1_8));

  TypeIndex TI(TypeIndex::FirstNonSimpleIndex);
  for (const auto &GHR : TypeTable.hashes()) {
@@ -775,16 +775,16 @@ void CodeViewDebug::emitCompilerInformation() {
  // TODO:  Figure out which other flags need to be set.

  OS.AddComment("Flags and language");
  OS.emitIntValue(Flags, 4);
  OS.emitInt32(Flags);

  OS.AddComment("CPUType");
  OS.emitIntValue(static_cast<uint64_t>(TheCPU), 2);
  OS.emitInt16(static_cast<uint64_t>(TheCPU));

  StringRef CompilerVersion = CU->getProducer();
  Version FrontVer = parseVersion(CompilerVersion);
  OS.AddComment("Frontend version");
  for (int N = 0; N < 4; ++N)
    OS.emitIntValue(FrontVer.Part[N], 2);
    OS.emitInt16(FrontVer.Part[N]);

  // Some Microsoft tools, like Binscope, expect a backend version number of at
  // least 8.something, so we'll coerce the LLVM version into a form that
@@ -797,7 +797,7 @@ void CodeViewDebug::emitCompilerInformation() {
  Version BackVer = {{ Major, 0, 0, 0 }};
  OS.AddComment("Backend version");
  for (int N = 0; N < 4; ++N)
    OS.emitIntValue(BackVer.Part[N], 2);
    OS.emitInt16(BackVer.Part[N]);

  OS.AddComment("Null-terminated compiler version string");
  emitNullTerminatedSymbolName(OS, CompilerVersion);
@@ -841,7 +841,7 @@ void CodeViewDebug::emitBuildInfo() {
  MCSymbol *BISubsecEnd = beginCVSubsection(DebugSubsectionKind::Symbols);
  MCSymbol *BIEnd = beginSymbolRecord(SymbolKind::S_BUILDINFO);
  OS.AddComment("LF_BUILDINFO index");
  OS.emitIntValue(BuildInfoIndex.getIndex(), 4);
  OS.emitInt32(BuildInfoIndex.getIndex());
  endSymbolRecord(BIEnd);
  endCVSubsection(BISubsecEnd);
}
@@ -858,7 +858,7 @@ void CodeViewDebug::emitInlineeLinesSubsection() {
  // for instance, will display a warning that the breakpoints are not valid if
  // the pdb does not match the source.
  OS.AddComment("Inlinee lines signature");
  OS.emitIntValue(unsigned(InlineeLinesSignature::Normal), 4);
  OS.emitInt32(unsigned(InlineeLinesSignature::Normal));

  for (const DISubprogram *SP : InlinedSubprograms) {
    assert(TypeIndices.count({SP, nullptr}));
@@ -870,11 +870,11 @@ void CodeViewDebug::emitInlineeLinesSubsection() {
                  SP->getFilename() + Twine(':') + Twine(SP->getLine()));
    OS.AddBlankLine();
    OS.AddComment("Type index of inlined function");
    OS.emitIntValue(InlineeIdx.getIndex(), 4);
    OS.emitInt32(InlineeIdx.getIndex());
    OS.AddComment("Offset into filechecksum table");
    OS.EmitCVFileChecksumOffsetDirective(FileId);
    OS.AddComment("Starting line number");
    OS.emitIntValue(SP->getLine(), 4);
    OS.emitInt32(SP->getLine());
  }

  endCVSubsection(InlineEnd);
@@ -890,11 +890,11 @@ void CodeViewDebug::emitInlinedCallSite(const FunctionInfo &FI,
  MCSymbol *InlineEnd = beginSymbolRecord(SymbolKind::S_INLINESITE);

  OS.AddComment("PtrParent");
  OS.emitIntValue(0, 4);
  OS.emitInt32(0);
  OS.AddComment("PtrEnd");
  OS.emitIntValue(0, 4);
  OS.emitInt32(0);
  OS.AddComment("Inlinee type index");
  OS.emitIntValue(InlineeIdx.getIndex(), 4);
  OS.emitInt32(InlineeIdx.getIndex());

  unsigned FileId = maybeRecordFile(Site.Inlinee->getFile());
  unsigned StartLineNum = Site.Inlinee->getLine();
@@ -953,11 +953,11 @@ void CodeViewDebug::emitDebugInfoForThunk(const Function *GV,
  // Emit S_THUNK32
  MCSymbol *ThunkRecordEnd = beginSymbolRecord(SymbolKind::S_THUNK32);
  OS.AddComment("PtrParent");
  OS.emitIntValue(0, 4);
  OS.emitInt32(0);
  OS.AddComment("PtrEnd");
  OS.emitIntValue(0, 4);
  OS.emitInt32(0);
  OS.AddComment("PtrNext");
  OS.emitIntValue(0, 4);
  OS.emitInt32(0);
  OS.AddComment("Thunk section relative address");
  OS.EmitCOFFSecRel32(Fn, /*Offset=*/0);
  OS.AddComment("Thunk section index");
@@ -965,7 +965,7 @@ void CodeViewDebug::emitDebugInfoForThunk(const Function *GV,
  OS.AddComment("Code size");
  OS.emitAbsoluteSymbolDiff(FI.End, Fn, 2);
  OS.AddComment("Ordinal");
  OS.emitIntValue(unsigned(ordinal), 1);
  OS.emitInt8(unsigned(ordinal));
  OS.AddComment("Function name");
  emitNullTerminatedSymbolName(OS, FuncName);
  // Additional fields specific to the thunk ordinal would go here.
@@ -1023,27 +1023,27 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,

    // These fields are filled in by tools like CVPACK which run after the fact.
    OS.AddComment("PtrParent");
    OS.emitIntValue(0, 4);
    OS.emitInt32(0);
    OS.AddComment("PtrEnd");
    OS.emitIntValue(0, 4);
    OS.emitInt32(0);
    OS.AddComment("PtrNext");
    OS.emitIntValue(0, 4);
    OS.emitInt32(0);
    // This is the important bit that tells the debugger where the function
    // code is located and what's its size:
    OS.AddComment("Code size");
    OS.emitAbsoluteSymbolDiff(FI.End, Fn, 4);
    OS.AddComment("Offset after prologue");
    OS.emitIntValue(0, 4);
    OS.emitInt32(0);
    OS.AddComment("Offset before epilogue");
    OS.emitIntValue(0, 4);
    OS.emitInt32(0);
    OS.AddComment("Function type index");
    OS.emitIntValue(getFuncIdForSubprogram(GV->getSubprogram()).getIndex(), 4);
    OS.emitInt32(getFuncIdForSubprogram(GV->getSubprogram()).getIndex());
    OS.AddComment("Function section relative address");
    OS.EmitCOFFSecRel32(Fn, /*Offset=*/0);
    OS.AddComment("Function section index");
    OS.EmitCOFFSectionIndex(Fn);
    OS.AddComment("Flags");
    OS.emitIntValue(0, 1);
    OS.emitInt8(0);
    // Emit the function display name as a null-terminated string.
    OS.AddComment("Function name");
    // Truncate the name so we won't overflow the record length field.
@@ -1053,19 +1053,19 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
    MCSymbol *FrameProcEnd = beginSymbolRecord(SymbolKind::S_FRAMEPROC);
    // Subtract out the CSR size since MSVC excludes that and we include it.
    OS.AddComment("FrameSize");
    OS.emitIntValue(FI.FrameSize - FI.CSRSize, 4);
    OS.emitInt32(FI.FrameSize - FI.CSRSize);
    OS.AddComment("Padding");
    OS.emitIntValue(0, 4);
    OS.emitInt32(0);
    OS.AddComment("Offset of padding");
    OS.emitIntValue(0, 4);
    OS.emitInt32(0);
    OS.AddComment("Bytes of callee saved registers");
    OS.emitIntValue(FI.CSRSize, 4);
    OS.emitInt32(FI.CSRSize);
    OS.AddComment("Exception handler offset");
    OS.emitIntValue(0, 4);
    OS.emitInt32(0);
    OS.AddComment("Exception handler section");
    OS.emitIntValue(0, 2);
    OS.emitInt16(0);
    OS.AddComment("Flags (defines frame register)");
    OS.emitIntValue(uint32_t(FI.FrameProcOpts), 4);
    OS.emitInt32(uint32_t(FI.FrameProcOpts));
    endSymbolRecord(FrameProcEnd);

    emitLocalVariableList(FI, FI.Locals);
@@ -1089,7 +1089,7 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
      OS.EmitCOFFSecRel32(Label, /*Offset=*/0);
      // FIXME: Make sure we don't overflow the max record size.
      OS.EmitCOFFSectionIndex(Label);
      OS.emitIntValue(Strs->getNumOperands(), 2);
      OS.emitInt16(Strs->getNumOperands());
      for (Metadata *MD : Strs->operands()) {
        // MDStrings are null terminated, so we can do EmitBytes and get the
        // nice .asciz directive.
@@ -1112,7 +1112,7 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
      OS.AddComment("Call instruction length");
      OS.emitAbsoluteSymbolDiff(EndLabel, BeginLabel, 2);
      OS.AddComment("Type index");
      OS.emitIntValue(getCompleteTypeIndex(DITy).getIndex(), 4);
      OS.emitInt32(getCompleteTypeIndex(DITy).getIndex());
      endSymbolRecord(HeapAllocEnd);
    }

@@ -2626,9 +2626,9 @@ void CodeViewDebug::emitLocalVariable(const FunctionInfo &FI,
  TypeIndex TI = Var.UseReferenceType
                     ? getTypeIndexForReferenceTo(Var.DIVar->getType())
                     : getCompleteTypeIndex(Var.DIVar->getType());
  OS.emitIntValue(TI.getIndex(), 4);
  OS.emitInt32(TI.getIndex());
  OS.AddComment("Flags");
  OS.emitIntValue(static_cast<uint16_t>(Flags), 2);
  OS.emitInt16(static_cast<uint16_t>(Flags));
  // Truncate the name so we won't overflow the record length field.
  emitNullTerminatedSymbolName(OS, Var.DIVar->getName());
  endSymbolRecord(LocalEnd);
@@ -2705,9 +2705,9 @@ void CodeViewDebug::emitLexicalBlock(const LexicalBlock &Block,
                                     const FunctionInfo& FI) {
  MCSymbol *RecordEnd = beginSymbolRecord(SymbolKind::S_BLOCK32);
  OS.AddComment("PtrParent");
  OS.emitIntValue(0, 4);                                  // PtrParent
  OS.emitInt32(0); // PtrParent
  OS.AddComment("PtrEnd");
  OS.emitIntValue(0, 4);                                  // PtrEnd
  OS.emitInt32(0); // PtrEnd
  OS.AddComment("Code size");
  OS.emitAbsoluteSymbolDiff(Block.End, Block.Begin, 4);   // Code Size
  OS.AddComment("Function section relative address");
@@ -2915,7 +2915,7 @@ void CodeViewDebug::beginInstruction(const MachineInstr *MI) {
MCSymbol *CodeViewDebug::beginCVSubsection(DebugSubsectionKind Kind) {
  MCSymbol *BeginLabel = MMI->getContext().createTempSymbol(),
           *EndLabel = MMI->getContext().createTempSymbol();
  OS.emitIntValue(unsigned(Kind), 4);
  OS.emitInt32(unsigned(Kind));
  OS.AddComment("Subsection size");
  OS.emitAbsoluteSymbolDiff(EndLabel, BeginLabel, 4);
  OS.emitLabel(BeginLabel);
@@ -2943,7 +2943,7 @@ MCSymbol *CodeViewDebug::beginSymbolRecord(SymbolKind SymKind) {
  OS.emitLabel(BeginLabel);
  if (OS.isVerboseAsm())
    OS.AddComment("Record kind: " + getSymbolName(SymKind));
  OS.emitIntValue(unsigned(SymKind), 2);
  OS.emitInt16(unsigned(SymKind));
  return EndLabel;
}

@@ -2958,10 +2958,10 @@ void CodeViewDebug::endSymbolRecord(MCSymbol *SymEnd) {

void CodeViewDebug::emitEndSymbolRecord(SymbolKind EndKind) {
  OS.AddComment("Record length");
  OS.emitIntValue(2, 2);
  OS.emitInt16(2);
  if (OS.isVerboseAsm())
    OS.AddComment("Record kind: " + getSymbolName(EndKind));
  OS.emitIntValue(unsigned(EndKind), 2); // Record Kind
  OS.emitInt16(uint16_t(EndKind)); // Record Kind
}

void CodeViewDebug::emitDebugInfoForUDTs(
@@ -2972,7 +2972,7 @@ void CodeViewDebug::emitDebugInfoForUDTs(

    MCSymbol *UDTRecordEnd = beginSymbolRecord(SymbolKind::S_UDT);
    OS.AddComment("Type");
    OS.emitIntValue(getCompleteTypeIndex(T).getIndex(), 4);
    OS.emitInt32(getCompleteTypeIndex(T).getIndex());
    emitNullTerminatedSymbolName(OS, UDT.first);
    endSymbolRecord(UDTRecordEnd);
  }
@@ -3088,7 +3088,7 @@ void CodeViewDebug::emitDebugInfoForGlobal(const CVGlobalVariable &CVGV) {
                                                      : SymbolKind::S_GDATA32);
    MCSymbol *DataEnd = beginSymbolRecord(DataSym);
    OS.AddComment("Type");
    OS.emitIntValue(getCompleteTypeIndex(DIGV->getType()).getIndex(), 4);
    OS.emitInt32(getCompleteTypeIndex(DIGV->getType()).getIndex());
    OS.AddComment("DataOffset");
    OS.EmitCOFFSecRel32(GVSym, /*Offset=*/0);
    OS.AddComment("Segment");
@@ -3107,7 +3107,7 @@ void CodeViewDebug::emitDebugInfoForGlobal(const CVGlobalVariable &CVGV) {

    MCSymbol *SConstantEnd = beginSymbolRecord(SymbolKind::S_CONSTANT);
    OS.AddComment("Type");
    OS.emitIntValue(getTypeIndex(DIGV->getType()).getIndex(), 4);
    OS.emitInt32(getTypeIndex(DIGV->getType()).getIndex());
    OS.AddComment("Value");

    // Encoded integers shouldn't need more than 10 bytes.
+25 −25
Original line number Diff line number Diff line
@@ -717,36 +717,36 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
  OS.emitLabel(FuncInfoXData);

  AddComment("MagicNumber");
  OS.emitIntValue(0x19930522, 4);
  OS.emitInt32(0x19930522);

  AddComment("MaxState");
  OS.emitIntValue(FuncInfo.CxxUnwindMap.size(), 4);
  OS.emitInt32(FuncInfo.CxxUnwindMap.size());

  AddComment("UnwindMap");
  OS.emitValue(create32bitRef(UnwindMapXData), 4);

  AddComment("NumTryBlocks");
  OS.emitIntValue(FuncInfo.TryBlockMap.size(), 4);
  OS.emitInt32(FuncInfo.TryBlockMap.size());

  AddComment("TryBlockMap");
  OS.emitValue(create32bitRef(TryBlockMapXData), 4);

  AddComment("IPMapEntries");
  OS.emitIntValue(IPToStateTable.size(), 4);
  OS.emitInt32(IPToStateTable.size());

  AddComment("IPToStateXData");
  OS.emitValue(create32bitRef(IPToStateXData), 4);

  if (Asm->MAI->usesWindowsCFI()) {
    AddComment("UnwindHelp");
    OS.emitIntValue(UnwindHelpOffset, 4);
    OS.emitInt32(UnwindHelpOffset);
  }

  AddComment("ESTypeList");
  OS.emitIntValue(0, 4);
  OS.emitInt32(0);

  AddComment("EHFlags");
  OS.emitIntValue(1, 4);
  OS.emitInt32(1);

  // UnwindMapEntry {
  //   int32_t ToState;
@@ -758,7 +758,7 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
      MCSymbol *CleanupSym =
          getMCSymbolForMBB(Asm, UME.Cleanup.dyn_cast<MachineBasicBlock *>());
      AddComment("ToState");
      OS.emitIntValue(UME.ToState, 4);
      OS.emitInt32(UME.ToState);

      AddComment("Action");
      OS.emitValue(create32bitRef(CleanupSym), 4);
@@ -795,16 +795,16 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
             "bad trymap interval");

      AddComment("TryLow");
      OS.emitIntValue(TBME.TryLow, 4);
      OS.emitInt32(TBME.TryLow);

      AddComment("TryHigh");
      OS.emitIntValue(TBME.TryHigh, 4);
      OS.emitInt32(TBME.TryHigh);

      AddComment("CatchHigh");
      OS.emitIntValue(TBME.CatchHigh, 4);
      OS.emitInt32(TBME.CatchHigh);

      AddComment("NumCatches");
      OS.emitIntValue(TBME.HandlerArray.size(), 4);
      OS.emitInt32(TBME.HandlerArray.size());

      AddComment("HandlerArray");
      OS.emitValue(create32bitRef(HandlerMapXData), 4);
@@ -847,7 +847,7 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
            getMCSymbolForMBB(Asm, HT.Handler.dyn_cast<MachineBasicBlock *>());

        AddComment("Adjectives");
        OS.emitIntValue(HT.Adjectives, 4);
        OS.emitInt32(HT.Adjectives);

        AddComment("Type");
        OS.emitValue(create32bitRef(HT.TypeDescriptor), 4);
@@ -860,7 +860,7 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {

        if (shouldEmitPersonality) {
          AddComment("ParentFrameOffset");
          OS.emitIntValue(ParentFrameOffset, 4);
          OS.emitInt32(ParentFrameOffset);
        }
      }
    }
@@ -876,7 +876,7 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) {
      AddComment("IP");
      OS.emitValue(IPStatePair.first, 4);
      AddComment("ToState");
      OS.emitIntValue(IPStatePair.second, 4);
      OS.emitInt32(IPStatePair.second);
    }
  }
}
@@ -1028,13 +1028,13 @@ void WinException::emitExceptHandlerTable(const MachineFunction *MF) {
    }

    AddComment("GSCookieOffset");
    OS.emitIntValue(GSCookieOffset, 4);
    OS.emitInt32(GSCookieOffset);
    AddComment("GSCookieXOROffset");
    OS.emitIntValue(0, 4);
    OS.emitInt32(0);
    AddComment("EHCookieOffset");
    OS.emitIntValue(EHCookieOffset, 4);
    OS.emitInt32(EHCookieOffset);
    AddComment("EHCookieXOROffset");
    OS.emitIntValue(0, 4);
    OS.emitInt32(0);
    BaseState = -2;
  }

@@ -1047,7 +1047,7 @@ void WinException::emitExceptHandlerTable(const MachineFunction *MF) {
    // _except_handler4 it's -2. Do that replacement here if necessary.
    int ToState = UME.ToState == -1 ? BaseState : UME.ToState;
    AddComment("ToState");
    OS.emitIntValue(ToState, 4);
    OS.emitInt32(ToState);
    AddComment(UME.IsFinally ? "Null" : "FilterFunction");
    OS.emitValue(create32bitRef(UME.Filter), 4);
    AddComment(UME.IsFinally ? "FinallyFunclet" : "ExceptionHandler");
@@ -1124,9 +1124,9 @@ void WinException::emitCLRExceptionTable(const MachineFunction *MF) {

  // Write out a sentinel indicating the end of the standard (Windows) xdata
  // and the start of the additional (CLR) info.
  OS.emitIntValue(0xffffffff, 4);
  OS.emitInt32(0xffffffff);
  // Write out the number of funclets
  OS.emitIntValue(NumStates, 4);
  OS.emitInt32(NumStates);

  // Walk the machine blocks/instrs, computing and emitting a few things:
  // 1. Emit a list of the offsets to each handler entry, in lexical order.
@@ -1217,7 +1217,7 @@ void WinException::emitCLRExceptionTable(const MachineFunction *MF) {
  }

  // Now emit the clause info, starting with the number of clauses.
  OS.emitIntValue(Clauses.size(), 4);
  OS.emitInt32(Clauses.size());
  for (ClrClause &Clause : Clauses) {
    // Emit a CORINFO_EH_CLAUSE :
    /*
@@ -1299,7 +1299,7 @@ void WinException::emitCLRExceptionTable(const MachineFunction *MF) {
      assert(Clause.EnclosingState > MinClauseMap[Clause.State]);
      Flags |= 8;
    }
    OS.emitIntValue(Flags, 4);
    OS.emitInt32(Flags);

    // Write the clause start/end
    OS.emitValue(ClauseBegin, 4);
@@ -1311,6 +1311,6 @@ void WinException::emitCLRExceptionTable(const MachineFunction *MF) {

    // Write out the type token or filter offset
    assert(Entry.HandlerType != ClrHandlerType::Filter && "NYI: filters");
    OS.emitIntValue(Entry.TypeToken, 4);
    OS.emitInt32(Entry.TypeToken);
  }
}
+5 −5
Original line number Diff line number Diff line
@@ -64,10 +64,10 @@ void FaultMaps::serializeToFaultMapSection() {
  // Header
  OS.emitIntValue(FaultMapVersion, 1); // Version.
  OS.emitIntValue(0, 1);               // Reserved.
  OS.emitIntValue(0, 2);               // Reserved.
  OS.emitInt16(0);                     // Reserved.

  LLVM_DEBUG(dbgs() << WFMP << "#functions = " << FunctionInfos.size() << "\n");
  OS.emitIntValue(FunctionInfos.size(), 4);
  OS.emitInt32(FunctionInfos.size());

  LLVM_DEBUG(dbgs() << WFMP << "functions:\n");

@@ -83,14 +83,14 @@ void FaultMaps::emitFunctionInfo(const MCSymbol *FnLabel,
  OS.emitSymbolValue(FnLabel, 8);

  LLVM_DEBUG(dbgs() << WFMP << "  #faulting PCs: " << FFI.size() << "\n");
  OS.emitIntValue(FFI.size(), 4);
  OS.emitInt32(FFI.size());

  OS.emitIntValue(0, 4); // Reserved
  OS.emitInt32(0); // Reserved

  for (auto &Fault : FFI) {
    LLVM_DEBUG(dbgs() << WFMP << "    fault type: "
                      << faultTypeToString(Fault.Kind) << "\n");
    OS.emitIntValue(Fault.Kind, 4);
    OS.emitInt32(Fault.Kind);

    LLVM_DEBUG(dbgs() << WFMP << "    faulting PC offset: "
                      << *Fault.FaultingOffsetExpr << "\n");
Loading