LLVM 24.0.0git
MCStreamer.cpp
Go to the documentation of this file.
1//===- lib/MC/MCStreamer.cpp - Streaming Machine Code Output --------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11#include "llvm/ADT/StringRef.h"
12#include "llvm/ADT/Twine.h"
16#include "llvm/MC/MCAsmInfo.h"
17#include "llvm/MC/MCCodeView.h"
18#include "llvm/MC/MCContext.h"
19#include "llvm/MC/MCDwarf.h"
20#include "llvm/MC/MCExpr.h"
21#include "llvm/MC/MCInst.h"
26#include "llvm/MC/MCRegister.h"
28#include "llvm/MC/MCSection.h"
30#include "llvm/MC/MCSymbol.h"
31#include "llvm/MC/MCWin64EH.h"
32#include "llvm/MC/MCWinEH.h"
35#include "llvm/Support/LEB128.h"
38#include <cassert>
39#include <cstdint>
40#include <cstdlib>
41#include <optional>
42#include <utility>
43
44using namespace llvm;
45
49
50// Pin the vtables to this file.
52
54
56
58
60 uint32_t Subsection, raw_ostream &OS) {
61 auto &MAI = Streamer.getContext().getAsmInfo();
62 MAI.printSwitchToSection(*Sec, Subsection,
63 Streamer.getContext().getTargetTriple(), OS);
64}
65
69
72 raw_svector_ostream OS(Str);
73
74 Streamer.getContext().getAsmInfo().printExpr(OS, *Value);
75 Streamer.emitRawText(OS.str());
76}
77
79 const MCAsmInfo &MAI = Streamer.getContext().getAsmInfo();
80 const char *Directive = MAI.getData8bitsDirective();
81 for (const unsigned char C : Data.bytes()) {
83 raw_svector_ostream OS(Str);
84
85 OS << Directive << (unsigned)C;
86 Streamer.emitRawText(OS.str());
87 }
88}
89
91
93 : Context(Ctx), CurrentWinFrameInfo(nullptr),
94 CurrentProcWinFrameInfoStartIndex(0) {
95 SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
96}
97
98MCStreamer::~MCStreamer() = default;
99
100void MCStreamer::setLFIRewriter(std::unique_ptr<MCLFIRewriter> Rewriter) {
101 LFIRewriter = std::move(Rewriter);
102}
103
105 DwarfFrameInfos.clear();
106 CurrentWinFrameInfo = nullptr;
107 WinFrameInfos.clear();
108 SectionStack.clear();
109 SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
110 CurFrag = nullptr;
111}
112
114 // By default, discard comments.
115 return nulls();
116}
117
122
123void MCStreamer::emitRawComment(const Twine &T, bool TabPrefix) {}
124
127
128/// EmitIntValue - Special case of EmitValue that avoids the client having to
129/// pass in a MCExpr for constant integers.
130void MCStreamer::emitIntValue(uint64_t Value, unsigned Size) {
131 assert(1 <= Size && Size <= 8 && "Invalid size");
132 assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
133 "Invalid size");
134 const bool IsLittleEndian = Context.getAsmInfo().isLittleEndian();
135 uint64_t Swapped = support::endian::byte_swap(
137 unsigned Index = IsLittleEndian ? 0 : 8 - Size;
138 emitBytes(StringRef(reinterpret_cast<char *>(&Swapped) + Index, Size));
139}
141 if (Value.getNumWords() == 1) {
142 emitIntValue(Value.getLimitedValue(), Value.getBitWidth() / 8);
143 return;
144 }
145
146 const bool IsLittleEndianTarget = Context.getAsmInfo().isLittleEndian();
147 const bool ShouldSwap = sys::IsLittleEndianHost != IsLittleEndianTarget;
148 const APInt Swapped = ShouldSwap ? Value.byteSwap() : Value;
149 const unsigned Size = Value.getBitWidth() / 8;
150 SmallString<10> Tmp;
151 Tmp.resize(Size);
152 StoreIntToMemory(Swapped, reinterpret_cast<uint8_t *>(Tmp.data()), Size);
153 emitBytes(Tmp.str());
154}
155
156/// EmitULEB128IntValue - Special case of EmitULEB128Value that avoids the
157/// client having to pass in a MCExpr for constant integers.
158unsigned MCStreamer::emitULEB128IntValue(uint64_t Value, unsigned PadTo) {
160 raw_svector_ostream OSE(Tmp);
161 encodeULEB128(Value, OSE, PadTo);
162 emitBytes(OSE.str());
163 return Tmp.size();
164}
165
166/// EmitSLEB128IntValue - Special case of EmitSLEB128Value that avoids the
167/// client having to pass in a MCExpr for constant integers.
170 raw_svector_ostream OSE(Tmp);
171 encodeSLEB128(Value, OSE);
172 emitBytes(OSE.str());
173 return Tmp.size();
174}
175
178}
179
183
185 unsigned Size) {
186 const MCAsmInfo &MAI = getContext().getAsmInfo();
189 if (Size > 4)
190 emitZeros(Size - 4);
191 return;
192 }
193
195}
196
197/// Emit NumBytes bytes worth of the value specified by FillValue.
198/// This implements directives such as '.space'.
199void MCStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
200 if (NumBytes)
201 emitFill(*MCConstantExpr::create(NumBytes, getContext()), FillValue);
202}
203
204void llvm::MCStreamer::emitNops(int64_t NumBytes, int64_t ControlledNopLen,
205 llvm::SMLoc, const MCSubtargetInfo& STI) {}
206
207/// The implementation in this class just redirects to emitFill.
208void MCStreamer::emitZeros(uint64_t NumBytes) { emitFill(NumBytes, 0); }
209
211 unsigned FileNo, StringRef Directory, StringRef Filename,
212 std::optional<MD5::MD5Result> Checksum, std::optional<StringRef> Source,
213 unsigned CUID) {
214 return getContext().getDwarfFile(Directory, Filename, FileNo, Checksum,
215 Source, CUID);
216}
217
220 std::optional<MD5::MD5Result> Checksum,
221 std::optional<StringRef> Source,
222 unsigned CUID) {
223 getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
224 Source);
225}
226
228 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
229 if (!CurFrame)
230 return;
231 CurFrame->IsBKeyFrame = true;
232}
233
235 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
236 if (!CurFrame)
237 return;
238 CurFrame->IsMTETaggedFrame = true;
239}
240
242 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
243 if (!CurFrame)
244 return;
245 CurFrame->IsNonHintPAuthFrame = true;
246}
247
248void MCStreamer::emitDwarfLocDirective(unsigned FileNo, unsigned Line,
249 unsigned Column, unsigned Flags,
250 unsigned Isa, unsigned Discriminator,
251 StringRef FileName, StringRef Comment) {
252 getContext().setCurrentDwarfLoc(FileNo, Line, Column, Flags, Isa,
253 Discriminator);
254}
255
261
264 if (!Table.getLabel()) {
265 StringRef Prefix = Context.getAsmInfo().getInternalSymbolPrefix();
266 Table.setLabel(
267 Context.getOrCreateSymbol(Prefix + "line_table_start" + Twine(CUID)));
268 }
269 return Table.getLabel();
270}
271
273 return !FrameInfoStack.empty();
274}
275
276MCDwarfFrameInfo *MCStreamer::getCurrentDwarfFrameInfo() {
279 "this directive must appear between "
280 ".cfi_startproc and .cfi_endproc directives");
281 return nullptr;
282 }
283 return &DwarfFrameInfos[FrameInfoStack.back().first];
284}
285
287 ArrayRef<uint8_t> Checksum,
288 unsigned ChecksumKind) {
289 return getContext().getCVContext().addFile(*this, FileNo, Filename, Checksum,
290 ChecksumKind);
291}
292
296
298 unsigned IAFunc, unsigned IAFile,
299 unsigned IALine, unsigned IACol,
300 SMLoc Loc) {
301 if (getContext().getCVContext().getCVFunctionInfo(IAFunc) == nullptr) {
302 getContext().reportError(Loc, "parent function id not introduced by "
303 ".cv_func_id or .cv_inline_site_id");
304 return true;
305 }
306
308 FunctionId, IAFunc, IAFile, IALine, IACol);
309}
310
311void MCStreamer::emitCVLocDirective(unsigned FunctionId, unsigned FileNo,
312 unsigned Line, unsigned Column,
313 bool PrologueEnd, bool IsStmt,
314 StringRef FileName, SMLoc Loc) {}
315
318 MCCVFunctionInfo *FI = CVC.getCVFunctionInfo(FuncId);
319 if (!FI) {
321 Loc, "function id not introduced by .cv_func_id or .cv_inline_site_id");
322 return false;
323 }
324
325 // Track the section
326 if (FI->Section == nullptr)
328 else if (FI->Section != getCurrentSectionOnly()) {
330 Loc,
331 "all .cv_loc directives for a function must be in the same section");
332 return false;
333 }
334 return true;
335}
336
338 const MCSymbol *Begin,
339 const MCSymbol *End) {}
340
341void MCStreamer::emitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
342 unsigned SourceFileId,
343 unsigned SourceLineNum,
344 const MCSymbol *FnStartSym,
345 const MCSymbol *FnEndSym) {}
346
347/// Only call this on endian-specific types like ulittle16_t and little32_t, or
348/// structs composed of them.
349template <typename T>
350static void copyBytesForDefRange(SmallString<20> &BytePrefix,
351 codeview::SymbolKind SymKind,
352 const T &DefRangeHeader) {
353 BytePrefix.resize(2 + sizeof(T));
354 codeview::ulittle16_t SymKindLE = codeview::ulittle16_t(SymKind);
355 memcpy(&BytePrefix[0], &SymKindLE, 2);
356 memcpy(&BytePrefix[2], &DefRangeHeader, sizeof(T));
357}
358
360 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
361 StringRef FixedSizePortion) {}
362
364 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
366 SmallString<20> BytePrefix;
367 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_REGISTER_REL, DRHdr);
368 emitCVDefRangeDirective(Ranges, BytePrefix);
369}
370
372 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
374 SmallString<20> BytePrefix;
375 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_SUBFIELD_REGISTER,
376 DRHdr);
377 emitCVDefRangeDirective(Ranges, BytePrefix);
378}
379
381 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
383 SmallString<20> BytePrefix;
384 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_REGISTER, DRHdr);
385 emitCVDefRangeDirective(Ranges, BytePrefix);
386}
387
389 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
391 SmallString<20> BytePrefix;
392 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_FRAMEPOINTER_REL,
393 DRHdr);
394 emitCVDefRangeDirective(Ranges, BytePrefix);
395}
396
398 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
400 SmallString<20> BytePrefix;
401 copyBytesForDefRange(BytePrefix, codeview::S_DEFRANGE_REGISTER_REL_INDIR,
402 DRHdr);
403 emitCVDefRangeDirective(Ranges, BytePrefix);
404}
405
407 MCSymbol *EHSymbol) {
408}
409
411 switchSectionNoPrint(getContext().getObjectFileInfo()->getTextSection());
412}
413
415 Symbol->redefineIfPossible();
416
417 if (!Symbol->isUndefined() || Symbol->isVariable())
418 return getContext().reportError(Loc, "symbol '" + Twine(Symbol->getName()) +
419 "' is already defined");
420
421 assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
422 assert(getCurrentSectionOnly() && "Cannot emit before setting section!");
423 assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
424 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
425
426 Symbol->setFragment(&getCurrentSectionOnly()->getDummyFragment());
427
428 if (LFIRewriter)
429 LFIRewriter->onLabel(Symbol, *this);
430
432 if (TS)
433 TS->emitLabel(Symbol);
434}
435
438
439void MCStreamer::emitCFISections(bool EH, bool Debug, bool SFrame) {}
440
442 if (!FrameInfoStack.empty() &&
443 getCurrentSectionOnly() == FrameInfoStack.back().second)
444 return getContext().reportError(
445 Loc, "starting new .cfi frame before finishing the previous one");
446
447 MCDwarfFrameInfo Frame;
448 Frame.IsSimple = IsSimple;
450
451 const MCAsmInfo &MAI = Context.getAsmInfo();
452 for (const MCCFIInstruction &Inst : MAI.getInitialFrameState()) {
453 if (Inst.getOperation() == MCCFIInstruction::OpDefCfa ||
454 Inst.getOperation() == MCCFIInstruction::OpDefCfaRegister ||
455 Inst.getOperation() == MCCFIInstruction::OpLLVMDefAspaceCfa) {
456 Frame.CurrentCfaRegister = Inst.getRegister();
457 }
458 }
459
460 FrameInfoStack.emplace_back(DwarfFrameInfos.size(), getCurrentSectionOnly());
461 DwarfFrameInfos.push_back(std::move(Frame));
462}
463
466
468 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
469 if (!CurFrame)
470 return;
471 emitCFIEndProcImpl(*CurFrame);
472 FrameInfoStack.pop_back();
473}
474
476 // Put a dummy non-null value in Frame.End to mark that this frame has been
477 // closed.
478 Frame.End = (MCSymbol *)1;
479}
480
482 // Create a label and insert it into the line table and return this label
483 const MCDwarfLoc &DwarfLoc = getContext().getCurrentDwarfLoc();
484
485 MCSymbol *LineStreamLabel = getContext().createTempSymbol();
486 MCDwarfLineEntry LabelLineEntry(nullptr, DwarfLoc, LineStreamLabel);
487 LabelLineEntry.Subsection = getCurrentSection().second;
488 getContext()
489 .getMCDwarfLineTable(getContext().getDwarfCompileUnitID())
491 .addLineEntry(LabelLineEntry, getCurrentSectionOnly() /*Section*/);
492
493 return LineStreamLabel;
494}
495
497 // Return a dummy non-null value so that label fields appear filled in when
498 // generating textual assembly.
499 return (MCSymbol *)1;
500}
501
503 MCSymbol *Label = emitCFILabel();
506 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
507 if (!CurFrame)
508 return;
509 CurFrame->Instructions.push_back(std::move(Instruction));
510 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
511}
512
514 MCSymbol *Label = emitCFILabel();
517 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
518 if (!CurFrame)
519 return;
520 CurFrame->Instructions.push_back(std::move(Instruction));
521}
522
524 MCSymbol *Label = emitCFILabel();
527 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
528 if (!CurFrame)
529 return;
530 CurFrame->Instructions.push_back(std::move(Instruction));
531}
532
534 MCSymbol *Label = emitCFILabel();
537 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
538 if (!CurFrame)
539 return;
540 CurFrame->Instructions.push_back(std::move(Instruction));
541 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
542}
543
545 int64_t AddressSpace, SMLoc Loc) {
546 MCSymbol *Label = emitCFILabel();
548 Label, Register, Offset, AddressSpace, Loc);
549 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
550 if (!CurFrame)
551 return;
552 CurFrame->Instructions.push_back(std::move(Instruction));
553 CurFrame->CurrentCfaRegister = static_cast<unsigned>(Register);
554}
555
557 MCSymbol *Label = emitCFILabel();
560 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
561 if (!CurFrame)
562 return;
563 CurFrame->Instructions.push_back(std::move(Instruction));
564}
565
567 MCSymbol *Label = emitCFILabel();
570 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
571 if (!CurFrame)
572 return;
573 CurFrame->Instructions.push_back(std::move(Instruction));
574}
575
577 unsigned Encoding) {
578 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
579 if (!CurFrame)
580 return;
581 CurFrame->Personality = Sym;
582 CurFrame->PersonalityEncoding = Encoding;
583}
584
585void MCStreamer::emitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
586 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
587 if (!CurFrame)
588 return;
589 CurFrame->Lsda = Sym;
590 CurFrame->LsdaEncoding = Encoding;
591}
592
594 MCSymbol *Label = emitCFILabel();
597 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
598 if (!CurFrame)
599 return;
600 ++CurFrame->RememberStateDepth;
601 CurFrame->Instructions.push_back(std::move(Instruction));
602}
603
605 MCSymbol *Label = emitCFILabel();
608 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
609 if (!CurFrame)
610 return;
611 if (!CurFrame->RememberStateDepth) {
612 getContext().reportError(Loc, "no matching .cfi_remember_state");
613 return;
614 }
615 --CurFrame->RememberStateDepth;
616 CurFrame->Instructions.push_back(std::move(Instruction));
617}
618
620 MCSymbol *Label = emitCFILabel();
623 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
624 if (!CurFrame)
625 return;
626 CurFrame->Instructions.push_back(std::move(Instruction));
627}
628
630 MCSymbol *Label = emitCFILabel();
633 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
634 if (!CurFrame)
635 return;
636 CurFrame->Instructions.push_back(std::move(Instruction));
637}
638
640 MCSymbol *Label = emitCFILabel();
643 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
644 if (!CurFrame)
645 return;
646 CurFrame->Instructions.push_back(std::move(Instruction));
647}
648
650 MCSymbol *Label = emitCFILabel();
653 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
654 if (!CurFrame)
655 return;
656 CurFrame->Instructions.push_back(std::move(Instruction));
657}
658
660 int64_t R1Size, int64_t R2,
661 int64_t R2Size, SMLoc Loc) {
662 MCSymbol *Label = emitCFILabel();
664 Label, Register, R1, R1Size, R2, R2Size, Loc);
665 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
666 if (!CurFrame)
667 return;
668 CurFrame->Instructions.push_back(std::move(Instruction));
669}
670
673 SMLoc Loc) {
674 MCSymbol *Label = emitCFILabel();
677 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
678 if (!CurFrame)
679 return;
680 CurFrame->Instructions.push_back(std::move(Instruction));
681}
682
684 int64_t RegisterSizeInBits,
685 int64_t MaskRegister,
686 int64_t MaskRegisterSizeInBits,
687 int64_t Offset, SMLoc Loc) {
688 MCSymbol *Label = emitCFILabel();
690 Label, Register, RegisterSizeInBits, MaskRegister, MaskRegisterSizeInBits,
691 Offset, Loc);
692 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
693 if (!CurFrame)
694 return;
695 CurFrame->Instructions.push_back(std::move(Instruction));
696}
697
699 int64_t Register, int64_t SpillRegister,
700 int64_t SpillRegisterLaneSizeInBits, int64_t MaskRegister,
701 int64_t MaskRegisterSizeInBits, SMLoc Loc) {
702
703 MCSymbol *Label = emitCFILabel();
705 Label, Register, SpillRegister, SpillRegisterLaneSizeInBits, MaskRegister,
706 MaskRegisterSizeInBits, Loc);
707 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
708 if (!CurFrame)
709 return;
710 CurFrame->Instructions.push_back(std::move(Instruction));
711}
712
714 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
715 if (!CurFrame)
716 return;
717 CurFrame->IsSignalFrame = true;
718}
719
721 MCSymbol *Label = emitCFILabel();
724 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
725 if (!CurFrame)
726 return;
727 CurFrame->Instructions.push_back(std::move(Instruction));
728}
729
730void MCStreamer::emitCFIRegister(int64_t Register1, int64_t Register2,
731 SMLoc Loc) {
732 MCSymbol *Label = emitCFILabel();
734 MCCFIInstruction::createRegister(Label, Register1, Register2, Loc);
735 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
736 if (!CurFrame)
737 return;
738 CurFrame->Instructions.push_back(std::move(Instruction));
739}
740
742 MCSymbol *Label = emitCFILabel();
744 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
745 if (!CurFrame)
746 return;
747 CurFrame->Instructions.push_back(std::move(Instruction));
748}
749
751 MCSymbol *Label = emitCFILabel();
754 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
755 if (!CurFrame)
756 return;
757 CurFrame->Instructions.push_back(std::move(Instruction));
758}
759
761 MCSymbol *Label = emitCFILabel();
764 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
765 if (!CurFrame)
766 return;
767 CurFrame->Instructions.push_back(std::move(Instruction));
768}
769
770void MCStreamer::emitCFILLVMSetRAState(unsigned State, MCSymbol *PACSym,
771 SMLoc Loc) {
772 MCSymbol *Label = emitCFILabel();
774 MCCFIInstruction::createSetRAState(Label, State, PACSym, Loc);
775 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
776 if (!CurFrame)
777 return;
778 CurFrame->Instructions.push_back(std::move(Instruction));
779}
780
781void MCStreamer::emitCFILLVMSetRAState(unsigned State, int64_t Offset,
782 SMLoc Loc) {
783 MCSymbol *Label = emitCFILabel();
786 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
787 if (!CurFrame)
788 return;
789 CurFrame->Instructions.push_back(std::move(Instruction));
790}
791
793 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
794 if (!CurFrame)
795 return;
796 CurFrame->RAReg = Register;
797}
798
800 MCSymbol *Label = emitCFILabel();
802 if (MCDwarfFrameInfo *F = getCurrentDwarfFrameInfo())
803 F->Instructions.push_back(MCCFIInstruction::createLabel(Label, Sym, Loc));
804}
805
807 MCSymbol *Label = emitCFILabel();
810 MCDwarfFrameInfo *CurFrame = getCurrentDwarfFrameInfo();
811 if (!CurFrame)
812 return;
813 CurFrame->Instructions.push_back(std::move(Instruction));
814}
815
817 const MCAsmInfo &MAI = Context.getAsmInfo();
818 if (!MAI.usesWindowsCFI()) {
820 Loc, ".seh_* directives are not supported on this target");
821 return nullptr;
822 }
823 if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End) {
825 Loc, ".seh_ directive must appear within an active frame");
826 return nullptr;
827 }
828 return CurrentWinFrameInfo;
829}
830
832 const MCAsmInfo &MAI = Context.getAsmInfo();
833 if (!MAI.usesWindowsCFI())
834 return getContext().reportError(
835 Loc, ".seh_* directives are not supported on this target");
836 if (CurrentWinFrameInfo && !CurrentWinFrameInfo->End)
838 Loc, "Starting a function before ending the previous one!");
839
840 MCSymbol *StartProc = emitCFILabel();
841
842 CurrentProcWinFrameInfoStartIndex = WinFrameInfos.size();
843 WinFrameInfos.emplace_back(
844 std::make_unique<WinEH::FrameInfo>(Symbol, StartProc));
845 CurrentWinFrameInfo = WinFrameInfos.back().get();
846 CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
847 CurrentWinFrameInfo->FunctionLoc = Loc;
848 // Inherit the module-wide default unwind version.
849 CurrentWinFrameInfo->Version = DefaultWinCFIUnwindVersion;
850}
851
854 if (!CurFrame)
855 return;
856 CurrentWinFrameInfo = nullptr;
857
858 MCSymbol *Label = emitCFILabel();
859 CurFrame->End = Label;
860 const MCSymbol **FuncletOrFuncEndPtr =
861 CurFrame->ChainedParent ? &CurFrame->ChainedParent->FuncletOrFuncEnd
862 : &CurFrame->FuncletOrFuncEnd;
863 if (!*FuncletOrFuncEndPtr)
864 *FuncletOrFuncEndPtr = CurFrame->End;
865
866 if (CurrentWinEpilog) {
867 // Set End to... something... to prevent crashes later.
869 CurrentWinEpilog = nullptr;
870 getContext().reportError(Loc, "Missing .seh_endepilogue in " +
871 CurFrame->Function->getName());
872 }
873
874 for (size_t I = CurrentProcWinFrameInfoStartIndex, E = WinFrameInfos.size();
875 I != E; ++I)
876 emitWindowsUnwindTables(WinFrameInfos[I].get());
877 switchSection(CurFrame->TextSection);
878}
879
882 if (!CurFrame)
883 return;
884
885 MCSymbol *Label = emitCFILabel();
886 const MCSymbol **FuncletOrFuncEndPtr =
887 CurFrame->ChainedParent ? &CurFrame->ChainedParent->FuncletOrFuncEnd
888 : &CurFrame->FuncletOrFuncEnd;
889 *FuncletOrFuncEndPtr = Label;
890}
891
894 if (!CurFrame)
895 return;
896
897 if (!CurFrame->PrologEnd)
898 return getContext().reportError(
899 Loc, "can't split into a new chained region (.seh_splitchained) in the "
900 "middle of a prolog in " +
901 CurFrame->Function->getName());
902
903 MCSymbol *Label = emitCFILabel();
904
905 // Complete the current frame before starting a new, chained one.
906 CurFrame->End = Label;
907
908 // All chained frames point to the same parent.
909 WinEH::FrameInfo *ChainedParent =
910 CurFrame->ChainedParent ? CurFrame->ChainedParent : CurFrame;
911
912 WinFrameInfos.emplace_back(std::make_unique<WinEH::FrameInfo>(
913 CurFrame->Function, Label, ChainedParent));
914 CurrentWinFrameInfo = WinFrameInfos.back().get();
915 CurrentWinFrameInfo->TextSection = getCurrentSectionOnly();
916}
917
918void MCStreamer::emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except,
919 SMLoc Loc) {
921 if (!CurFrame)
922 return;
923
924 // Handlers are always associated with the parent frame.
925 CurFrame = CurFrame->ChainedParent ? CurFrame->ChainedParent : CurFrame;
926
927 CurFrame->ExceptionHandler = Sym;
928 if (!Except && !Unwind)
929 getContext().reportError(Loc, "Don't know what kind of handler this is!");
930 if (Unwind)
931 CurFrame->HandlesUnwind = true;
932 if (Except)
933 CurFrame->HandlesExceptions = true;
934}
935
938 if (!CurFrame)
939 return;
940}
941
943 const MCSymbolRefExpr *To, uint64_t Count) {
944}
945
946static MCSection *getWinCFISection(MCContext &Context, unsigned *NextWinCFIID,
947 MCSection *MainCFISec,
948 const MCSection *TextSec) {
949 // If this is the main .text section, use the main unwind info section.
950 if (TextSec == Context.getObjectFileInfo()->getTextSection())
951 return MainCFISec;
952
953 const auto *TextSecCOFF = static_cast<const MCSectionCOFF *>(TextSec);
954 auto *MainCFISecCOFF = static_cast<MCSectionCOFF *>(MainCFISec);
955 unsigned UniqueID = TextSecCOFF->getOrAssignWinCFISectionID(NextWinCFIID);
956
957 // If this section is COMDAT, this unwind section should be COMDAT associative
958 // with its group.
959 const MCSymbol *KeySym = nullptr;
960 if (TextSecCOFF->getCharacteristics() & COFF::IMAGE_SCN_LNK_COMDAT) {
961 KeySym = TextSecCOFF->getCOMDATSymbol();
962
963 // In a GNU environment, we can't use associative comdats. Instead, do what
964 // GCC does, which is to make plain comdat selectany section named like
965 // ".[px]data$_Z3foov".
966 if (!Context.getAsmInfo().hasCOFFAssociativeComdats()) {
967 std::string SectionName = (MainCFISecCOFF->getName() + "$" +
968 TextSecCOFF->getName().split('$').second)
969 .str();
970 return Context.getCOFFSection(SectionName,
971 MainCFISecCOFF->getCharacteristics() |
974 }
975 }
976
977 return Context.getAssociativeCOFFSection(MainCFISecCOFF, KeySym, UniqueID);
978}
979
981 return getWinCFISection(getContext(), &NextWinCFIID,
982 getContext().getObjectFileInfo()->getPDataSection(),
983 TextSec);
984}
985
987 return getWinCFISection(getContext(), &NextWinCFIID,
988 getContext().getObjectFileInfo()->getXDataSection(),
989 TextSec);
990}
991
993
994static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg) {
995 return Ctx.getRegisterInfo()->getSEHRegNum(Reg);
996}
997
998// Unwind formats before v3 store the register operand of an unwind code in a
999// 4-bit field, so extended registers (r16-r31 / xmm16-xmm31, i.e. SEH register
1000// numbers greater than 15) cannot be represented. Report an error rather than
1001// silently truncating the register number to a different register. Returns true
1002// if an error was reported.
1004 const WinEH::Instruction &Inst,
1005 uint8_t Version, SMLoc Loc,
1008 Ctx.reportError(Loc, Directive +
1009 " with an extended register requires unwind v3");
1010 return true;
1011 }
1012 return false;
1013}
1014
1017 if (!CurFrame)
1018 return;
1019
1020 MCSymbol *Label = emitCFILabel();
1021
1023 Label, encodeSEHRegNum(Context, Register));
1024 if (CurrentWinEpilog) {
1025 if (CurFrame->Version < 3)
1026 return getContext().reportError(
1027 Loc, ".seh_pushreg inside epilog requires unwind v3");
1028 CurrentWinEpilog->Instructions.push_back(Inst);
1029 } else {
1030 if (checkUnwindV3ExtendedReg(getContext(), Inst, CurFrame->Version, Loc,
1031 ".seh_pushreg"))
1032 return;
1033 CurFrame->Instructions.push_back(Inst);
1034 }
1035}
1036
1038 SMLoc Loc) {
1040 if (!CurFrame)
1041 return;
1042
1043 // UOP_Push2 is V3-only - reject for V1/V2.
1044 if (CurFrame->Version < 3)
1045 return getContext().reportError(
1046 Loc, ".seh_push2regs is only supported for unwind v3");
1047
1048 MCSymbol *Label = emitCFILabel();
1049
1051 Label, encodeSEHRegNum(Context, Reg1), encodeSEHRegNum(Context, Reg2));
1052 if (CurrentWinEpilog)
1053 CurrentWinEpilog->Instructions.push_back(Inst);
1054 else
1055 CurFrame->Instructions.push_back(Inst);
1056}
1057
1059 SMLoc Loc) {
1061 if (!CurFrame)
1062 return;
1063 if (!CurrentWinEpilog && CurFrame->LastFrameInst >= 0)
1064 return getContext().reportError(
1065 Loc, "frame register and offset can be set at most once");
1066 if (Offset & 0x0F)
1067 return getContext().reportError(Loc, "offset is not a multiple of 16");
1068 if (Offset > 240)
1069 return getContext().reportError(
1070 Loc, "frame offset must be less than or equal to 240");
1071
1072 MCSymbol *Label = emitCFILabel();
1073
1076 if (CurrentWinEpilog) {
1077 if (CurFrame->Version < 3)
1078 return getContext().reportError(
1079 Loc, ".seh_setframe inside epilog requires unwind v3");
1080 CurrentWinEpilog->Instructions.push_back(Inst);
1081 } else {
1082 if (checkUnwindV3ExtendedReg(getContext(), Inst, CurFrame->Version, Loc,
1083 ".seh_setframe"))
1084 return;
1085 CurFrame->LastFrameInst = CurFrame->Instructions.size();
1086 CurFrame->Instructions.push_back(Inst);
1087 }
1088}
1089
1092 if (!CurFrame)
1093 return;
1094 if (Size == 0)
1095 return getContext().reportError(Loc,
1096 "stack allocation size must be non-zero");
1097 if (Size & 7)
1098 return getContext().reportError(
1099 Loc, "stack allocation size is not a multiple of 8");
1100
1101 MCSymbol *Label = emitCFILabel();
1102
1104 if (CurrentWinEpilog) {
1105 if (CurFrame->Version < 3)
1106 return getContext().reportError(
1107 Loc, ".seh_stackalloc inside epilog requires unwind v3");
1108 CurrentWinEpilog->Instructions.push_back(Inst);
1109 } else {
1110 CurFrame->Instructions.push_back(Inst);
1111 }
1112}
1113
1115 SMLoc Loc) {
1117 if (!CurFrame)
1118 return;
1119
1120 if (Offset & 7)
1121 return getContext().reportError(
1122 Loc, "register save offset is not 8 byte aligned");
1123
1124 MCSymbol *Label = emitCFILabel();
1125
1127 Label, encodeSEHRegNum(Context, Register), Offset);
1128 if (CurrentWinEpilog) {
1129 if (CurFrame->Version < 3)
1130 return getContext().reportError(
1131 Loc, ".seh_savereg inside epilog requires unwind v3");
1132 CurrentWinEpilog->Instructions.push_back(Inst);
1133 } else {
1134 if (checkUnwindV3ExtendedReg(getContext(), Inst, CurFrame->Version, Loc,
1135 ".seh_savereg"))
1136 return;
1137 CurFrame->Instructions.push_back(Inst);
1138 }
1139}
1140
1142 SMLoc Loc) {
1144 if (!CurFrame)
1145 return;
1146 if (Offset & 0x0F)
1147 return getContext().reportError(Loc, "offset is not a multiple of 16");
1148
1149 MCSymbol *Label = emitCFILabel();
1150
1152 Label, encodeSEHRegNum(Context, Register), Offset);
1153 if (CurrentWinEpilog) {
1154 if (CurFrame->Version < 3)
1155 return getContext().reportError(
1156 Loc, ".seh_savexmm inside epilog requires unwind v3");
1157 CurrentWinEpilog->Instructions.push_back(Inst);
1158 } else {
1159 if (checkUnwindV3ExtendedReg(getContext(), Inst, CurFrame->Version, Loc,
1160 ".seh_savexmm"))
1161 return;
1162 CurFrame->Instructions.push_back(Inst);
1163 }
1164}
1165
1168 if (!CurFrame)
1169 return;
1170 if (CurrentWinEpilog) {
1171 if (CurFrame->Version < 3)
1172 return getContext().reportError(
1173 Loc, ".seh_pushframe inside epilog requires unwind v3");
1174 MCSymbol *Label = emitCFILabel();
1176 CurrentWinEpilog->Instructions.push_back(Inst);
1177 return;
1178 }
1179 if (!CurFrame->Instructions.empty())
1180 return getContext().reportError(
1181 Loc, "If present, PushMachFrame must be the first UOP");
1182
1183 MCSymbol *Label = emitCFILabel();
1184
1186 CurFrame->Instructions.push_back(Inst);
1187}
1188
1191 if (!CurFrame)
1192 return;
1193
1194 MCSymbol *Label = emitCFILabel();
1195
1196 CurFrame->PrologEnd = Label;
1197}
1198
1201 if (!CurFrame)
1202 return;
1203
1204 MCSymbol *Label = emitCFILabel();
1205
1206 if (!CurFrame->PrologEnd) {
1207 CurFrame->PrologEnd = Label;
1209 Loc, "starting epilogue (.seh_startepilogue) before prologue has ended "
1210 "(.seh_endprologue) in " +
1211 CurFrame->Function->getName());
1212 }
1214 &CurFrame->EpilogMap.insert_or_assign(Label, WinEH::FrameInfo::Epilog())
1215 .first->second;
1216 CurrentWinEpilog->Start = Label;
1217 CurrentWinEpilog->Loc = Loc;
1218}
1219
1222 if (!CurFrame)
1223 return;
1224
1225 if (!CurrentWinEpilog)
1226 return getContext().reportError(Loc, "Stray .seh_endepilogue in " +
1227 CurFrame->Function->getName());
1228
1229 if ((CurFrame->Version == 2) && !CurrentWinEpilog->UnwindV2Start) {
1230 // Set UnwindV2Start to... something... to prevent crashes later.
1231 CurrentWinEpilog->UnwindV2Start = CurrentWinEpilog->Start;
1232 getContext().reportError(Loc, "Missing .seh_unwindv2start in " +
1233 CurFrame->Function->getName());
1234 }
1235
1237 CurrentWinEpilog = nullptr;
1238}
1239
1242 if (!CurFrame)
1243 return;
1244
1245 if (!CurrentWinEpilog)
1246 return getContext().reportError(Loc, "Stray .seh_unwindv2start in " +
1247 CurFrame->Function->getName());
1248
1249 if (CurrentWinEpilog->UnwindV2Start)
1250 return getContext().reportError(Loc, "Duplicate .seh_unwindv2start in " +
1251 CurFrame->Function->getName());
1252
1253 MCSymbol *Label = emitCFILabel();
1254 CurrentWinEpilog->UnwindV2Start = Label;
1255}
1256
1258 bool SupportedVersion = (Version >= 1 && Version <= 3);
1259
1260 // If called outside a proc, set the module-level default.
1261 if (!CurrentWinFrameInfo || CurrentWinFrameInfo->End) {
1262 if (!SupportedVersion)
1263 return getContext().reportError(
1264 Loc, "Unsupported version for .seh_unwindversion");
1266 return;
1267 }
1268
1269 // Per-function override (existing behaviour).
1270 WinEH::FrameInfo *CurFrame = CurrentWinFrameInfo;
1271
1272 if (CurFrame->Version != DefaultWinCFIUnwindVersion &&
1274 return getContext().reportError(Loc, "Duplicate .seh_unwindversion in " +
1275 CurFrame->Function->getName());
1276
1277 if (!SupportedVersion)
1278 return getContext().reportError(
1279 Loc, "Unsupported version specified in .seh_unwindversion in " +
1280 CurFrame->Function->getName());
1281
1282 CurFrame->Version = Version;
1283}
1284
1286
1288
1290
1291void MCStreamer::emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) {}
1292
1293void MCStreamer::emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) {}
1294
1296
1298
1299/// EmitRawText - If this file is backed by an assembly streamer, this dumps
1300/// the specified string in the output .s file. This capability is
1301/// indicated by the hasRawTextSupport() predicate.
1303 // This is not llvm_unreachable for the sake of out of tree backend
1304 // developers who may not have assembly streamers and should serve as a
1305 // reminder to not accidentally call EmitRawText in the absence of such.
1306 report_fatal_error("EmitRawText called on an MCStreamer that doesn't support "
1307 "it (target backend is likely missing an AsmStreamer "
1308 "implementation)");
1309}
1310
1312 SmallString<128> Str;
1313 emitRawTextImpl(T.toStringRef(Str));
1314}
1315
1317
1319
1322 (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
1323 getContext().reportError(EndLoc, "Unfinished frame!");
1324 return;
1325 }
1326
1327 if (LFIRewriter)
1328 LFIRewriter->finish(*this);
1329
1331 if (TS)
1332 TS->finish();
1333
1334 finishImpl();
1335}
1336
1338 if (Context.getDwarfFormat() != dwarf::DWARF64)
1339 return;
1340 AddComment("DWARF64 Mark");
1342}
1343
1344void MCStreamer::emitDwarfUnitLength(uint64_t Length, const Twine &Comment) {
1345 assert(Context.getDwarfFormat() == dwarf::DWARF64 ||
1348 AddComment(Comment);
1349 emitIntValue(Length, dwarf::getDwarfOffsetByteSize(Context.getDwarfFormat()));
1350}
1351
1353 const Twine &Comment) {
1355 AddComment(Comment);
1356 MCSymbol *Lo = Context.createTempSymbol(Prefix + "_start");
1357 MCSymbol *Hi = Context.createTempSymbol(Prefix + "_end");
1358
1360 Hi, Lo, dwarf::getDwarfOffsetByteSize(Context.getDwarfFormat()));
1361 // emit the begin symbol after we generate the length field.
1362 emitLabel(Lo);
1363 // Return the Hi symbol to the caller.
1364 return Hi;
1365}
1366
1368 // Set the value of the symbol, as we are at the start of the line table.
1369 emitLabel(StartSym);
1370}
1371
1374 Symbol->setVariableValue(Value);
1375
1377 if (TS)
1378 TS->emitAssignment(Symbol, Value);
1379}
1380
1382 uint64_t Address, const MCInst &Inst,
1383 const MCSubtargetInfo &STI,
1384 raw_ostream &OS) {
1385 InstPrinter.printInst(&Inst, Address, "", STI, OS);
1386}
1387
1389}
1390
1392 switch (Expr.getKind()) {
1393 case MCExpr::Target:
1394 cast<MCTargetExpr>(Expr).visitUsedExpr(*this);
1395 break;
1396
1397 case MCExpr::Constant:
1398 break;
1399
1400 case MCExpr::Binary: {
1401 const MCBinaryExpr &BE = cast<MCBinaryExpr>(Expr);
1402 visitUsedExpr(*BE.getLHS());
1403 visitUsedExpr(*BE.getRHS());
1404 break;
1405 }
1406
1407 case MCExpr::SymbolRef:
1408 visitUsedSymbol(cast<MCSymbolRefExpr>(Expr).getSymbol());
1409 break;
1410
1411 case MCExpr::Unary:
1412 visitUsedExpr(*cast<MCUnaryExpr>(Expr).getSubExpr());
1413 break;
1414
1415 case MCExpr::Specifier:
1416 visitUsedExpr(*cast<MCSpecifierExpr>(Expr).getSubExpr());
1417 break;
1418 }
1419}
1420
1422 // Scan for values.
1423 for (unsigned i = Inst.getNumOperands(); i--;)
1424 if (Inst.getOperand(i).isExpr())
1425 visitUsedExpr(*Inst.getOperand(i).getExpr());
1426}
1427
1428void MCStreamer::emitPseudoProbe(uint64_t Guid, uint64_t Index, uint64_t Type,
1429 uint64_t Attr, uint64_t Discriminator,
1430 const MCPseudoProbeInlineStack &InlineStack,
1431 MCSymbol *FnSym) {
1432 auto &Context = getContext();
1433
1434 // Create a symbol at in the current section for use in the probe.
1435 MCSymbol *ProbeSym = Context.createTempSymbol();
1436
1437 // Set the value of the symbol to use for the MCPseudoProbe.
1438 emitLabel(ProbeSym);
1439
1440 // Create a (local) probe entry with the symbol.
1441 MCPseudoProbe Probe(ProbeSym, Guid, Index, Type, Attr, Discriminator);
1442
1443 // Add the probe entry to this section's entries.
1444 Context.getMCPseudoProbeTable().getProbeSections().addPseudoProbe(
1445 FnSym, Probe, InlineStack);
1446}
1447
1449 unsigned Size) {
1450 // Get the Hi-Lo expression.
1451 const MCExpr *Diff =
1453 MCSymbolRefExpr::create(Lo, Context), Context);
1454
1455 const MCAsmInfo &MAI = Context.getAsmInfo();
1456 if (!MAI.doesSetDirectiveSuppressReloc()) {
1457 emitValue(Diff, Size);
1458 return;
1459 }
1460
1461 // Otherwise, emit with .set (aka assignment).
1462 MCSymbol *SetLabel = Context.createTempSymbol("set");
1463 emitAssignment(SetLabel, Diff);
1464 emitSymbolValue(SetLabel, Size);
1465}
1466
1468 const MCSymbol *Lo) {
1469 // Get the Hi-Lo expression.
1470 const MCExpr *Diff =
1472 MCSymbolRefExpr::create(Lo, Context), Context);
1473
1474 emitULEB128Value(Diff);
1475}
1476
1479 "emitSubsectionsViaSymbols only supported on Mach-O targets");
1480}
1481void MCStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
1483 llvm_unreachable("this directive only supported on COFF targets");
1484}
1486 llvm_unreachable("this directive only supported on COFF targets");
1487}
1490 StringRef CompilerVersion,
1491 StringRef TimeStamp, StringRef Description) {
1492}
1494 llvm_unreachable("this directive only supported on COFF targets");
1495}
1497 llvm_unreachable("this directive only supported on COFF targets");
1498}
1500 MCSymbol *CsectSym,
1501 Align Alignment) {
1502 llvm_unreachable("this directive only supported on XCOFF targets");
1503}
1504
1506 MCSymbolAttr Linkage,
1507 MCSymbolAttr Visibility) {
1508 llvm_unreachable("emitXCOFFSymbolLinkageWithVisibility is only supported on "
1509 "XCOFF targets");
1510}
1511
1514
1516 llvm_unreachable("emitXCOFFRefDirective is only supported on XCOFF targets");
1517}
1518
1520 const MCSymbol *Trap,
1521 unsigned Lang, unsigned Reason,
1522 unsigned FunctionSize,
1523 bool hasDebug) {
1524 report_fatal_error("emitXCOFFExceptDirective is only supported on "
1525 "XCOFF targets");
1526}
1527
1529 llvm_unreachable("emitXCOFFCInfoSym is only supported on"
1530 "XCOFF targets");
1531}
1532
1535 StringRef Name, bool KeepOriginalSym) {}
1537 Align ByteAlignment) {}
1541 uint64_t Size, Align ByteAlignment) {}
1542
1544 CurFrag = &Sec->getDummyFragment();
1545 auto *Sym = Sec->getBeginSymbol();
1546 if (!Sym || !Sym->isUndefined())
1547 return;
1548 // In Mach-O, DWARF sections use Begin as a temporary label, requiring a label
1549 // definition, unlike section symbols in other file formats.
1550 if (getContext().getObjectFileType() == MCContext::IsMachO)
1551 emitLabel(Sym);
1552 else
1553 Sym->setFragment(CurFrag);
1554}
1555
1561}
1564void MCStreamer::emitFill(const MCExpr &NumBytes, uint64_t Value, SMLoc Loc) {}
1565void MCStreamer::emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
1566 SMLoc Loc) {}
1568void MCStreamer::emitPrefAlign(Align A, const MCSymbol &End, bool EmitNops,
1569 uint8_t Fill, const MCSubtargetInfo &STI) {}
1571 unsigned MaxBytesToEmit) {}
1573 SMLoc Loc) {}
1576 S.getStartTokLoc(),
1577 "aligned bundling is not supported by this object file format");
1578}
1589
1591 if (SectionStack.size() <= 1)
1592 return false;
1593 auto I = SectionStack.end();
1594 --I;
1595 MCSectionSubPair OldSec = I->first;
1596 --I;
1597 MCSectionSubPair NewSec = I->first;
1598
1599 if (NewSec.first && OldSec != NewSec)
1600 changeSection(NewSec.first, NewSec.second);
1601 SectionStack.pop_back();
1602 return true;
1603}
1604
1606 assert(Section && "Cannot switch to a null section!");
1607 MCSectionSubPair curSection = SectionStack.back().first;
1608 SectionStack.back().second = curSection;
1609 if (MCSectionSubPair(Section, Subsection) != curSection) {
1610 changeSection(Section, Subsection);
1611 SectionStack.back().first = MCSectionSubPair(Section, Subsection);
1612 assert(!Section->hasEnded() && "Section already ended");
1613 }
1614}
1615
1616bool MCStreamer::switchSection(MCSection *Section, const MCExpr *SubsecExpr) {
1617 int64_t Subsec = 0;
1618 if (SubsecExpr) {
1619 if (!SubsecExpr->evaluateAsAbsolute(Subsec, getAssemblerPtr())) {
1620 getContext().reportError(SubsecExpr->getLoc(),
1621 "cannot evaluate subsection number");
1622 return true;
1623 }
1624 if (!isUInt<31>(Subsec)) {
1625 getContext().reportError(SubsecExpr->getLoc(),
1626 "subsection number " + Twine(Subsec) +
1627 " is not within [0,2147483647]");
1628 return true;
1629 }
1630 }
1631 switchSection(Section, Subsec);
1632 return false;
1633}
1634
1636 SectionStack.back().second = SectionStack.back().first;
1637 SectionStack.back().first = MCSectionSubPair(Section, 0);
1638 changeSection(Section, 0);
1639}
1640
1642 MCSymbol *Sym = Section->getEndSymbol(Context);
1643 if (Sym->isInSection())
1644 return Sym;
1645
1646 // Subsections are laid out in increasing order of their numbers, so the end
1647 // of the section is the end of the highest-numbered subsection.
1648 switchSection(Section, Section->getLastSubsection());
1649 emitLabel(Sym);
1650 return Sym;
1651}
1652
1654 auto *Sec = CurFrag->getParent();
1655 F->setParent(Sec);
1656 F->setLayoutOrder(CurFrag->getLayoutOrder() + 1);
1657 CurFrag->Next = F;
1658 CurFrag = F;
1659 Sec->curFragList()->Tail = F;
1660}
1661
1662static VersionTuple
1664 VersionTuple TargetVersion) {
1665 VersionTuple Min = Target.getMinimumSupportedOSVersion();
1666 return !Min.empty() && Min > TargetVersion ? Min : TargetVersion;
1667}
1668
1669static MCVersionMinType
1671 assert(Target.isOSDarwin() && "expected a darwin OS");
1672 switch (Target.getOS()) {
1673 case Triple::MacOSX:
1674 case Triple::Darwin:
1675 return MCVM_OSXVersionMin;
1676 case Triple::IOS:
1677 assert(!Target.isMacCatalystEnvironment() &&
1678 "mac Catalyst should use LC_BUILD_VERSION");
1679 return MCVM_IOSVersionMin;
1680 case Triple::TvOS:
1681 return MCVM_TvOSVersionMin;
1682 case Triple::WatchOS:
1684 default:
1685 break;
1686 }
1687 llvm_unreachable("unexpected OS type");
1688}
1689
1691 assert(Target.isOSDarwin() && "expected a darwin OS");
1692 switch (Target.getOS()) {
1693 case Triple::MacOSX:
1694 case Triple::Darwin:
1695 return VersionTuple(10, 14);
1696 case Triple::IOS:
1697 // Mac Catalyst always uses the build version load command.
1698 if (Target.isMacCatalystEnvironment())
1699 return VersionTuple();
1700 [[fallthrough]];
1701 case Triple::TvOS:
1702 return VersionTuple(12);
1703 case Triple::WatchOS:
1704 return VersionTuple(5);
1705 case Triple::DriverKit:
1706 case Triple::BridgeOS:
1707 case Triple::XROS:
1708 // DriverKit/BridgeOS/XROS always use the build version load command.
1709 return VersionTuple();
1710 default:
1711 break;
1712 }
1713 llvm_unreachable("unexpected OS type");
1714}
1715
1718 assert(Target.isOSDarwin() && "expected a darwin OS");
1719 switch (Target.getOS()) {
1720 case Triple::MacOSX:
1721 case Triple::Darwin:
1722 return MachO::PLATFORM_MACOS;
1723 case Triple::IOS:
1724 if (Target.isMacCatalystEnvironment())
1725 return MachO::PLATFORM_MACCATALYST;
1726 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_IOSSIMULATOR
1727 : MachO::PLATFORM_IOS;
1728 case Triple::TvOS:
1729 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_TVOSSIMULATOR
1730 : MachO::PLATFORM_TVOS;
1731 case Triple::WatchOS:
1732 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_WATCHOSSIMULATOR
1733 : MachO::PLATFORM_WATCHOS;
1734 case Triple::DriverKit:
1735 return MachO::PLATFORM_DRIVERKIT;
1736 case Triple::XROS:
1737 return Target.isSimulatorEnvironment() ? MachO::PLATFORM_XROS_SIMULATOR
1738 : MachO::PLATFORM_XROS;
1739 case Triple::BridgeOS:
1740 return MachO::PLATFORM_BRIDGEOS;
1741 default:
1742 break;
1743 }
1744 llvm_unreachable("unexpected OS type");
1745}
1746
1748 const Triple &Target, const VersionTuple &SDKVersion,
1749 const Triple *DarwinTargetVariantTriple,
1750 const VersionTuple &DarwinTargetVariantSDKVersion) {
1751 if (!Target.isOSBinFormatMachO() || !Target.isOSDarwin())
1752 return;
1753 // Do we even know the version?
1754 if (Target.getOSMajorVersion() == 0)
1755 return;
1756
1758 switch (Target.getOS()) {
1759 case Triple::MacOSX:
1760 case Triple::Darwin:
1761 Target.getMacOSXVersion(Version);
1762 break;
1763 case Triple::IOS:
1764 case Triple::TvOS:
1765 Version = Target.getiOSVersion();
1766 break;
1767 case Triple::WatchOS:
1768 Version = Target.getWatchOSVersion();
1769 break;
1770 case Triple::DriverKit:
1771 Version = Target.getDriverKitVersion();
1772 break;
1773 case Triple::XROS:
1774 case Triple::BridgeOS:
1775 Version = Target.getOSVersion();
1776 break;
1777 default:
1778 llvm_unreachable("unexpected OS type");
1779 }
1780 assert(Version.getMajor() != 0 && "A non-zero major version is expected");
1781 auto LinkedTargetVersion =
1783 auto BuildVersionOSVersion = getMachoBuildVersionSupportedOS(Target);
1784 bool ShouldEmitBuildVersion = false;
1785 if (BuildVersionOSVersion.empty() ||
1786 LinkedTargetVersion >= BuildVersionOSVersion) {
1787 if (Target.isMacCatalystEnvironment() && DarwinTargetVariantTriple &&
1788 DarwinTargetVariantTriple->isMacOSX()) {
1789 emitVersionForTarget(*DarwinTargetVariantTriple,
1790 DarwinTargetVariantSDKVersion,
1791 /*DarwinTargetVariantTriple=*/nullptr,
1792 /*DarwinTargetVariantSDKVersion=*/VersionTuple());
1795 LinkedTargetVersion.getMajor(),
1796 LinkedTargetVersion.getMinor().value_or(0),
1797 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1798 return;
1799 }
1801 LinkedTargetVersion.getMajor(),
1802 LinkedTargetVersion.getMinor().value_or(0),
1803 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1804 ShouldEmitBuildVersion = true;
1805 }
1806
1807 if (const Triple *TVT = DarwinTargetVariantTriple) {
1808 if (Target.isMacOSX() && TVT->isMacCatalystEnvironment()) {
1809 auto TVLinkedTargetVersion =
1810 targetVersionOrMinimumSupportedOSVersion(*TVT, TVT->getiOSVersion());
1813 TVLinkedTargetVersion.getMajor(),
1814 TVLinkedTargetVersion.getMinor().value_or(0),
1815 TVLinkedTargetVersion.getSubminor().value_or(0),
1816 DarwinTargetVariantSDKVersion);
1817 }
1818 }
1819
1820 if (ShouldEmitBuildVersion)
1821 return;
1822
1824 LinkedTargetVersion.getMajor(),
1825 LinkedTargetVersion.getMinor().value_or(0),
1826 LinkedTargetVersion.getSubminor().value_or(0), SDKVersion);
1827}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static LVOptions Options
Definition LVOptions.cpp:25
This file declares the MCLFIRewriter class, an abstract class that encapsulates the rewriting logic f...
static VersionTuple getMachoBuildVersionSupportedOS(const Triple &Target)
static bool checkUnwindV3ExtendedReg(MCContext &Ctx, const WinEH::Instruction &Inst, uint8_t Version, SMLoc Loc, StringRef Directive)
static void copyBytesForDefRange(SmallString< 20 > &BytePrefix, codeview::SymbolKind SymKind, const T &DefRangeHeader)
Only call this on endian-specific types like ulittle16_t and little32_t, or structs composed of them.
static MCVersionMinType getMachoVersionMinLoadCommandType(const Triple &Target)
static VersionTuple targetVersionOrMinimumSupportedOSVersion(const Triple &Target, VersionTuple TargetVersion)
static MCSection * getWinCFISection(MCContext &Context, unsigned *NextWinCFIID, MCSection *MainCFISec, const MCSection *TextSec)
static void reportBundlingUnsupported(MCStreamer &S)
static MachO::PlatformType getMachoBuildVersionPlatformType(const Triple &Target)
static unsigned encodeSEHRegNum(MCContext &Ctx, MCRegister Reg)
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
#define R2(n)
#define T
static constexpr StringLiteral Filename
This file defines the SmallString class.
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Holds state from .cv_file and .cv_loc directives for later emission.
Definition MCCodeView.h:144
LLVM_ABI bool addFile(MCStreamer &OS, unsigned FileNumber, StringRef Filename, ArrayRef< uint8_t > ChecksumBytes, uint8_t ChecksumKind)
LLVM_ABI MCCVFunctionInfo * getCVFunctionInfo(unsigned FuncId)
Retreive the function info if this is a valid function id, or nullptr.
LLVM_ABI bool recordFunctionId(unsigned FuncId)
Records the function id of a normal function.
LLVM_ABI bool recordInlinedCallSiteId(unsigned FuncId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol)
Records the function id of an inlined call site.
Tagged union holding either a T or a Error.
Definition Error.h:485
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:67
const std::vector< MCCFIInstruction > & getInitialFrameState() const
Definition MCAsmInfo.h:723
const char * getData8bitsDirective() const
Definition MCAsmInfo.h:475
bool needsDwarfSectionOffsetDirective() const
Definition MCAsmInfo.h:540
bool doesSetDirectiveSuppressReloc() const
Definition MCAsmInfo.h:626
virtual const MCExpr * getDwarfSectionOffsetExpr(const MCSymbol *Sym, uint64_t Offset, MCContext &Ctx) const
Return the expression used to emit the offset of Sym + Offset from the start of its DWARF section.
Definition MCAsmInfo.cpp:73
bool usesWindowsCFI() const
Returns true if the object format describes unwind information with Windows SEH unwind opcodes (....
Definition MCAsmInfo.h:685
Binary assembler expressions.
Definition MCExpr.h:298
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition MCExpr.h:445
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition MCExpr.h:448
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition MCExpr.h:427
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_def_cfa_register modifies a rule for computing CFA.
Definition MCDwarf.h:638
static MCCFIInstruction createLLVMVectorOffset(MCSymbol *L, unsigned Register, unsigned RegisterSizeInBits, unsigned MaskRegister, unsigned MaskRegisterSizeInBits, int64_t Offset, SMLoc Loc={})
.cfi_llvm_vector_offset Previous value of Register is saved at Offset from CFA.
Definition MCDwarf.h:800
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_undefined From now on the previous value of Register can't be restored anymore.
Definition MCDwarf.h:735
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int64_t Size, SMLoc Loc={})
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
Definition MCDwarf.h:768
static MCCFIInstruction createLLVMVectorRegisters(MCSymbol *L, unsigned Register, ArrayRef< VectorRegisterWithLane > VectorRegisters, SMLoc Loc={})
.cfi_llvm_vector_registers Previous value of Register is saved in lanes of vector registers.
Definition MCDwarf.h:790
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
Definition MCDwarf.h:728
static MCCFIInstruction createSetRAState(MCSymbol *L, unsigned State, MCSymbol *PACSym=nullptr, SMLoc Loc={})
.cfi_set_ra_state AArch64 set RA sign state,
Definition MCDwarf.h:711
static MCCFIInstruction createLLVMDefAspaceCfa(MCSymbol *L, unsigned Register, int64_t Offset, unsigned AddressSpace, SMLoc Loc)
.cfi_llvm_def_aspace_cfa defines the rule for computing the CFA to be the result of evaluating the DW...
Definition MCDwarf.h:663
static MCCFIInstruction createLLVMVectorRegisterMask(MCSymbol *L, unsigned Register, unsigned SpillRegister, unsigned SpillRegisterLaneSizeInBits, unsigned MaskRegister, unsigned MaskRegisterSizeInBits, SMLoc Loc={})
.cfi_llvm_vector_register_mask Previous value of Register is saved in SpillRegister,...
Definition MCDwarf.h:811
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2, SMLoc Loc={})
.cfi_register Previous value of Register1 is saved in register Register2.
Definition MCDwarf.h:688
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition MCDwarf.h:631
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition MCDwarf.h:673
static MCCFIInstruction createValOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_val_offset Previous value of Register is offset Offset from the current CFA register.
Definition MCDwarf.h:831
static MCCFIInstruction createNegateRAStateWithPC(MCSymbol *L, SMLoc Loc={})
.cfi_negate_ra_state_with_pc AArch64 negate RA state with PC.
Definition MCDwarf.h:704
static MCCFIInstruction createNegateRAState(MCSymbol *L, SMLoc Loc={})
.cfi_negate_ra_state AArch64 negate RA state.
Definition MCDwarf.h:699
static MCCFIInstruction createRememberState(MCSymbol *L, SMLoc Loc={})
.cfi_remember_state Save all current rules for all registers.
Definition MCDwarf.h:748
static MCCFIInstruction createLLVMRegisterPair(MCSymbol *L, unsigned Register, unsigned R1, unsigned R1SizeInBits, unsigned R2, unsigned R2SizeInBits, SMLoc Loc={})
.cfi_llvm_register_pair Previous value of Register is saved in R1:R2.
Definition MCDwarf.h:780
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa_offset modifies a rule for computing CFA.
Definition MCDwarf.h:646
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, SMLoc Loc={}, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Definition MCDwarf.h:759
static MCCFIInstruction createWindowSave(MCSymbol *L, SMLoc Loc={})
.cfi_window_save SPARC register window is saved.
Definition MCDwarf.h:694
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int64_t Adjustment, SMLoc Loc={})
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
Definition MCDwarf.h:654
static MCCFIInstruction createRestoreState(MCSymbol *L, SMLoc Loc={})
.cfi_restore_state Restore the previously saved state.
Definition MCDwarf.h:753
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_same_value Current value of Register is the same as in the previous frame.
Definition MCDwarf.h:742
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register.
Definition MCDwarf.h:681
static MCCFIInstruction createLabel(MCSymbol *L, MCSymbol *CfiLabel, SMLoc Loc)
Definition MCDwarf.h:773
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition MCExpr.cpp:212
Context object for machine code objects.
Definition MCContext.h:84
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
LLVM_ABI Expected< unsigned > getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
Definition MCContext.h:714
LLVM_ABI CodeViewContext & getCVContext()
void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator)
Saves the information from the currently parsed dwarf .loc directive and sets DwarfLocSeen.
Definition MCContext.h:755
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
const MCDwarfLoc & getCurrentDwarfLoc()
Definition MCContext.h:770
const MCAsmInfo & getAsmInfo() const
Definition MCContext.h:409
void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir, StringRef Filename, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
Specifies the "root" file and directory of the compilation unit.
Definition MCContext.h:738
Instances of this class represent the line information for the dwarf line table entries.
Definition MCDwarf.h:190
LLVM_ABI void endCurrentSeqAndEmitLineStreamLabel(MCStreamer *MCOS, SMLoc DefLoc, StringRef Name)
Definition MCDwarf.cpp:295
const MCLineSection & getMCLineSections() const
Definition MCDwarf.h:454
Instances of this class represent the information from a dwarf .loc directive.
Definition MCDwarf.h:107
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
@ Unary
Unary expressions.
Definition MCExpr.h:44
@ Constant
Constant expressions.
Definition MCExpr.h:42
@ SymbolRef
References to labels and assigned expressions.
Definition MCExpr.h:43
@ Target
Target specific expression.
Definition MCExpr.h:46
@ Specifier
Expression with a relocation specifier.
Definition MCExpr.h:45
@ Binary
Binary expressions.
Definition MCExpr.h:41
ExprKind getKind() const
Definition MCExpr.h:85
SMLoc getLoc() const
Definition MCExpr.h:86
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
virtual void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS)=0
Print the specified MCInst to the specified raw_ostream.
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
unsigned getNumOperands() const
Definition MCInst.h:212
const MCOperand & getOperand(unsigned i) const
Definition MCInst.h:210
void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec)
Definition MCDwarf.h:244
const MCExpr * getExpr() const
Definition MCInst.h:118
bool isExpr() const
Definition MCInst.h:69
Instances of this class represent a pseudo probe instance for a pseudo probe table entry,...
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
This represents a section on Windows.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:580
MCFragment & getDummyFragment()
Definition MCSection.h:686
MCSymbol * getBeginSymbol()
Definition MCSection.h:653
Streaming machine code generation interface.
Definition MCStreamer.h:222
virtual void emitCFIGnuArgsSize(int64_t Size, SMLoc Loc={})
virtual void emitNops(int64_t NumBytes, int64_t ControlledNopLength, SMLoc Loc, const MCSubtargetInfo &STI)
MCSymbol * emitLineTableLabel()
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void emitCFILLVMVectorOffset(int64_t Register, int64_t RegisterSizeInBits, int64_t MaskRegister, int64_t MaskRegisterSizeInBits, int64_t Offset, SMLoc Loc={})
void switchSectionNoPrint(MCSection *Section)
Similar to switchSection, but does not print the section directive.
virtual void emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual void emitWinCFIUnwindVersion(uint8_t Version, SMLoc Loc=SMLoc())
virtual void visitUsedSymbol(const MCSymbol &Sym)
void setDefaultWinCFIUnwindVersion(uint8_t V)
Set the default unwind version for new WinCFI frames.
void emitCFIStartProc(bool IsSimple, SMLoc Loc=SMLoc())
virtual bool emitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
bool checkCVLocSection(unsigned FuncId, SMLoc Loc)
Returns true if the .cv_loc directive is in the right section.
virtual void finishImpl()
Streamer specific finalization.
virtual void emitCFIBKeyFrame()
virtual void beginCOFFSymbolDef(const MCSymbol *Symbol)
Start emitting COFF symbol definition.
virtual void emitWinCFIPushReg(MCRegister Register, SMLoc Loc=SMLoc())
virtual void emitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
virtual bool popSection()
Restore the current and previous section from the section stack.
virtual MCSymbol * emitCFILabel()
When emitting an object file, create and emit a real label.
std::unique_ptr< MCLFIRewriter > LFIRewriter
Definition MCStreamer.h:299
virtual void emitWindowsUnwindTables()
virtual raw_ostream & getCommentOS()
Return a raw_ostream that comments can be written to.
virtual void emitZerofill(MCSection *Section, MCSymbol *Symbol=nullptr, uint64_t Size=0, Align ByteAlignment=Align(1), SMLoc Loc=SMLoc())
Emit the zerofill section and an optional symbol.
virtual void emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
virtual void emitCFISections(bool EH, bool Debug, bool SFrame)
MCSection * getAssociatedPDataSection(const MCSection *TextSec)
Get the .pdata section used for the given section.
virtual void emitDwarfLocLabelDirective(SMLoc Loc, StringRef Name)
This implements the '.loc_label Name' directive.
bool hasUnfinishedDwarfFrameInfo()
virtual ~MCStreamer()
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
virtual void emitCFINegateRAStateWithPC(SMLoc Loc={})
virtual void emitCFISameValue(int64_t Register, SMLoc Loc={})
virtual void emitSyntaxDirective(StringRef Syntax, StringRef Options)
virtual bool emitCVFileDirective(unsigned FileNo, StringRef Filename, ArrayRef< uint8_t > Checksum, unsigned ChecksumKind)
Associate a filename with a specified logical file number, and also specify that file's checksum info...
virtual void emitCFIReturnColumn(int64_t Register)
virtual void emitCOFFSymbolType(int Type)
Emit the type of the symbol.
virtual void emitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
virtual void emitDwarfUnitLength(uint64_t Length, const Twine &Comment)
Emit a unit length field.
virtual void emitCFIWindowSave(SMLoc Loc={})
virtual void emitCOFFSymbolIndex(MCSymbol const *Symbol)
Emits the symbol table index of a Symbol into the current section.
void emitSymbolValue(const MCSymbol *Sym, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
virtual void emitCFILLVMRegisterPair(int64_t Register, int64_t R1, int64_t R1SizeInBits, int64_t R2, int64_t R2SizeInBits, SMLoc Loc={})
virtual void emitCodeAlignment(Align Alignment, const MCSubtargetInfo &STI, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
SmallVector< MCDwarfFrameInfo, 0 > DwarfFrameInfos
Definition MCStreamer.h:273
virtual void emitWinCFIUnwindV2Start(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndEpilogue(SMLoc Loc=SMLoc())
virtual void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset)
Emits a COFF image relative relocation.
virtual void endCOFFSymbolDef()
Marks the end of the symbol definition.
virtual void emitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
virtual MCAssembler * getAssemblerPtr()
Definition MCStreamer.h:331
virtual void emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo)
Emit the absolute difference between two symbols encoded with ULEB128.
virtual void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol, MCSymbolAttr Linkage, MCSymbolAttr Visibility)
Emit a symbol's linkage and visibility with a linkage directive for XCOFF.
virtual void emitCFIUndefined(int64_t Register, SMLoc Loc={})
void setTargetStreamer(MCTargetStreamer *TS)
Definition MCStreamer.h:309
virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame)
virtual void emitCOFFSecNumber(MCSymbol const *Symbol)
Emits the physical number of the section containing the given symbol as assigned during object writin...
virtual void emitCFINegateRAState(SMLoc Loc={})
virtual void emitCFILsda(const MCSymbol *Sym, unsigned Encoding)
MCContext & getContext() const
Definition MCStreamer.h:326
SMLoc getStartTokLoc() const
Definition MCStreamer.h:314
virtual Expected< unsigned > tryEmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, std::optional< MD5::MD5Result > Checksum=std::nullopt, std::optional< StringRef > Source=std::nullopt, unsigned CUID=0)
Associate a filename with a specified logical file number.
virtual void addExplicitComment(const Twine &T)
Add explicit comment T.
virtual void AddComment(const Twine &T, bool EOL=true)
Add a textual comment.
Definition MCStreamer.h:404
virtual void emitWinCFIBeginEpilogue(SMLoc Loc=SMLoc())
virtual void initSections(const MCSubtargetInfo &STI)
Create the default sections and set the initial one.
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
virtual void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t Size, MCSymbol *CsectSym, Align Alignment)
Emits an lcomm directive with XCOFF csect information.
virtual void emitCFIMTETaggedFrame()
virtual void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)
Emits a COFF section relative relocation.
virtual void emitBundleLock(bool AlignToEnd, const MCSubtargetInfo &STI)
The following instructions are a bundle-locked group.
MCSection * getAssociatedXDataSection(const MCSection *TextSec)
Get the .xdata section used for the given section.
virtual void emitRawComment(const Twine &T, bool TabPrefix=true)
Print T and prefix it with the comment string (normally #) and optionally a tab.
virtual void emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc=SMLoc())
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)
Emit the debug line start label.
virtual void emitCFIEscape(StringRef Values, SMLoc Loc={})
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
virtual void emitXCOFFExceptDirective(const MCSymbol *Symbol, const MCSymbol *Trap, unsigned Lang, unsigned Reason, unsigned FunctionSize, bool hasDebug)
Emit an XCOFF .except directive which adds information about a trap instruction to the object file ex...
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void emitCOFFSectionIndex(MCSymbol const *Symbol)
Emits a COFF section index.
virtual void emitCFIRememberState(SMLoc Loc)
virtual void reset()
State management.
virtual void emitValueToAlignment(Align Alignment, int64_t Fill=0, uint8_t FillLen=1, unsigned MaxBytesToEmit=0)
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
virtual void emitCFILabelDirective(SMLoc Loc, StringRef Name)
virtual void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName, StringRef Comment={})
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
virtual void emitCOFFSecOffset(MCSymbol const *Symbol)
Emits the offset of the symbol from the beginning of the section during object writing (i....
MCTargetStreamer * getTargetStreamer()
Definition MCStreamer.h:336
MCStreamer(MCContext &Ctx)
MCFragment * CurFrag
Definition MCStreamer.h:271
virtual void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Definition MCStreamer.h:525
virtual void emitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers.
unsigned getNumFrameInfos()
virtual void emitWinCFISaveReg(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
virtual void emitWinCFIEndProlog(SMLoc Loc=SMLoc())
virtual void emitWinCFIEndProc(SMLoc Loc=SMLoc())
virtual void emitSubsectionsViaSymbols()
Emit a .subsection_via_symbols directive.
void emitVersionForTarget(const Triple &Target, const VersionTuple &SDKVersion, const Triple *DarwinTargetVariantTriple, const VersionTuple &DarwinTargetVariantSDKVersion)
virtual void emitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
virtual void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
Set the DescValue for the Symbol.
virtual void emitCFIDefCfaRegister(int64_t Register, SMLoc Loc={})
virtual void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment)
Emit a local common (.lcomm) symbol.
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
virtual void emitCFIRegister(int64_t Register1, int64_t Register2, SMLoc Loc={})
virtual void emitCOFFSafeSEH(MCSymbol const *Symbol)
virtual void emitWinCFIFuncletOrFuncEnd(SMLoc Loc=SMLoc())
This is used on platforms, such as Windows on ARM64, that require function or funclet sizes to be emi...
virtual void emitXCOFFRenameDirective(const MCSymbol *Name, StringRef Rename)
Emit a XCOFF .rename directive which creates a synonym for an illegal or undesirable name.
virtual void emitBundleUnlock(const MCSubtargetInfo &STI)
Ends a bundle-locked group.
virtual void emitPseudoProbe(uint64_t Guid, uint64_t Index, uint64_t Type, uint64_t Attr, uint64_t Discriminator, const MCPseudoProbeInlineStack &InlineStack, MCSymbol *FnSym)
Emit the a pseudo probe into the current section.
void setLFIRewriter(std::unique_ptr< MCLFIRewriter > Rewriter)
virtual void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count)
virtual void emitCFIAdjustCfaOffset(int64_t Adjustment, SMLoc Loc={})
unsigned emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
virtual void emitWinCFIPush2Regs(MCRegister Reg1, MCRegister Reg2, SMLoc Loc=SMLoc())
virtual void emitULEB128Value(const MCExpr *Value)
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
virtual void emitPrefAlign(Align A, const MCSymbol &End, bool EmitNops, uint8_t Fill, const MCSubtargetInfo &STI)
virtual void emitCFILLVMVectorRegisterMask(int64_t Register, int64_t SpillRegister, int64_t SpillRegisterLaneSizeInBits, int64_t MaskRegister, int64_t MaskRegisterSizeInBits, SMLoc Loc={})
virtual void emitCFIRelOffset(int64_t Register, int64_t Offset, SMLoc Loc)
virtual void emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc)
Emit some number of copies of Value until the byte offset Offset is reached.
MCSymbol * endSection(MCSection *Section)
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
virtual void emitExplicitComments()
Emit added explicit comments.
WinEH::FrameInfo * EnsureValidWinFrameInfo(SMLoc Loc)
Retrieve the current frame info if one is available and it is not yet closed.
virtual void emitCFIRestoreState(SMLoc Loc)
virtual void emitXCOFFRefDirective(const MCSymbol *Symbol)
Emit a XCOFF .ref directive which creates R_REF type entry in the relocation table for one or more sy...
virtual void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol)
virtual void emitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
void emitInt32(uint64_t Value)
Definition MCStreamer.h:769
virtual void emitCFIOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
void maybeEmitDwarf64Mark()
Emit a special value of 0xffffffff if producing 64-bit debugging info.
virtual void emitCFIDefCfaOffset(int64_t Offset, SMLoc Loc={})
virtual void emitWinCFISplitChained(SMLoc Loc=SMLoc())
virtual void emitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc)
This implements the CodeView '.cv_loc' assembler directive.
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
Definition MCStreamer.h:433
virtual void emitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
virtual void emitFileDirective(StringRef Filename)
Switch to a new logical file.
virtual void emitSLEB128Value(const MCExpr *Value)
virtual void emitCFIValOffset(int64_t Register, int64_t Offset, SMLoc Loc={})
virtual void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name, bool KeepOriginalSym)
Emit an ELF .symver directive.
virtual void emitXCOFFCInfoSym(StringRef Name, StringRef Metadata)
Emit a C_INFO symbol with XCOFF embedded metadata to the .info section.
MCSection * getCurrentSectionOnly() const
Definition MCStreamer.h:438
virtual void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
void emitRawText(const Twine &String)
If this file is backed by a assembly streamer, this dumps the specified string in the output ....
void emitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
void addFragment(MCFragment *F)
unsigned emitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
virtual bool emitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol, SMLoc Loc)
Introduces an inline call site id for use with .cv_loc.
virtual void emitCFISignalFrame()
virtual void emitCFILLVMVectorRegisters(int64_t Register, ArrayRef< MCCFIInstruction::VectorRegisterWithLane > VRs, SMLoc Loc={})
virtual void emitVersionMin(MCVersionMinType Type, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Specify the Mach-O minimum deployment target version.
Definition MCStreamer.h:515
virtual void emitCOFFSymbolStorageClass(int StorageClass)
Emit the storage class of the symbol.
virtual void emitConditionalAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol, but only if Value is also emitted.
virtual void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment=Align(1))
Emit a thread local bss (.tbss) symbol.
virtual void emitCFIRestore(int64_t Register, SMLoc Loc={})
WinEH::FrameInfo::Epilog * CurrentWinEpilog
Definition MCStreamer.h:269
virtual void emitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView '.cv_inline_linetable' assembler directive.
void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
virtual void emitBundleAlignMode(Align Alignment)
Enable aligned instruction bundling with the given bundle size, from this point onward.
virtual void emitRawTextImpl(StringRef String)
EmitRawText - If this file is backed by an assembly streamer, this dumps the specified string in the ...
void emitDwarfSectionOffset(const MCSymbol *Sym, uint64_t Offset, unsigned Size)
Emit the offset of Sym + Offset from the start of its DWARF section as a section-relative relocation.
virtual void emitBytes(StringRef Data)
Emit the bytes in Data into the output.
void finish(SMLoc EndLoc=SMLoc())
Finish emission of machine code.
virtual void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol)
Emit an weak reference from Alias to Symbol.
void visitUsedExpr(const MCExpr &Expr)
virtual void emitDwarfFile0Directive(StringRef Directory, StringRef Filename, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, unsigned CUID=0)
Specify the "root" file of the compilation, using the ".file 0" extension.
virtual void emitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor, unsigned Update, VersionTuple SDKVersion)
Emit/Specify Mach-O build version command.
Definition MCStreamer.h:521
virtual void changeSection(MCSection *, uint32_t)
This is called by popSection and switchSection, if the current section changes.
virtual void emitCFINonHintPAuthFrame()
virtual void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset, int64_t AddressSpace, SMLoc Loc={})
virtual void emitCFILLVMSetRAState(unsigned State, MCSymbol *PACSym, SMLoc Loc={})
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
Definition MCExpr.h:190
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:213
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute).
Definition MCSymbol.h:237
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
Definition MCSymbol.h:243
StringRef getName() const
getName - Get the symbol name.
Definition MCSymbol.h:188
void setFragment(MCFragment *F) const
Mark the symbol as defined in the fragment F.
Definition MCSymbol.h:257
Target specific streamer interface.
Definition MCStreamer.h:95
virtual void emitDwarfFileDirective(StringRef Directive)
virtual void emitValue(const MCExpr *Value)
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, uint64_t Address, const MCInst &Inst, const MCSubtargetInfo &STI, raw_ostream &OS)
virtual void finish()
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
virtual void emitRawBytes(StringRef Data)
Emit the bytes in Data into the output.
MCStreamer & Streamer
Definition MCStreamer.h:97
MCTargetStreamer(MCStreamer &S)
virtual void changeSection(const MCSection *CurSection, MCSection *Section, uint32_t SubSection, raw_ostream &OS)
Update streamer for a new active section.
virtual void emitLabel(MCSymbol *Symbol)
virtual void emitConstantPools()
Root of the metadata hierarchy.
Definition Metadata.h:65
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Represents a location in source code.
Definition SMLoc.h:22
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:28
StringRef str() const
Explicit conversion to StringRef.
void resize(size_type N)
pointer data()
Return a pointer to the vector's buffer, even if empty().
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
bool isMacOSX() const
Is this a Mac OS X triple.
Definition Triple.h:684
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM Value Representation.
Definition Value.h:75
Represents a version number in the form major[.minor[.subminor[.build]]].
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
A raw_ostream that writes to an SmallVector or SmallString.
StringRef str() const
Return a StringRef for the vector contents.
This class represents a function that is read from a sample profile.
Definition FunctionId.h:36
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_SCN_LNK_COMDAT
Definition COFF.h:309
@ IMAGE_COMDAT_SELECT_ANY
Definition COFF.h:456
detail::packed_endian_specific_integral< uint16_t, llvm::endianness::little, unaligned > ulittle16_t
Definition Endian.h:267
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
Definition CodeView.h:48
@ DWARF64
Definition Dwarf.h:93
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
Definition Dwarf.h:1208
@ DW_LENGTH_lo_reserved
Special values for an initial length field.
Definition Dwarf.h:56
@ DW_LENGTH_DWARF64
Indicator of 64-bit DWARF format.
Definition Dwarf.h:57
value_type byte_swap(value_type value, endianness endian)
Swap the bytes of value to match the given endianness.
Definition Endian.h:45
detail::packed_endian_specific_integral< uint16_t, llvm::endianness::little, unaligned > ulittle16_t
Definition Endian.h:267
constexpr bool IsLittleEndianHost
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
@ Length
Definition DWP.cpp:577
LLVM_ABI void StoreIntToMemory(const APInt &IntVal, uint8_t *Dst, unsigned StoreBytes)
Fills the StoreBytes bytes of memory starting from Dst with the integer held in IntVal.
Definition APInt.cpp:3094
RelativeUniformCounterPtr Values
Definition InstrProf.h:91
@ Debug
Register 'use' is for debugging purpose.
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Definition MathExtras.h:244
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
SmallVector< InlineSite, 8 > MCPseudoProbeInlineStack
MCVersionMinType
@ MCVM_WatchOSVersionMin
.watchos_version_min
@ MCVM_OSXVersionMin
.macosx_version_min
@ MCVM_TvOSVersionMin
.tvos_version_min
@ MCVM_IOSVersionMin
.ios_version_min
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
Definition MathExtras.h:190
LLVM_ABI raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition InstrProf.h:145
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
Definition LEB128.h:24
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
Definition MathExtras.h:249
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
Definition LEB128.h:79
std::pair< MCSection *, uint32_t > MCSectionSubPair
Definition MCStreamer.h:68
@ End
Run the machine verifier once, at the end of the pipeline.
Definition CodeGen.h:320
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Information describing a function or inlined call site introduced by .cv_func_id or ....
Definition MCCodeView.h:98
MCSection * Section
The section of the first .cv_loc directive used for this function, or null if none has been seen yet.
Definition MCCodeView.h:118
const MCSymbol * Personality
Definition MCDwarf.h:907
unsigned RememberStateDepth
Definition MCDwarf.h:911
unsigned PersonalityEncoding
Definition MCDwarf.h:912
std::vector< MCCFIInstruction > Instructions
Definition MCDwarf.h:909
const MCSymbol * Lsda
Definition MCDwarf.h:908
unsigned CurrentCfaRegister
Definition MCDwarf.h:910
static WinEH::Instruction SaveXMM(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition MCWin64EH.h:45
static WinEH::Instruction PushNonVol(MCSymbol *L, unsigned Reg)
Definition MCWin64EH.h:26
static WinEH::Instruction PushMachFrame(MCSymbol *L, bool Code)
Definition MCWin64EH.h:36
static WinEH::Instruction SaveNonVol(MCSymbol *L, unsigned Reg, unsigned Offset)
Definition MCWin64EH.h:39
static WinEH::Instruction Alloc(MCSymbol *L, unsigned Size)
Definition MCWin64EH.h:32
static WinEH::Instruction SetFPReg(MCSymbol *L, unsigned Reg, unsigned Off)
Definition MCWin64EH.h:51
static WinEH::Instruction Push2(MCSymbol *L, unsigned Reg1, unsigned Reg2)
Definition MCWin64EH.h:29
std::vector< Instruction > Instructions
Definition MCWinEH.h:68
const MCSymbol * Function
Definition MCWinEH.h:51
MCSection * TextSection
Definition MCWinEH.h:55
FrameInfo * ChainedParent
Definition MCWinEH.h:67
const MCSymbol * PrologEnd
Definition MCWinEH.h:53
MapVector< MCSymbol *, Epilog > EpilogMap
Definition MCWinEH.h:77
const MCSymbol * FuncletOrFuncEnd
Definition MCWinEH.h:49
const MCSymbol * End
Definition MCWinEH.h:48
static constexpr uint8_t DefaultVersion
Definition MCWinEH.h:63
const MCSymbol * ExceptionHandler
Definition MCWinEH.h:50