LCOV - code coverage report
Current view: top level - lib/MC - MCStreamer.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 473 549 86.2 %
Date: 2018-06-17 00:07:59 Functions: 103 136 75.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- lib/MC/MCStreamer.cpp - Streaming Machine Code Output --------------===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #include "llvm/MC/MCStreamer.h"
      11             : #include "llvm/ADT/Optional.h"
      12             : #include "llvm/ADT/SmallString.h"
      13             : #include "llvm/ADT/StringRef.h"
      14             : #include "llvm/ADT/Twine.h"
      15             : #include "llvm/BinaryFormat/COFF.h"
      16             : #include "llvm/MC/MCAsmBackend.h"
      17             : #include "llvm/MC/MCAsmInfo.h"
      18             : #include "llvm/MC/MCCodeView.h"
      19             : #include "llvm/MC/MCContext.h"
      20             : #include "llvm/MC/MCDwarf.h"
      21             : #include "llvm/MC/MCExpr.h"
      22             : #include "llvm/MC/MCInst.h"
      23             : #include "llvm/MC/MCInstPrinter.h"
      24             : #include "llvm/MC/MCObjectFileInfo.h"
      25             : #include "llvm/MC/MCSection.h"
      26             : #include "llvm/MC/MCSectionCOFF.h"
      27             : #include "llvm/MC/MCSymbol.h"
      28             : #include "llvm/MC/MCWin64EH.h"
      29             : #include "llvm/MC/MCWinEH.h"
      30             : #include "llvm/Support/Casting.h"
      31             : #include "llvm/Support/ErrorHandling.h"
      32             : #include "llvm/Support/LEB128.h"
      33             : #include "llvm/Support/MathExtras.h"
      34             : #include "llvm/Support/raw_ostream.h"
      35             : #include <cassert>
      36             : #include <cstdint>
      37             : #include <cstdlib>
      38             : #include <utility>
      39             : 
      40             : using namespace llvm;
      41             : 
      42       22452 : MCTargetStreamer::MCTargetStreamer(MCStreamer &S) : Streamer(S) {
      43             :   S.setTargetStreamer(this);
      44       22452 : }
      45             : 
      46             : // Pin the vtables to this file.
      47             : MCTargetStreamer::~MCTargetStreamer() = default;
      48             : 
      49      410218 : void MCTargetStreamer::emitLabel(MCSymbol *Symbol) {}
      50             : 
      51       14919 : void MCTargetStreamer::finish() {}
      52             : 
      53      138608 : void MCTargetStreamer::changeSection(const MCSection *CurSection,
      54             :                                      MCSection *Section,
      55             :                                      const MCExpr *Subsection,
      56             :                                      raw_ostream &OS) {
      57      277216 :   Section->PrintSwitchToSection(
      58      138608 :       *Streamer.getContext().getAsmInfo(),
      59      138608 :       Streamer.getContext().getObjectFileInfo()->getTargetTriple(), OS,
      60      138608 :       Subsection);
      61      138607 : }
      62             : 
      63         346 : void MCTargetStreamer::emitDwarfFileDirective(StringRef Directive) {
      64         692 :   Streamer.EmitRawText(Directive);
      65         346 : }
      66             : 
      67      429465 : void MCTargetStreamer::emitValue(const MCExpr *Value) {
      68             :   SmallString<128> Str;
      69             :   raw_svector_ostream OS(Str);
      70             : 
      71      429465 :   Value->print(OS, Streamer.getContext().getAsmInfo());
      72     1288395 :   Streamer.EmitRawText(OS.str());
      73      429465 : }
      74             : 
      75        2345 : void MCTargetStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {}
      76             : 
      77       29937 : MCStreamer::MCStreamer(MCContext &Ctx)
      78             :     : Context(Ctx), CurrentWinFrameInfo(nullptr),
      79       89811 :       UseAssemblerInfoForParsing(false) {
      80       59874 :   SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
      81       29937 : }
      82             : 
      83       89379 : MCStreamer::~MCStreamer() {}
      84             : 
      85       22514 : void MCStreamer::reset() {
      86             :   DwarfFrameInfos.clear();
      87       22514 :   CurrentWinFrameInfo = nullptr;
      88       22514 :   WinFrameInfos.clear();
      89       22514 :   SymbolOrdering.clear();
      90             :   SectionStack.clear();
      91       45028 :   SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
      92       22514 : }
      93             : 
      94           0 : raw_ostream &MCStreamer::GetCommentOS() {
      95             :   // By default, discard comments.
      96           0 :   return nulls();
      97             : }
      98             : 
      99         885 : void MCStreamer::emitRawComment(const Twine &T, bool TabPrefix) {}
     100             : 
     101       58987 : void MCStreamer::addExplicitComment(const Twine &T) {}
     102           0 : void MCStreamer::emitExplicitComments() {}
     103             : 
     104        3173 : void MCStreamer::generateCompactUnwindEncodings(MCAsmBackend *MAB) {
     105       49109 :   for (auto &FI : DwarfFrameInfos)
     106       45936 :     FI.CompactUnwindEncoding =
     107       92246 :         (MAB ? MAB->generateCompactUnwindEncoding(FI.Instructions) : 0);
     108        3173 : }
     109             : 
     110             : /// EmitIntValue - Special case of EmitValue that avoids the client having to
     111             : /// pass in a MCExpr for constant integers.
     112     9999008 : void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
     113             :   assert(1 <= Size && Size <= 8 && "Invalid size");
     114             :   assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
     115             :          "Invalid size");
     116             :   char buf[8];
     117     9999008 :   const bool isLittleEndian = Context.getAsmInfo()->isLittleEndian();
     118    65499450 :   for (unsigned i = 0; i != Size; ++i) {
     119    27750221 :     unsigned index = isLittleEndian ? i : (Size - i - 1);
     120    27750221 :     buf[i] = uint8_t(Value >> (index * 8));
     121             :   }
     122    19998016 :   EmitBytes(StringRef(buf, Size));
     123     9999008 : }
     124             : 
     125             : /// EmitULEB128IntValue - Special case of EmitULEB128Value that avoids the
     126             : /// client having to pass in a MCExpr for constant integers.
     127     4282651 : void MCStreamer::EmitULEB128IntValue(uint64_t Value) {
     128             :   SmallString<128> Tmp;
     129             :   raw_svector_ostream OSE(Tmp);
     130     4282651 :   encodeULEB128(Value, OSE);
     131     8565302 :   EmitBytes(OSE.str());
     132     4282651 : }
     133             : 
     134             : /// EmitSLEB128IntValue - Special case of EmitSLEB128Value that avoids the
     135             : /// client having to pass in a MCExpr for constant integers.
     136       91468 : void MCStreamer::EmitSLEB128IntValue(int64_t Value) {
     137             :   SmallString<128> Tmp;
     138             :   raw_svector_ostream OSE(Tmp);
     139       91468 :   encodeSLEB128(Value, OSE);
     140      182936 :   EmitBytes(OSE.str());
     141       91468 : }
     142             : 
     143     1630764 : void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc) {
     144     1630764 :   EmitValueImpl(Value, Size, Loc);
     145     1630764 : }
     146             : 
     147      538409 : void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
     148             :                                  bool IsSectionRelative) {
     149             :   assert((!IsSectionRelative || Size == 4) &&
     150             :          "SectionRelative value requires 4-bytes");
     151             : 
     152      538409 :   if (!IsSectionRelative)
     153     1076806 :     EmitValueImpl(MCSymbolRefExpr::create(Sym, getContext()), Size);
     154             :   else
     155           6 :     EmitCOFFSecRel32(Sym, /*Offset=*/0);
     156      538409 : }
     157             : 
     158           0 : void MCStreamer::EmitDTPRel64Value(const MCExpr *Value) {
     159           0 :   report_fatal_error("unsupported directive in streamer");
     160             : }
     161             : 
     162           0 : void MCStreamer::EmitDTPRel32Value(const MCExpr *Value) {
     163           0 :   report_fatal_error("unsupported directive in streamer");
     164             : }
     165             : 
     166           0 : void MCStreamer::EmitTPRel64Value(const MCExpr *Value) {
     167           0 :   report_fatal_error("unsupported directive in streamer");
     168             : }
     169             : 
     170           0 : void MCStreamer::EmitTPRel32Value(const MCExpr *Value) {
     171           0 :   report_fatal_error("unsupported directive in streamer");
     172             : }
     173             : 
     174           0 : void MCStreamer::EmitGPRel64Value(const MCExpr *Value) {
     175           0 :   report_fatal_error("unsupported directive in streamer");
     176             : }
     177             : 
     178           0 : void MCStreamer::EmitGPRel32Value(const MCExpr *Value) {
     179           0 :   report_fatal_error("unsupported directive in streamer");
     180             : }
     181             : 
     182             : /// Emit NumBytes bytes worth of the value specified by FillValue.
     183             : /// This implements directives such as '.space'.
     184      250123 : void MCStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
     185      250123 :   emitFill(*MCConstantExpr::create(NumBytes, getContext()), FillValue);
     186      250123 : }
     187             : 
     188             : /// The implementation in this class just redirects to emitFill.
     189      247505 : void MCStreamer::EmitZeros(uint64_t NumBytes) {
     190      247505 :   emitFill(NumBytes, 0);
     191      247505 : }
     192             : 
     193             : Expected<unsigned>
     194     1489415 : MCStreamer::tryEmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
     195             :                                       StringRef Filename,
     196             :                                       MD5::MD5Result *Checksum,
     197             :                                       Optional<StringRef> Source,
     198             :                                       unsigned CUID) {
     199     1489415 :   return getContext().getDwarfFile(Directory, Filename, FileNo, Checksum,
     200     1489415 :                                    Source, CUID);
     201             : }
     202             : 
     203        2963 : void MCStreamer::emitDwarfFile0Directive(StringRef Directory,
     204             :                                          StringRef Filename,
     205             :                                          MD5::MD5Result *Checksum,
     206             :                                          Optional<StringRef> Source,
     207             :                                          unsigned CUID) {
     208        5926 :   getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
     209             :                                       Source);
     210        2963 : }
     211             : 
     212      722807 : void MCStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
     213             :                                        unsigned Column, unsigned Flags,
     214             :                                        unsigned Isa,
     215             :                                        unsigned Discriminator,
     216             :                                        StringRef FileName) {
     217      722807 :   getContext().setCurrentDwarfLoc(FileNo, Line, Column, Flags, Isa,
     218             :                                   Discriminator);
     219      722807 : }
     220             : 
     221        3281 : MCSymbol *MCStreamer::getDwarfLineTableSymbol(unsigned CUID) {
     222        3281 :   MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID);
     223        3281 :   if (!Table.getLabel()) {
     224        3272 :     StringRef Prefix = Context.getAsmInfo()->getPrivateGlobalPrefix();
     225        3272 :     Table.setLabel(
     226        3272 :         Context.getOrCreateSymbol(Prefix + "line_table_start" + Twine(CUID)));
     227             :   }
     228        3281 :   return Table.getLabel();
     229             : }
     230             : 
     231      609045 : bool MCStreamer::hasUnfinishedDwarfFrameInfo() {
     232      609045 :   return !DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End;
     233             : }
     234             : 
     235      460169 : MCDwarfFrameInfo *MCStreamer::getCurrentDwarfFrameInfo() {
     236      460169 :   if (!hasUnfinishedDwarfFrameInfo()) {
     237           4 :     getContext().reportError(SMLoc(), "this directive must appear between "
     238             :                                       ".cfi_startproc and .cfi_endproc "
     239           2 :                                       "directives");
     240           2 :     return nullptr;
     241             :   }
     242      460167 :   return &DwarfFrameInfos.back();
     243             : }
     244             : 
     245          78 : bool MCStreamer::EmitCVFileDirective(unsigned FileNo, StringRef Filename,
     246             :                                      ArrayRef<uint8_t> Checksum,
     247             :                                      unsigned ChecksumKind) {
     248          78 :   return getContext().getCVContext().addFile(*this, FileNo, Filename, Checksum,
     249          78 :                                              ChecksumKind);
     250             : }
     251             : 
     252         239 : bool MCStreamer::EmitCVFuncIdDirective(unsigned FunctionId) {
     253         239 :   return getContext().getCVContext().recordFunctionId(FunctionId);
     254             : }
     255             : 
     256          32 : bool MCStreamer::EmitCVInlineSiteIdDirective(unsigned FunctionId,
     257             :                                              unsigned IAFunc, unsigned IAFile,
     258             :                                              unsigned IALine, unsigned IACol,
     259             :                                              SMLoc Loc) {
     260          32 :   if (getContext().getCVContext().getCVFunctionInfo(IAFunc) == nullptr) {
     261           0 :     getContext().reportError(Loc, "parent function id not introduced by "
     262             :                                   ".cv_func_id or .cv_inline_site_id");
     263           0 :     return true;
     264             :   }
     265             : 
     266          32 :   return getContext().getCVContext().recordInlinedCallSiteId(
     267          32 :       FunctionId, IAFunc, IAFile, IALine, IACol);
     268             : }
     269             : 
     270         899 : void MCStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
     271             :                                     unsigned Line, unsigned Column,
     272             :                                     bool PrologueEnd, bool IsStmt,
     273             :                                     StringRef FileName, SMLoc Loc) {
     274         899 :   CodeViewContext &CVC = getContext().getCVContext();
     275         899 :   MCCVFunctionInfo *FI = CVC.getCVFunctionInfo(FunctionId);
     276         899 :   if (!FI)
     277           0 :     return getContext().reportError(
     278           0 :         Loc, "function id not introduced by .cv_func_id or .cv_inline_site_id");
     279             : 
     280             :   // Track the section
     281         899 :   if (FI->Section == nullptr)
     282         264 :     FI->Section = getCurrentSectionOnly();
     283         635 :   else if (FI->Section != getCurrentSectionOnly())
     284           2 :     return getContext().reportError(
     285             :         Loc,
     286           1 :         "all .cv_loc directives for a function must be in the same section");
     287             : 
     288             :   CVC.setCurrentCVLoc(FunctionId, FileNo, Line, Column, PrologueEnd, IsStmt);
     289             : }
     290             : 
     291         229 : void MCStreamer::EmitCVLinetableDirective(unsigned FunctionId,
     292             :                                           const MCSymbol *Begin,
     293         229 :                                           const MCSymbol *End) {}
     294             : 
     295          30 : void MCStreamer::EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
     296             :                                                 unsigned SourceFileId,
     297             :                                                 unsigned SourceLineNum,
     298             :                                                 const MCSymbol *FnStartSym,
     299          30 :                                                 const MCSymbol *FnEndSym) {}
     300             : 
     301         293 : void MCStreamer::EmitCVDefRangeDirective(
     302             :     ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
     303         293 :     StringRef FixedSizePortion) {}
     304             : 
     305           0 : void MCStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
     306             :                                      MCSymbol *EHSymbol) {
     307           0 : }
     308             : 
     309       22434 : void MCStreamer::InitSections(bool NoExecStack) {
     310       22434 :   SwitchSection(getContext().getObjectFileInfo()->getTextSection());
     311       22434 : }
     312             : 
     313         353 : void MCStreamer::AssignFragment(MCSymbol *Symbol, MCFragment *Fragment) {
     314             :   assert(Fragment);
     315             :   Symbol->setFragment(Fragment);
     316             : 
     317             :   // As we emit symbols into a section, track the order so that they can
     318             :   // be sorted upon later. Zero is reserved to mean 'unemitted'.
     319         706 :   SymbolOrdering[Symbol] = 1 + SymbolOrdering.size();
     320         353 : }
     321             : 
     322     3226522 : void MCStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) {
     323             :   Symbol->redefineIfPossible();
     324             : 
     325     6453028 :   if (!Symbol->isUndefined() || Symbol->isVariable())
     326          32 :     return getContext().reportError(Loc, "invalid symbol redefinition");
     327             : 
     328             :   assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
     329             :   assert(getCurrentSectionOnly() && "Cannot emit before setting section!");
     330             :   assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
     331             :   assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
     332             : 
     333             :   Symbol->setFragment(&getCurrentSectionOnly()->getDummyFragment());
     334             : 
     335             :   MCTargetStreamer *TS = getTargetStreamer();
     336     3226506 :   if (TS)
     337      426210 :     TS->emitLabel(Symbol);
     338             : }
     339             : 
     340         223 : void MCStreamer::EmitCFISections(bool EH, bool Debug) {
     341             :   assert(EH || Debug);
     342         223 : }
     343             : 
     344      148876 : void MCStreamer::EmitCFIStartProc(bool IsSimple) {
     345      148876 :   if (hasUnfinishedDwarfFrameInfo())
     346           2 :     getContext().reportError(
     347           1 :         SMLoc(), "starting new .cfi frame before finishing the previous one");
     348             : 
     349             :   MCDwarfFrameInfo Frame;
     350      148876 :   Frame.IsSimple = IsSimple;
     351      148876 :   EmitCFIStartProcImpl(Frame);
     352             : 
     353      148876 :   const MCAsmInfo* MAI = Context.getAsmInfo();
     354      148876 :   if (MAI) {
     355      148876 :     for (const MCCFIInstruction& Inst : MAI->getInitialFrameState()) {
     356      265478 :       if (Inst.getOperation() == MCCFIInstruction::OpDefCfa ||
     357             :           Inst.getOperation() == MCCFIInstruction::OpDefCfaRegister) {
     358      148670 :         Frame.CurrentCfaRegister = Inst.getRegister();
     359             :       }
     360             :     }
     361             :   }
     362             : 
     363      148876 :   DwarfFrameInfos.push_back(Frame);
     364      148876 : }
     365             : 
     366          13 : void MCStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
     367          13 : }
     368             : 
     369      148873 : void MCStreamer::EmitCFIEndProc() {
     370      148873 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     371      148873 :   if (!CurFrame)
     372             :     return;
     373      148873 :   EmitCFIEndProcImpl(*CurFrame);
     374             : }
     375             : 
     376      102937 : void MCStreamer::EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
     377             :   // Put a dummy non-null value in Frame.End to mark that this frame has been
     378             :   // closed.
     379      102937 :   Frame.End = (MCSymbol *)1;
     380      102937 : }
     381             : 
     382       40761 : MCSymbol *MCStreamer::EmitCFILabel() {
     383             :   // Return a dummy non-null value so that label fields appear filled in when
     384             :   // generating textual assembly.
     385       40761 :   return (MCSymbol *)1;
     386             : }
     387             : 
     388       43588 : void MCStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
     389       43588 :   MCSymbol *Label = EmitCFILabel();
     390             :   MCCFIInstruction Instruction =
     391       43588 :     MCCFIInstruction::createDefCfa(Label, Register, Offset);
     392       43588 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     393       43588 :   if (!CurFrame)
     394             :     return;
     395       43586 :   CurFrame->Instructions.push_back(Instruction);
     396       43586 :   CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
     397             : }
     398             : 
     399       98893 : void MCStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
     400       98893 :   MCSymbol *Label = EmitCFILabel();
     401             :   MCCFIInstruction Instruction =
     402       98893 :     MCCFIInstruction::createDefCfaOffset(Label, Offset);
     403       98893 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     404       98893 :   if (!CurFrame)
     405             :     return;
     406       98893 :   CurFrame->Instructions.push_back(Instruction);
     407             : }
     408             : 
     409       33559 : void MCStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
     410       33559 :   MCSymbol *Label = EmitCFILabel();
     411             :   MCCFIInstruction Instruction =
     412       33559 :     MCCFIInstruction::createAdjustCfaOffset(Label, Adjustment);
     413       33559 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     414       33559 :   if (!CurFrame)
     415             :     return;
     416       33559 :   CurFrame->Instructions.push_back(Instruction);
     417             : }
     418             : 
     419       39444 : void MCStreamer::EmitCFIDefCfaRegister(int64_t Register) {
     420       39444 :   MCSymbol *Label = EmitCFILabel();
     421             :   MCCFIInstruction Instruction =
     422       39444 :     MCCFIInstruction::createDefCfaRegister(Label, Register);
     423       39444 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     424       39444 :   if (!CurFrame)
     425             :     return;
     426       39444 :   CurFrame->Instructions.push_back(Instruction);
     427       39444 :   CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
     428             : }
     429             : 
     430       72121 : void MCStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
     431       72121 :   MCSymbol *Label = EmitCFILabel();
     432             :   MCCFIInstruction Instruction =
     433       72121 :     MCCFIInstruction::createOffset(Label, Register, Offset);
     434       72121 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     435       72121 :   if (!CurFrame)
     436             :     return;
     437       72121 :   CurFrame->Instructions.push_back(Instruction);
     438             : }
     439             : 
     440          24 : void MCStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) {
     441          24 :   MCSymbol *Label = EmitCFILabel();
     442             :   MCCFIInstruction Instruction =
     443          24 :     MCCFIInstruction::createRelOffset(Label, Register, Offset);
     444          24 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     445          24 :   if (!CurFrame)
     446             :     return;
     447          24 :   CurFrame->Instructions.push_back(Instruction);
     448             : }
     449             : 
     450        6501 : void MCStreamer::EmitCFIPersonality(const MCSymbol *Sym,
     451             :                                     unsigned Encoding) {
     452        6501 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     453        6501 :   if (!CurFrame)
     454             :     return;
     455        6501 :   CurFrame->Personality = Sym;
     456        6501 :   CurFrame->PersonalityEncoding = Encoding;
     457             : }
     458             : 
     459        6464 : void MCStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
     460        6464 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     461        6464 :   if (!CurFrame)
     462             :     return;
     463        6464 :   CurFrame->Lsda = Sym;
     464        6464 :   CurFrame->LsdaEncoding = Encoding;
     465             : }
     466             : 
     467          30 : void MCStreamer::EmitCFIRememberState() {
     468          30 :   MCSymbol *Label = EmitCFILabel();
     469             :   MCCFIInstruction Instruction = MCCFIInstruction::createRememberState(Label);
     470          30 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     471          30 :   if (!CurFrame)
     472             :     return;
     473          30 :   CurFrame->Instructions.push_back(Instruction);
     474             : }
     475             : 
     476          30 : void MCStreamer::EmitCFIRestoreState() {
     477             :   // FIXME: Error if there is no matching cfi_remember_state.
     478          30 :   MCSymbol *Label = EmitCFILabel();
     479             :   MCCFIInstruction Instruction = MCCFIInstruction::createRestoreState(Label);
     480          30 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     481          30 :   if (!CurFrame)
     482             :     return;
     483          30 :   CurFrame->Instructions.push_back(Instruction);
     484             : }
     485             : 
     486           6 : void MCStreamer::EmitCFISameValue(int64_t Register) {
     487           6 :   MCSymbol *Label = EmitCFILabel();
     488             :   MCCFIInstruction Instruction =
     489           6 :     MCCFIInstruction::createSameValue(Label, Register);
     490           6 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     491           6 :   if (!CurFrame)
     492             :     return;
     493           6 :   CurFrame->Instructions.push_back(Instruction);
     494             : }
     495             : 
     496           5 : void MCStreamer::EmitCFIRestore(int64_t Register) {
     497           5 :   MCSymbol *Label = EmitCFILabel();
     498             :   MCCFIInstruction Instruction =
     499           5 :     MCCFIInstruction::createRestore(Label, Register);
     500           5 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     501           5 :   if (!CurFrame)
     502             :     return;
     503           5 :   CurFrame->Instructions.push_back(Instruction);
     504             : }
     505             : 
     506           2 : void MCStreamer::EmitCFIEscape(StringRef Values) {
     507           2 :   MCSymbol *Label = EmitCFILabel();
     508             :   MCCFIInstruction Instruction = MCCFIInstruction::createEscape(Label, Values);
     509           2 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     510           2 :   if (!CurFrame)
     511             :     return;
     512           2 :   CurFrame->Instructions.push_back(Instruction);
     513             : }
     514             : 
     515        9826 : void MCStreamer::EmitCFIGnuArgsSize(int64_t Size) {
     516        9826 :   MCSymbol *Label = EmitCFILabel();
     517             :   MCCFIInstruction Instruction = 
     518        9826 :     MCCFIInstruction::createGnuArgsSize(Label, Size);
     519        9826 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     520        9826 :   if (!CurFrame)
     521             :     return;
     522        9826 :   CurFrame->Instructions.push_back(Instruction);
     523             : }
     524             : 
     525           1 : void MCStreamer::EmitCFISignalFrame() {
     526           1 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     527           1 :   if (!CurFrame)
     528             :     return;
     529           1 :   CurFrame->IsSignalFrame = true;
     530             : }
     531             : 
     532           1 : void MCStreamer::EmitCFIUndefined(int64_t Register) {
     533           1 :   MCSymbol *Label = EmitCFILabel();
     534             :   MCCFIInstruction Instruction =
     535           1 :     MCCFIInstruction::createUndefined(Label, Register);
     536           1 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     537           1 :   if (!CurFrame)
     538             :     return;
     539           1 :   CurFrame->Instructions.push_back(Instruction);
     540             : }
     541             : 
     542         398 : void MCStreamer::EmitCFIRegister(int64_t Register1, int64_t Register2) {
     543         398 :   MCSymbol *Label = EmitCFILabel();
     544             :   MCCFIInstruction Instruction =
     545         398 :     MCCFIInstruction::createRegister(Label, Register1, Register2);
     546         398 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     547         398 :   if (!CurFrame)
     548             :     return;
     549         398 :   CurFrame->Instructions.push_back(Instruction);
     550             : }
     551             : 
     552         397 : void MCStreamer::EmitCFIWindowSave() {
     553         397 :   MCSymbol *Label = EmitCFILabel();
     554             :   MCCFIInstruction Instruction =
     555             :     MCCFIInstruction::createWindowSave(Label);
     556         397 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     557         397 :   if (!CurFrame)
     558             :     return;
     559         397 :   CurFrame->Instructions.push_back(Instruction);
     560             : }
     561             : 
     562           6 : void MCStreamer::EmitCFIReturnColumn(int64_t Register) {
     563           6 :   MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
     564           6 :   if (!CurFrame)
     565             :     return;
     566           6 :   CurFrame->RAReg = Register;
     567             : }
     568             : 
     569        2924 : WinEH::FrameInfo *MCStreamer::EnsureValidWinFrameInfo(SMLoc Loc) {
     570        2924 :   const MCAsmInfo *MAI = Context.getAsmInfo();
     571        2924 :   if (!MAI->usesWindowsCFI()) {
     572           0 :     getContext().reportError(
     573             :         Loc, ".seh_* directives are not supported on this target");
     574           0 :     return nullptr;
     575             :   }
     576        5846 :   if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End) {
     577           3 :     getContext().reportError(
     578             :         Loc, ".seh_ directive must appear within an active frame");
     579           3 :     return nullptr;
     580             :   }
     581             :   return CurrentWinFrameInfo;
     582             : }
     583             : 
     584         544 : void MCStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc) {
     585         544 :   const MCAsmInfo *MAI = Context.getAsmInfo();
     586         544 :   if (!MAI->usesWindowsCFI())
     587           0 :     return getContext().reportError(
     588             :         Loc, ".seh_* directives are not supported on this target");
     589         919 :   if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End)
     590           0 :     getContext().reportError(
     591             :         Loc, "Starting a function before ending the previous one!");
     592             : 
     593         544 :   MCSymbol *StartProc = EmitCFILabel();
     594             : 
     595        1088 :   WinFrameInfos.emplace_back(
     596        1088 :       llvm::make_unique<WinEH::FrameInfo>(Symbol, StartProc));
     597         544 :   CurrentWinFrameInfo = WinFrameInfos.back().get();
     598         544 :   CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
     599             : }
     600             : 
     601         543 : void MCStreamer::EmitWinCFIEndProc(SMLoc Loc) {
     602         543 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     603         543 :   if (!CurFrame)
     604             :     return;
     605         543 :   if (CurFrame->ChainedParent)
     606           0 :     getContext().reportError(Loc, "Not all chained regions terminated!");
     607             : 
     608         543 :   MCSymbol *Label = EmitCFILabel();
     609         543 :   CurFrame->End = Label;
     610             : }
     611             : 
     612           2 : void MCStreamer::EmitWinCFIStartChained(SMLoc Loc) {
     613           2 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     614           2 :   if (!CurFrame)
     615             :     return;
     616             : 
     617           2 :   MCSymbol *StartProc = EmitCFILabel();
     618             : 
     619           4 :   WinFrameInfos.emplace_back(llvm::make_unique<WinEH::FrameInfo>(
     620             :       CurFrame->Function, StartProc, CurFrame));
     621           2 :   CurrentWinFrameInfo = WinFrameInfos.back().get();
     622           2 :   CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
     623             : }
     624             : 
     625           2 : void MCStreamer::EmitWinCFIEndChained(SMLoc Loc) {
     626           2 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     627           2 :   if (!CurFrame)
     628             :     return;
     629           2 :   if (!CurFrame->ChainedParent)
     630           0 :     return getContext().reportError(
     631           0 :         Loc, "End of a chained region outside a chained region!");
     632             : 
     633           2 :   MCSymbol *Label = EmitCFILabel();
     634             : 
     635           2 :   CurFrame->End = Label;
     636           2 :   CurrentWinFrameInfo = const_cast<WinEH::FrameInfo *>(CurFrame->ChainedParent);
     637             : }
     638             : 
     639         133 : void MCStreamer::EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except,
     640             :                                   SMLoc Loc) {
     641         133 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     642         133 :   if (!CurFrame)
     643             :     return;
     644         133 :   if (CurFrame->ChainedParent)
     645           0 :     return getContext().reportError(
     646           0 :         Loc, "Chained unwind areas can't have handlers!");
     647         133 :   CurFrame->ExceptionHandler = Sym;
     648         133 :   if (!Except && !Unwind)
     649           0 :     getContext().reportError(Loc, "Don't know what kind of handler this is!");
     650         133 :   if (Unwind)
     651         130 :     CurFrame->HandlesUnwind = true;
     652         133 :   if (Except)
     653         133 :     CurFrame->HandlesExceptions = true;
     654             : }
     655             : 
     656         534 : void MCStreamer::EmitWinEHHandlerData(SMLoc Loc) {
     657         534 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     658         534 :   if (!CurFrame)
     659             :     return;
     660         534 :   if (CurFrame->ChainedParent)
     661           0 :     getContext().reportError(Loc, "Chained unwind areas can't have handlers!");
     662             : }
     663             : 
     664           0 : void MCStreamer::emitCGProfileEntry(const MCSymbolRefExpr *From,
     665             :                                     const MCSymbolRefExpr *To, uint64_t Count) {
     666           0 : }
     667             : 
     668         805 : static MCSection *getWinCFISection(MCContext &Context, unsigned *NextWinCFIID,
     669             :                                    MCSection *MainCFISec,
     670             :                                    const MCSection *TextSec) {
     671             :   // If this is the main .text section, use the main unwind info section.
     672         805 :   if (TextSec == Context.getObjectFileInfo()->getTextSection())
     673             :     return MainCFISec;
     674             : 
     675             :   const auto *TextSecCOFF = cast<MCSectionCOFF>(TextSec);
     676             :   unsigned UniqueID = TextSecCOFF->getOrAssignWinCFISectionID(NextWinCFIID);
     677             : 
     678             :   // If this section is COMDAT, this unwind section should be COMDAT associative
     679             :   // with its group.
     680             :   const MCSymbol *KeySym = nullptr;
     681         104 :   if (TextSecCOFF->getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT)
     682         100 :     KeySym = TextSecCOFF->getCOMDATSymbol();
     683             : 
     684             :   return Context.getAssociativeCOFFSection(cast<MCSectionCOFF>(MainCFISec),
     685         104 :                                            KeySym, UniqueID);
     686             : }
     687             : 
     688          89 : MCSection *MCStreamer::getAssociatedPDataSection(const MCSection *TextSec) {
     689          89 :   return getWinCFISection(getContext(), &NextWinCFIID,
     690          89 :                           getContext().getObjectFileInfo()->getPDataSection(),
     691          89 :                           TextSec);
     692             : }
     693             : 
     694         716 : MCSection *MCStreamer::getAssociatedXDataSection(const MCSection *TextSec) {
     695         716 :   return getWinCFISection(getContext(), &NextWinCFIID,
     696         716 :                           getContext().getObjectFileInfo()->getXDataSection(),
     697         716 :                           TextSec);
     698             : }
     699             : 
     700        3804 : void MCStreamer::EmitSyntaxDirective() {}
     701             : 
     702         414 : void MCStreamer::EmitWinCFIPushReg(unsigned Register, SMLoc Loc) {
     703         414 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     704         414 :   if (!CurFrame)
     705           2 :     return;
     706             : 
     707         412 :   MCSymbol *Label = EmitCFILabel();
     708             : 
     709             :   WinEH::Instruction Inst = Win64EH::Instruction::PushNonVol(Label, Register);
     710         412 :   CurFrame->Instructions.push_back(Inst);
     711             : }
     712             : 
     713          96 : void MCStreamer::EmitWinCFISetFrame(unsigned Register, unsigned Offset,
     714             :                                     SMLoc Loc) {
     715          96 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     716          96 :   if (!CurFrame)
     717           3 :     return;
     718          96 :   if (CurFrame->LastFrameInst >= 0)
     719           2 :     return getContext().reportError(
     720           1 :         Loc, "frame register and offset can be set at most once");
     721          95 :   if (Offset & 0x0F)
     722           2 :     return getContext().reportError(Loc, "offset is not a multiple of 16");
     723          94 :   if (Offset > 240)
     724           2 :     return getContext().reportError(
     725           1 :         Loc, "frame offset must be less than or equal to 240");
     726             : 
     727          93 :   MCSymbol *Label = EmitCFILabel();
     728             : 
     729             :   WinEH::Instruction Inst =
     730             :       Win64EH::Instruction::SetFPReg(Label, Register, Offset);
     731         186 :   CurFrame->LastFrameInst = CurFrame->Instructions.size();
     732          93 :   CurFrame->Instructions.push_back(Inst);
     733             : }
     734             : 
     735         510 : void MCStreamer::EmitWinCFIAllocStack(unsigned Size, SMLoc Loc) {
     736         510 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     737         510 :   if (!CurFrame)
     738           4 :     return;
     739         509 :   if (Size == 0)
     740           4 :     return getContext().reportError(Loc,
     741           2 :                                     "stack allocation size must be non-zero");
     742         507 :   if (Size & 7)
     743           2 :     return getContext().reportError(
     744           1 :         Loc, "stack allocation size is not a multiple of 8");
     745             : 
     746         506 :   MCSymbol *Label = EmitCFILabel();
     747             : 
     748             :   WinEH::Instruction Inst = Win64EH::Instruction::Alloc(Label, Size);
     749         506 :   CurFrame->Instructions.push_back(Inst);
     750             : }
     751             : 
     752           2 : void MCStreamer::EmitWinCFISaveReg(unsigned Register, unsigned Offset,
     753             :                                    SMLoc Loc) {
     754           2 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     755           2 :   if (!CurFrame)
     756           0 :     return;
     757             : 
     758           2 :   if (Offset & 7)
     759           0 :     return getContext().reportError(
     760           0 :         Loc, "register save offset is not 8 byte aligned");
     761             : 
     762           2 :   MCSymbol *Label = EmitCFILabel();
     763             : 
     764             :   WinEH::Instruction Inst =
     765             :       Win64EH::Instruction::SaveNonVol(Label, Register, Offset);
     766           2 :   CurFrame->Instructions.push_back(Inst);
     767             : }
     768             : 
     769         146 : void MCStreamer::EmitWinCFISaveXMM(unsigned Register, unsigned Offset,
     770             :                                    SMLoc Loc) {
     771         146 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     772         146 :   if (!CurFrame)
     773           1 :     return;
     774         146 :   if (Offset & 0x0F)
     775           2 :     return getContext().reportError(Loc, "offset is not a multiple of 16");
     776             : 
     777         145 :   MCSymbol *Label = EmitCFILabel();
     778             : 
     779             :   WinEH::Instruction Inst =
     780             :       Win64EH::Instruction::SaveXMM(Label, Register, Offset);
     781         145 :   CurFrame->Instructions.push_back(Inst);
     782             : }
     783             : 
     784           2 : void MCStreamer::EmitWinCFIPushFrame(bool Code, SMLoc Loc) {
     785           2 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     786           2 :   if (!CurFrame)
     787           0 :     return;
     788           2 :   if (!CurFrame->Instructions.empty())
     789           0 :     return getContext().reportError(
     790           0 :         Loc, "If present, PushMachFrame must be the first UOP");
     791             : 
     792           2 :   MCSymbol *Label = EmitCFILabel();
     793             : 
     794             :   WinEH::Instruction Inst = Win64EH::Instruction::PushMachFrame(Label, Code);
     795           2 :   CurFrame->Instructions.push_back(Inst);
     796             : }
     797             : 
     798         540 : void MCStreamer::EmitWinCFIEndProlog(SMLoc Loc) {
     799         540 :   WinEH::FrameInfo *CurFrame = EnsureValidWinFrameInfo(Loc);
     800         540 :   if (!CurFrame)
     801             :     return;
     802             : 
     803         540 :   MCSymbol *Label = EmitCFILabel();
     804             : 
     805         540 :   CurFrame->PrologEnd = Label;
     806             : }
     807             : 
     808           0 : void MCStreamer::EmitCOFFSafeSEH(MCSymbol const *Symbol) {
     809           0 : }
     810             : 
     811           0 : void MCStreamer::EmitCOFFSymbolIndex(MCSymbol const *Symbol) {}
     812             : 
     813           0 : void MCStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
     814           0 : }
     815             : 
     816          17 : void MCStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) {}
     817             : 
     818             : /// EmitRawText - If this file is backed by an assembly streamer, this dumps
     819             : /// the specified string in the output .s file.  This capability is
     820             : /// indicated by the hasRawTextSupport() predicate.
     821           0 : void MCStreamer::EmitRawTextImpl(StringRef String) {
     822           0 :   errs() << "EmitRawText called on an MCStreamer that doesn't support it, "
     823             :   " something must not be fully mc'ized\n";
     824           0 :   abort();
     825             : }
     826             : 
     827      440044 : void MCStreamer::EmitRawText(const Twine &T) {
     828             :   SmallString<128> Str;
     829      440044 :   EmitRawTextImpl(T.toStringRef(Str));
     830      440044 : }
     831             : 
     832           0 : void MCStreamer::EmitWindowsUnwindTables() {
     833           0 : }
     834             : 
     835       27882 : void MCStreamer::Finish() {
     836       55762 :   if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) ||
     837         167 :       (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
     838           6 :     getContext().reportError(SMLoc(), "Unfinished frame!");
     839           3 :     return;
     840             :   }
     841             : 
     842             :   MCTargetStreamer *TS = getTargetStreamer();
     843       27879 :   if (TS)
     844       20744 :     TS->finish();
     845             : 
     846       27879 :   FinishImpl();
     847             : }
     848             : 
     849        7122 : void MCStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
     850        7122 :   visitUsedExpr(*Value);
     851        7122 :   Symbol->setVariableValue(Value);
     852             : 
     853             :   MCTargetStreamer *TS = getTargetStreamer();
     854        7122 :   if (TS)
     855        2398 :     TS->emitAssignment(Symbol, Value);
     856        7122 : }
     857             : 
     858     1764119 : void MCTargetStreamer::prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS,
     859             :                               const MCInst &Inst, const MCSubtargetInfo &STI) {
     860     3528238 :   InstPrinter.printInst(&Inst, OS, "", STI);
     861     1764119 : }
     862             : 
     863        2541 : void MCStreamer::visitUsedSymbol(const MCSymbol &Sym) {
     864        2541 : }
     865             : 
     866     3238793 : void MCStreamer::visitUsedExpr(const MCExpr &Expr) {
     867     3887230 :   switch (Expr.getKind()) {
     868             :   case MCExpr::Target:
     869       13886 :     cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
     870       13886 :     break;
     871             : 
     872             :   case MCExpr::Constant:
     873             :     break;
     874             : 
     875             :   case MCExpr::Binary: {
     876             :     const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
     877      648416 :     visitUsedExpr(*BE.getLHS());
     878      648416 :     visitUsedExpr(*BE.getRHS());
     879      648416 :     break;
     880             :   }
     881             : 
     882     2802219 :   case MCExpr::SymbolRef:
     883     2802219 :     visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
     884     2802219 :     break;
     885             : 
     886             :   case MCExpr::Unary:
     887          21 :     visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
     888          21 :     break;
     889             :   }
     890     3238793 : }
     891             : 
     892     2094501 : void MCStreamer::EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
     893             :                                  bool) {
     894             :   // Scan for values.
     895    10112566 :   for (unsigned i = Inst.getNumOperands(); i--;)
     896     8018065 :     if (Inst.getOperand(i).isExpr())
     897      843842 :       visitUsedExpr(*Inst.getOperand(i).getExpr());
     898     2094501 : }
     899             : 
     900       28280 : void MCStreamer::emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo,
     901             :                                         unsigned Size) {
     902             :   // Get the Hi-Lo expression.
     903             :   const MCExpr *Diff =
     904       56560 :       MCBinaryExpr::createSub(MCSymbolRefExpr::create(Hi, Context),
     905             :                               MCSymbolRefExpr::create(Lo, Context), Context);
     906             : 
     907       28280 :   const MCAsmInfo *MAI = Context.getAsmInfo();
     908       28280 :   if (!MAI->doesSetDirectiveSuppressReloc()) {
     909       25171 :     EmitValue(Diff, Size);
     910       25171 :     return;
     911             :   }
     912             : 
     913             :   // Otherwise, emit with .set (aka assignment).
     914        3109 :   MCSymbol *SetLabel = Context.createTempSymbol("set", true);
     915        3109 :   EmitAssignment(SetLabel, Diff);
     916        3109 :   EmitSymbolValue(SetLabel, Size);
     917             : }
     918             : 
     919       61058 : void MCStreamer::emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi,
     920             :                                                  const MCSymbol *Lo) {
     921             :   // Get the Hi-Lo expression.
     922             :   const MCExpr *Diff =
     923      122116 :       MCBinaryExpr::createSub(MCSymbolRefExpr::create(Hi, Context),
     924             :                               MCSymbolRefExpr::create(Lo, Context), Context);
     925             : 
     926       61058 :   EmitULEB128Value(Diff);
     927       61058 : }
     928             : 
     929           4 : void MCStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {}
     930           0 : void MCStreamer::EmitThumbFunc(MCSymbol *Func) {}
     931           0 : void MCStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
     932           0 : void MCStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) {
     933           0 :   llvm_unreachable("this directive only supported on COFF targets");
     934             : }
     935           0 : void MCStreamer::EndCOFFSymbolDef() {
     936           0 :   llvm_unreachable("this directive only supported on COFF targets");
     937             : }
     938           9 : void MCStreamer::EmitFileDirective(StringRef Filename) {}
     939           0 : void MCStreamer::EmitCOFFSymbolStorageClass(int StorageClass) {
     940           0 :   llvm_unreachable("this directive only supported on COFF targets");
     941             : }
     942           0 : void MCStreamer::EmitCOFFSymbolType(int Type) {
     943           0 :   llvm_unreachable("this directive only supported on COFF targets");
     944             : }
     945          42 : void MCStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) {}
     946           0 : void MCStreamer::emitELFSymverDirective(StringRef AliasName,
     947           0 :                                         const MCSymbol *Aliasee) {}
     948           0 : void MCStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
     949           0 :                                        unsigned ByteAlignment) {}
     950           0 : void MCStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
     951           0 :                                 uint64_t Size, unsigned ByteAlignment) {}
     952         464 : void MCStreamer::ChangeSection(MCSection *, const MCExpr *) {}
     953           0 : void MCStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {}
     954         506 : void MCStreamer::EmitBytes(StringRef Data) {}
     955         922 : void MCStreamer::EmitBinaryData(StringRef Data) { EmitBytes(Data); }
     956     1723347 : void MCStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) {
     957     1723347 :   visitUsedExpr(*Value);
     958     1723347 : }
     959           0 : void MCStreamer::EmitULEB128Value(const MCExpr *Value) {}
     960           0 : void MCStreamer::EmitSLEB128Value(const MCExpr *Value) {}
     961           7 : void MCStreamer::emitFill(const MCExpr &NumBytes, uint64_t Value, SMLoc Loc) {}
     962           0 : void MCStreamer::emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
     963           0 :                           SMLoc Loc) {}
     964           4 : void MCStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
     965             :                                       unsigned ValueSize,
     966           4 :                                       unsigned MaxBytesToEmit) {}
     967          27 : void MCStreamer::EmitCodeAlignment(unsigned ByteAlignment,
     968          27 :                                    unsigned MaxBytesToEmit) {}
     969           0 : void MCStreamer::emitValueToOffset(const MCExpr *Offset, unsigned char Value,
     970           0 :                                    SMLoc Loc) {}
     971           0 : void MCStreamer::EmitBundleAlignMode(unsigned AlignPow2) {}
     972           0 : void MCStreamer::EmitBundleLock(bool AlignToEnd) {}
     973         408 : void MCStreamer::FinishImpl() {}
     974           0 : void MCStreamer::EmitBundleUnlock() {}
     975             : 
     976      901189 : void MCStreamer::SwitchSection(MCSection *Section, const MCExpr *Subsection) {
     977             :   assert(Section && "Cannot switch to a null section!");
     978      901189 :   MCSectionSubPair curSection = SectionStack.back().first;
     979             :   SectionStack.back().second = curSection;
     980             :   if (MCSectionSubPair(Section, Subsection) != curSection) {
     981      695520 :     ChangeSection(Section, Subsection);
     982      695518 :     SectionStack.back().first = MCSectionSubPair(Section, Subsection);
     983             :     assert(!Section->hasEnded() && "Section already ended");
     984      695518 :     MCSymbol *Sym = Section->getBeginSymbol();
     985      695518 :     if (Sym && !Sym->isInSection())
     986        3613 :       EmitLabel(Sym);
     987             :   }
     988      901187 : }
     989             : 
     990       38805 : MCSymbol *MCStreamer::endSection(MCSection *Section) {
     991             :   // TODO: keep track of the last subsection so that this symbol appears in the
     992             :   // correct place.
     993       38805 :   MCSymbol *Sym = Section->getEndSymbol(Context);
     994       38805 :   if (Sym->isInSection())
     995             :     return Sym;
     996             : 
     997       38780 :   SwitchSection(Section);
     998       38780 :   EmitLabel(Sym);
     999       38780 :   return Sym;
    1000             : }
    1001             : 
    1002       23270 : void MCStreamer::EmitVersionForTarget(const Triple &Target) {
    1003       23270 :   if (!Target.isOSBinFormatMachO() || !Target.isOSDarwin())
    1004       22137 :     return;
    1005             :   // Do we even know the version?
    1006        2916 :   if (Target.getOSMajorVersion() == 0)
    1007             :     return;
    1008             : 
    1009             :   unsigned Major;
    1010             :   unsigned Minor;
    1011             :   unsigned Update;
    1012             :   MCVersionMinType VersionType;
    1013        1133 :   if (Target.isWatchOS()) {
    1014             :     VersionType = MCVM_WatchOSVersionMin;
    1015          15 :     Target.getWatchOSVersion(Major, Minor, Update);
    1016        1118 :   } else if (Target.isTvOS()) {
    1017             :     VersionType = MCVM_TvOSVersionMin;
    1018           6 :     Target.getiOSVersion(Major, Minor, Update);
    1019             :   } else if (Target.isMacOSX()) {
    1020             :     VersionType = MCVM_OSXVersionMin;
    1021         921 :     if (!Target.getMacOSXVersion(Major, Minor, Update))
    1022           2 :       Major = 0;
    1023             :   } else {
    1024             :     VersionType = MCVM_IOSVersionMin;
    1025         191 :     Target.getiOSVersion(Major, Minor, Update);
    1026             :   }
    1027        1133 :   if (Major != 0)
    1028        1131 :     EmitVersionMin(VersionType, Major, Minor, Update);
    1029             : }

Generated by: LCOV version 1.13