21 #include "llvm/Config/config.h" 53 bool UseRelocs =
false;
74 if (MinInsnLength == 1)
76 if (AddrDelta % MinInsnLength != 0) {
80 return AddrDelta / MinInsnLength;
110 .addLineEntry(LineEntry, Section);
137 static inline const MCExpr *
153 unsigned FileNum = 1;
154 unsigned LastLine = 1;
158 unsigned Discriminator = 0;
163 int64_t LineDelta =
static_cast<int64_t
>(LineEntry.getLine()) - LastLine;
165 if (FileNum != LineEntry.getFileNum()) {
166 FileNum = LineEntry.getFileNum();
170 if (Column != LineEntry.getColumn()) {
171 Column = LineEntry.getColumn();
175 if (Discriminator != LineEntry.getDiscriminator() &&
177 Discriminator = LineEntry.getDiscriminator();
184 if (Isa != LineEntry.getIsa()) {
185 Isa = LineEntry.getIsa();
190 Flags = LineEntry.getFlags();
198 MCOS->
EmitIntValue(dwarf::DW_LNS_set_epilogue_begin, 1);
200 MCSymbol *Label = LineEntry.getLabel();
210 LastLine = LineEntry.getLine();
241 if (LineTables.empty())
253 for (
const auto &CUIDTablePair : LineTables) {
254 CUIDTablePair.second.EmitCU(MCOS, Params, LineStr);
263 if (Header.MCDwarfFiles.empty())
267 MCOS.
EmitLabel(Header.Emit(&MCOS, Params,
None, NoLineStr).second);
270 std::pair<MCSymbol *, MCSymbol *>
273 static const char StandardOpcodeLengths[] = {
297 assert(!isa<MCSymbolRefExpr>(Expr));
319 LineStrings.
write((uint8_t *)Data.
data());
333 void MCDwarfLineTableHeader::emitV2FileDirTables(
MCStreamer *MCOS)
const {
335 for (
auto &Dir : MCDwarfDirs) {
342 for (
unsigned i = 1; i < MCDwarfFiles.size(); i++) {
354 bool EmitMD5,
bool HasSource,
368 Cksum->
Bytes.size()));
381 void MCDwarfLineTableHeader::emitV5FileDirTables(
390 : dwarf::DW_FORM_string);
394 CompilationDir.
empty() ? CtxCompilationDir :
StringRef(CompilationDir);
397 LineStr->
emitRef(MCOS, CompDir);
398 for (
const auto &Dir : MCDwarfDirs)
404 for (
const auto &Dir : MCDwarfDirs) {
413 uint64_t Entries = 2;
421 : dwarf::DW_FORM_string);
431 : dwarf::DW_FORM_string);
439 HasAllMD5, HasSource, LineStr);
440 for (
unsigned i = 1; i < MCDwarfFiles.size(); ++i)
444 std::pair<MCSymbol *, MCSymbol *>
469 LineTableVersion = 2;
474 unsigned PreHeaderLengthBytes = 4 + 2;
477 if (LineTableVersion >= 5) {
480 PreHeaderLengthBytes += 2;
490 (PreHeaderLengthBytes + 4)),
498 if (LineTableVersion >= 4)
506 for (
char Length : StandardOpcodeLengths)
511 if (LineTableVersion >= 5)
514 emitV2FileDirTables(MCOS);
520 return std::make_pair(LineStartSym, LineEndSym);
526 MCSymbol *LineEndSym = Header.Emit(MCOS, Params, LineStr).second;
529 for (
const auto &LineSec : MCLineSections.getMCLineEntries())
541 unsigned FileNumber) {
542 return Header.tryGetFile(Directory, FileName, Checksum, Source, FileNumber);
550 unsigned FileNumber) {
551 if (Directory == CompilationDir)
553 if (FileName.
empty()) {
554 FileName =
"<stdin>";
560 if (MCDwarfFiles.empty()) {
561 trackMD5Usage(Checksum);
562 HasSource = (Source !=
None);
564 if (FileNumber == 0) {
567 FileNumber = MCDwarfFiles.empty() ? 1 : MCDwarfFiles.size();
569 auto IterBool = SourceIdMap.
insert(
572 if (!IterBool.second)
573 return IterBool.first->second;
576 if (FileNumber >= MCDwarfFiles.size())
577 MCDwarfFiles.resize(FileNumber + 1);
583 if (!File.
Name.empty())
584 return make_error<StringError>(
"file number already allocated",
588 if (HasSource != (Source !=
None))
589 return make_error<StringError>(
"inconsistent use of embedded source",
592 if (Directory.
empty()) {
595 if (!tFileName.
empty()) {
597 if (!Directory.
empty())
598 FileName = tFileName;
605 if (Directory.
empty()) {
610 for (
unsigned End = MCDwarfDirs.size(); DirIndex < End; DirIndex++) {
611 if (Directory == MCDwarfDirs[DirIndex])
614 if (DirIndex >= MCDwarfDirs.size())
615 MCDwarfDirs.push_back(Directory);
623 File.
Name = FileName;
626 trackMD5Usage(Checksum);
637 int64_t LineDelta, uint64_t AddrDelta) {
653 int64_t LineDelta, uint64_t AddrDelta,
655 uint64_t Temp, Opcode;
656 bool NeedCopy =
false;
659 uint64_t MaxSpecialAddrDelta =
SpecialAddr(Params, 255);
668 if (AddrDelta == MaxSpecialAddrDelta)
669 OS <<
char(dwarf::DW_LNS_const_add_pc);
670 else if (AddrDelta) {
671 OS << char(dwarf::DW_LNS_advance_pc);
674 OS << char(dwarf::DW_LNS_extended_op);
676 OS << char(dwarf::DW_LNE_end_sequence);
687 OS <<
char(dwarf::DW_LNS_advance_line);
696 if (LineDelta == 0 && AddrDelta == 0) {
697 OS <<
char(dwarf::DW_LNS_copy);
705 if (AddrDelta < 256 + MaxSpecialAddrDelta) {
714 Opcode = Temp + (AddrDelta - MaxSpecialAddrDelta) * Params.
DWARF2LineRange;
716 OS <<
char(dwarf::DW_LNS_const_add_pc);
723 OS <<
char(dwarf::DW_LNS_advance_pc);
727 OS << char(dwarf::DW_LNS_copy);
729 assert(Temp <= 255 &&
"Buggy special opcode encoding.");
736 int64_t LineDelta, uint64_t AddrDelta,
740 OS <<
char(dwarf::DW_LNS_advance_line);
750 if (AddrDelta > 60000) {
754 OS <<
char(dwarf::DW_LNS_extended_op);
756 OS << char(dwarf::DW_LNE_set_address);
761 std::vector<uint8_t> FillData;
762 FillData.insert(FillData.begin(), AddrSize, 0);
763 OS.
write(reinterpret_cast<char *>(FillData.data()), AddrSize);
765 OS <<
char(dwarf::DW_LNS_fixed_advance_pc);
775 OS <<
char(dwarf::DW_LNS_extended_op);
777 OS << char(dwarf::DW_LNE_end_sequence);
779 OS <<
char(dwarf::DW_LNS_copy);
802 ? dwarf::DW_FORM_sec_offset
803 : dwarf::DW_FORM_data4);
807 ? dwarf::DW_FORM_sec_offset
808 : dwarf::DW_FORM_data4);
810 EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr);
811 EmitAbbrev(MCOS, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr);
813 EmitAbbrev(MCOS, dwarf::DW_AT_name, dwarf::DW_FORM_string);
815 EmitAbbrev(MCOS, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string);
817 if (!DwarfDebugFlags.
empty())
818 EmitAbbrev(MCOS, dwarf::DW_AT_APPLE_flags, dwarf::DW_FORM_string);
819 EmitAbbrev(MCOS, dwarf::DW_AT_producer, dwarf::DW_FORM_string);
820 EmitAbbrev(MCOS, dwarf::DW_AT_language, dwarf::DW_FORM_data2);
827 EmitAbbrev(MCOS, dwarf::DW_AT_name, dwarf::DW_FORM_string);
828 EmitAbbrev(MCOS, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data4);
829 EmitAbbrev(MCOS, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data4);
830 EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr);
831 EmitAbbrev(MCOS, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag);
849 const MCSymbol *InfoSectionSymbol) {
858 int Length = 4 + 2 + 4 + 1 + 1;
864 int Pad = 2 * AddrSize - (Length & (2 * AddrSize - 1));
865 if (Pad == 2 * AddrSize)
871 Length += 2 * AddrSize * Sections.size();
873 Length += 2 * AddrSize;
882 if (InfoSectionSymbol)
892 for(
int i = 0; i < Pad; i++)
898 const MCSymbol *StartSymbol = Sec->getBeginSymbol();
899 MCSymbol *EndSymbol = Sec->getEndSymbol(context);
900 assert(StartSymbol &&
"StartSymbol must not be NULL");
901 assert(EndSymbol &&
"EndSymbol must not be NULL");
906 *StartSymbol, *EndSymbol, 0);
920 const MCSymbol *AbbrevSectionSymbol,
922 const MCSymbol *RangesSectionSymbol) {
953 if (AbbrevSectionSymbol ==
nullptr)
968 if (LineSectionSymbol)
974 if (RangesSectionSymbol) {
987 const auto TextSection = Sections.begin();
988 assert(TextSection != Sections.end() &&
"No text section found");
990 MCSymbol *StartSymbol = (*TextSection)->getBeginSymbol();
991 MCSymbol *EndSymbol = (*TextSection)->getEndSymbol(context);
992 assert(StartSymbol &&
"StartSymbol must not be NULL");
993 assert(EndSymbol &&
"EndSymbol must not be NULL");
1009 if (MCDwarfDirs.
size() > 0) {
1026 if (!DwarfDebugFlags.
empty()){
1033 if (!DwarfDebugProducer.
empty())
1046 const std::vector<MCGenDwarfLabelEntry> &Entries =
1048 for (
const auto &Entry : Entries) {
1097 const MCSymbol *StartSymbol = Sec->getBeginSymbol();
1098 MCSymbol *EndSymbol = Sec->getEndSymbol(context);
1099 assert(StartSymbol &&
"StartSymbol must not be NULL");
1100 assert(EndSymbol &&
"EndSymbol must not be NULL");
1106 MCOS->
EmitValue(SectionStartAddr, AddrSize);
1110 *StartSymbol, *EndSymbol, 0);
1129 bool CreateDwarfSectionSymbols =
1131 MCSymbol *LineSectionSymbol =
nullptr;
1132 if (CreateDwarfSectionSymbols)
1134 MCSymbol *AbbrevSectionSymbol =
nullptr;
1135 MCSymbol *InfoSectionSymbol =
nullptr;
1136 MCSymbol *RangesSectionSymbol =
nullptr;
1148 const bool UseRangesSection =
1151 CreateDwarfSectionSymbols |= UseRangesSection;
1154 if (CreateDwarfSectionSymbols) {
1159 if (CreateDwarfSectionSymbols) {
1163 if (UseRangesSection) {
1165 if (CreateDwarfSectionSymbols) {
1171 assert((RangesSectionSymbol !=
nullptr) || !UseRangesSection);
1178 if (UseRangesSection)
1186 RangesSectionSymbol);
1243 unsigned symbolEncoding) {
1245 unsigned format = symbolEncoding & 0x0f;
1264 unsigned symbolEncoding,
bool isEH) {
1278 unsigned symbolEncoding) {
1290 class FrameEmitterImpl {
1292 int InitialCFAOffset = 0;
1298 : IsEH(IsEH), Streamer(Streamer) {}
1305 bool LastInSection,
const MCSymbol &SectionStart);
1319 auto *
MRI = Streamer.getContext().getRegisterInfo();
1326 Reg1 =
MRI->getDwarfRegNumFromDwarfEHRegNum(Reg1);
1327 Reg2 =
MRI->getDwarfRegNumFromDwarfEHRegNum(Reg2);
1329 Streamer.EmitIntValue(dwarf::DW_CFA_register, 1);
1330 Streamer.EmitULEB128IntValue(Reg1);
1331 Streamer.EmitULEB128IntValue(Reg2);
1335 Streamer.EmitIntValue(dwarf::DW_CFA_GNU_window_save, 1);
1340 Streamer.EmitIntValue(dwarf::DW_CFA_undefined, 1);
1341 Streamer.EmitULEB128IntValue(Reg);
1346 const bool IsRelative =
1349 Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa_offset, 1);
1356 Streamer.EmitULEB128IntValue(CFAOffset);
1363 Reg =
MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);
1364 Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa, 1);
1365 Streamer.EmitULEB128IntValue(Reg);
1367 Streamer.EmitULEB128IntValue(CFAOffset);
1374 Reg =
MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);
1375 Streamer.EmitIntValue(dwarf::DW_CFA_def_cfa_register, 1);
1376 Streamer.EmitULEB128IntValue(Reg);
1382 const bool IsRelative =
1387 Reg =
MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);
1391 Offset -= CFAOffset;
1392 Offset = Offset / dataAlignmentFactor;
1395 Streamer.EmitIntValue(dwarf::DW_CFA_offset_extended_sf, 1);
1396 Streamer.EmitULEB128IntValue(Reg);
1397 Streamer.EmitSLEB128IntValue(Offset);
1398 }
else if (Reg < 64) {
1399 Streamer.EmitIntValue(dwarf::DW_CFA_offset + Reg, 1);
1400 Streamer.EmitULEB128IntValue(Offset);
1402 Streamer.EmitIntValue(dwarf::DW_CFA_offset_extended, 1);
1403 Streamer.EmitULEB128IntValue(Reg);
1404 Streamer.EmitULEB128IntValue(Offset);
1409 Streamer.EmitIntValue(dwarf::DW_CFA_remember_state, 1);
1412 Streamer.EmitIntValue(dwarf::DW_CFA_restore_state, 1);
1416 Streamer.EmitIntValue(dwarf::DW_CFA_same_value, 1);
1417 Streamer.EmitULEB128IntValue(Reg);
1423 Reg =
MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);
1424 Streamer.EmitIntValue(dwarf::DW_CFA_restore | Reg, 1);
1428 Streamer.EmitIntValue(dwarf::DW_CFA_GNU_args_size, 1);
1429 Streamer.EmitULEB128IntValue(Instr.
getOffset());
1445 if (Label && !Label->
isDefined())
continue;
1448 if (BaseLabel && Label) {
1450 if (ThisSym != BaseLabel) {
1451 Streamer.EmitDwarfAdvanceFrameAddr(BaseLabel, ThisSym);
1452 BaseLabel = ThisSym;
1456 EmitCFIInstruction(Instr);
1488 if (!Encoding)
return;
1492 if (!DwarfEHFrameOnly && Frame.
Lsda)
1493 Encoding |= 0x40000000;
1498 Streamer.EmitSymbolValue(Frame.
Begin, Size);
1507 Streamer.EmitIntValue(Encoding, Size);
1512 Streamer.EmitSymbolValue(Frame.
Personality, Size);
1514 Streamer.EmitIntValue(0, Size);
1518 if (!DwarfEHFrameOnly && Frame.
Lsda)
1519 Streamer.EmitSymbolValue(Frame.
Lsda, Size);
1521 Streamer.EmitIntValue(0, Size);
1527 switch (DwarfVersion) {
1540 MCContext &context = Streamer.getContext();
1545 Streamer.EmitLabel(sectionStart);
1555 unsigned CIE_ID = IsEH ? 0 : -1;
1556 Streamer.EmitIntValue(CIE_ID, 4);
1560 Streamer.EmitIntValue(CIEVersion, 1);
1565 Augmentation +=
"z";
1567 Augmentation +=
"P";
1569 Augmentation +=
"L";
1570 Augmentation +=
"R";
1572 Augmentation +=
"S";
1573 Streamer.EmitBytes(Augmentation);
1575 Streamer.EmitIntValue(0, 1);
1577 if (CIEVersion >= 4) {
1582 Streamer.EmitIntValue(0, 1);
1592 unsigned RAReg = Frame.
RAReg;
1593 if (RAReg == static_cast<unsigned>(INT_MAX))
1596 if (CIEVersion == 1) {
1598 "DWARF 2 encodes return_address_register in one byte");
1599 Streamer.EmitIntValue(RAReg, 1);
1601 Streamer.EmitULEB128IntValue(RAReg);
1605 unsigned augmentationLength = 0;
1609 augmentationLength += 1;
1611 augmentationLength +=
1615 augmentationLength += 1;
1617 augmentationLength += 1;
1619 Streamer.EmitULEB128IntValue(augmentationLength);
1640 const std::vector<MCCFIInstruction> &Instructions =
1642 EmitCFIInstructions(Instructions,
nullptr);
1645 InitialCFAOffset = CFAOffset;
1648 Streamer.EmitValueToAlignment(IsEH ? 4 : MAI->getCodePointerSize());
1650 Streamer.EmitLabel(sectionEnd);
1651 return *sectionStart;
1654 void FrameEmitterImpl::EmitFDE(
const MCSymbol &cieStart,
1658 MCContext &context = Streamer.getContext();
1663 CFAOffset = InitialCFAOffset;
1669 Streamer.EmitLabel(fdeStart);
1682 Streamer.EmitSymbolValue(&cieStart, 4);
1686 unsigned PCEncoding =
1698 unsigned augmentationLength = 0;
1703 Streamer.EmitULEB128IntValue(augmentationLength);
1718 Streamer.EmitValueToAlignment(Align);
1720 Streamer.EmitLabel(fdeEnd);
1726 static const CIEKey getEmptyKey() {
1727 return CIEKey(
nullptr, 0, -1,
false,
false, static_cast<unsigned>(INT_MAX));
1730 static const CIEKey getTombstoneKey() {
1731 return CIEKey(
nullptr, -1, 0,
false,
false, static_cast<unsigned>(INT_MAX));
1734 CIEKey(
const MCSymbol *Personality,
unsigned PersonalityEncoding,
1735 unsigned LSDAEncoding,
bool IsSignalFrame,
bool IsSimple,
1737 : Personality(Personality), PersonalityEncoding(PersonalityEncoding),
1738 LsdaEncoding(LSDAEncoding), IsSignalFrame(IsSignalFrame),
1739 IsSimple(IsSimple), RAReg(RAReg) {}
1748 unsigned PersonalityEncoding;
1749 unsigned LsdaEncoding;
1764 return static_cast<unsigned>(
1765 hash_combine(Key.Personality, Key.PersonalityEncoding, Key.LsdaEncoding,
1766 Key.IsSignalFrame, Key.IsSimple, Key.RAReg));
1769 static bool isEqual(
const CIEKey &LHS,
const CIEKey &RHS) {
1770 return LHS.Personality == RHS.Personality &&
1771 LHS.PersonalityEncoding == RHS.PersonalityEncoding &&
1772 LHS.LsdaEncoding == RHS.LsdaEncoding &&
1773 LHS.IsSignalFrame == RHS.IsSignalFrame &&
1774 LHS.IsSimple == RHS.IsSimple &&
1775 LHS.RAReg == RHS.RAReg;
1788 FrameEmitterImpl Emitter(IsEH, Streamer);
1794 bool SectionEmitted =
false;
1797 if (!SectionEmitted) {
1800 SectionEmitted =
true;
1802 NeedsEHFrameSection |=
1805 Emitter.EmitCompactUnwind(Frame);
1809 if (!NeedsEHFrameSection)
return;
1821 const MCSymbol *DummyDebugKey =
nullptr;
1823 for (
auto I = FrameArray.
begin(),
E = FrameArray.
end();
I !=
E;) {
1833 const MCSymbol *&CIEStart = IsEH ? CIEStarts[
Key] : DummyDebugKey;
1835 CIEStart = &Emitter.EmitCIE(Frame);
1837 Emitter.EmitFDE(*CIEStart, Frame,
I ==
E, *SectionStart);
1842 uint64_t AddrDelta) {
1858 if (AddrDelta == 0) {
1859 }
else if (
isUIntN(6, AddrDelta)) {
1860 uint8_t Opcode = dwarf::DW_CFA_advance_loc | AddrDelta;
1863 OS << uint8_t(dwarf::DW_CFA_advance_loc1);
1864 OS << uint8_t(AddrDelta);
1866 OS << uint8_t(dwarf::DW_CFA_advance_loc2);
1867 support::endian::write<uint16_t>(OS, AddrDelta,
E);
1870 OS << uint8_t(dwarf::DW_CFA_advance_loc4);
1871 support::endian::write<uint32_t>(OS, AddrDelta,
E);
static const MCExpr * forceExpAbs(MCStreamer &OS, const MCExpr *Expr)
const MCAsmInfo * getAsmInfo() const
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E)
constexpr bool isUInt< 32 >(uint64_t x)
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
Instances of this class represent a uniqued identifier for a section in the current translation unit...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static int getDataAlignmentFactor(MCStreamer &streamer)
unsigned FindBufferContainingLoc(SMLoc Loc) const
Return the ID of the buffer containing the specified location.
void EmitBytes(StringRef Data) override
Emit the bytes in Data into the output.
static CIEKey getTombstoneKey()
#define DWARF2_FLAG_PROLOGUE_END
static void Make(MCObjectStreamer *MCOS, MCSection *Section)
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Optional< StringRef > Source
The source code of the file.
Compute iterated dominance frontiers using a linear time algorithm.
void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, bool IsSectionRelative=false)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
MCSection * getDwarfLineSection() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
static bool FixedEncode(MCContext &Context, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta, raw_ostream &OS, uint32_t *Offset, uint32_t *Size)
Utility function to encode a Dwarf pair of LineDelta and AddrDeltas using fixed length operands...
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
virtual void EmitBytes(StringRef Data)
Emit the bytes in Data into the output.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
bool needsDwarfSectionOffsetDirective() const
static void EmitAdvanceLoc(MCObjectStreamer &Streamer, uint64_t AddrDelta)
MCSection * getDwarfLineStrSection() const
A raw_ostream that writes to an SmallVector or SmallString.
MCSection * getDwarfARangesSection() const
MCDwarfLineStr(MCContext &Ctx)
Construct an instance that can emit .debug_line_str (for use in a normal v5 line table).
uint16_t getDwarfVersion() const
static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
bool getSupportsCompactUnwindWithoutEHFrame() const
static void EmitGenDwarfInfo(MCStreamer *MCOS, const MCSymbol *AbbrevSectionSymbol, const MCSymbol *LineSectionSymbol, const MCSymbol *RangesSectionSymbol)
StringRef getDwarfDebugFlags()
std::vector< MCDwarfLineEntry > MCDwarfLineEntryCollection
static void Encode(MCContext &Context, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta, raw_ostream &OS)
Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
void EmitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, unsigned PointerSize)
std::vector< MCCFIInstruction > Instructions
const std::vector< MCGenDwarfLabelEntry > & getMCGenDwarfLabelEntries() const
MCContext & getContext() const
#define DWARF2_FLAG_IS_STMT
StringRef getDwarfDebugProducer()
virtual const MCExpr * getExprForPersonalitySymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth...
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionStartEndSyms, to avoid generating useless debug info for them...
Base class for the full range of assembler expressions which are needed for parsing.
uint8_t DWARF2LineRange
Range of line offsets in a special line info. opcode.
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
Tagged union holding either a T or a Error.
unsigned getCompactUnwindDwarfEHFrameOnly() const
static void emitFDESymbol(MCObjectStreamer &streamer, const MCSymbol &symbol, unsigned symbolEncoding, bool isEH)
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
MCSection * getDwarfFrameSection() const
const SmallVectorImpl< std::string > & getMCDwarfDirs(unsigned CUID=0)
bool hasAggressiveSymbolFolding() const
bool getOmitDwarfIfHaveCompactUnwind() const
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
StringRef str() const
Explicit conversion to StringRef.
Context object for machine code objects.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
static void EmitGenDwarfAbbrev(MCStreamer *MCOS)
void write(raw_ostream &OS) const
Utility for building string tables with deduplicated suffixes.
unsigned getDwarfCompileUnitID()
size_t add(CachedHashStringRef S)
Add a string to the builder.
const std::map< unsigned, MCDwarfLineTable > & getMCDwarfLineTables() const
Streaming object file generation interface.
bool doesDwarfUseRelocationsAcrossSections() const
Instances of this class represent the information from a dwarf .loc directive.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
MCSection * getCompactUnwindSection() const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
virtual void EmitBinaryData(StringRef Data)
Functionally identical to EmitBytes.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
unsigned getGenDwarfFileNumber()
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...
MCSymbol * getLabel() const
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
MCSection * getDwarfAbbrevSection() const
static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
static uint64_t SpecialAddr(MCDwarfLineTableParams Params, uint64_t op)
Given a special op, return the address skip amount (in units of DWARF2_LINE_MIN_INSN_LENGTH).
static unsigned getSizeForEncoding(MCStreamer &streamer, unsigned symbolEncoding)
Streaming machine code generation interface.
static unsigned getCIEVersion(bool IsEH, unsigned DwarfVersion)
static void EmitAbbrev(MCStreamer *MCOS, uint64_t Name, uint64_t Form)
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
uint8_t DWARF2LineOpcodeBase
First special line opcode - leave room for the standard opcodes.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
constexpr bool isUInt< 8 >(uint64_t x)
unsigned const MachineRegisterInfo * MRI
void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
unsigned getRegister2() const
void finalizeInOrder()
Finalize the string table without reording it.
#define DWARF2_FLAG_EPILOGUE_BEGIN
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
static void emitAbsValue(MCStreamer &OS, const MCExpr *Value, unsigned Size)
unsigned getFDEEncoding() const
static void EmitDwarfLineTable(MCObjectStreamer *MCOS, MCSection *Section, const MCLineSection::MCDwarfLineEntryCollection &LineEntries)
static void EmitGenDwarfAranges(MCStreamer *MCOS, const MCSymbol *InfoSectionSymbol)
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
OpType getOperation() const
const MCObjectFileInfo * getObjectFileInfo() const
#define DWARF2_FLAG_BASIC_BLOCK
bool doDwarfFDESymbolsUseAbsDiff() const
const MCDwarfLoc & getCurrentDwarfLoc()
StringRef parent_path(StringRef path, Style style=Style::native)
Get parent path.
unsigned PersonalityEncoding
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
static void emitOneV5FileEntry(MCStreamer *MCOS, const MCDwarfFile &DwarfFile, bool EmitMD5, bool HasSource, Optional< MCDwarfLineStr > &LineStr)
StringRef getValues() const
StringRef toStringRef(bool B)
Construct a string ref from a boolean.
int8_t DWARF2LineBase
Minimum line offset in a special line info.
StringRef get_separator(Style style=Style::native)
Return the preferred separator for this platform.
void generateCompactUnwindEncodings(MCAsmBackend *MAB)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0) override
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
raw_ostream & write(unsigned char C)
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir The compilation directory should be set with setComp...
unsigned getRegister() const
const SetVector< MCSection * > & getGenDwarfSectionSyms()
const std::vector< MCCFIInstruction > & getInitialFrameState() const
void Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params, MCSection *Section) const
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
static unsigned getHashValue(const CIEKey &Key)
void EmitCU(MCObjectStreamer *MCOS, MCDwarfLineTableParams Params, Optional< MCDwarfLineStr > &LineStr) const
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, MD5::MD5Result *Checksum, Optional< StringRef > Source, unsigned FileNumber=0)
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
unsigned getMinInstAlignment() const
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
static bool isEqual(const CIEKey &LHS, const CIEKey &RHS)
MCSymbol * getBeginSymbol()
const Triple & getTargetTriple() const
StringRef str()
Return a StringRef for the vector contents.
static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, raw_ostream &OS)
MCSection * getDwarfInfoSection() const
uint32_t CompactUnwindEncoding
static void EmitGenDwarfRanges(MCStreamer *MCOS)
This file contains constants used for implementing Dwarf debug support.
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
MCSection * getCurrentSectionOnly() const
static CIEKey getEmptyKey()
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
static void Emit(MCStreamer *MCOS)
iterator insert(iterator I, T &&Elt)
#define DWARF2_LINE_DEFAULT_IS_STMT
unsigned FindLineNumber(SMLoc Loc, unsigned BufferID=0) const
Find the line number for the specified location in the specified file.
bool isStackGrowthDirectionUp() const
True if target stack grow up.
static uint64_t ScaleAddrDelta(MCContext &Context, uint64_t AddrDelta)
Instances of this class represent the line information for the dwarf line table entries.
static void Emit(MCObjectStreamer *MCOS, MCDwarfLineTableParams Params)
static const MCExpr * MakeStartMinusEndExpr(const MCStreamer &MCOS, const MCSymbol &Start, const MCSymbol &End, int IntVal)
pointer data()
Return a pointer to the vector's buffer, even if empty().
static void EmitPersonality(MCStreamer &streamer, const MCSymbol &symbol, unsigned symbolEncoding)
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
static void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr, SMLoc &Loc)
const MCSymbol * Personality
static const MCExpr * makeStartPlusIntExpr(MCContext &Ctx, const MCSymbol &Start, int IntVal)
unsigned getCalleeSaveStackSlotSize() const
Get the callee-saved register stack slot size in bytes.
bool isLittleEndian() const
True if the target is little endian.
Manage the .debug_line_str section contents, if we use it.
constexpr bool isUInt< 16 >(uint64_t x)
void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
MD5::MD5Result * Checksum
The MD5 checksum, if there is one.
unsigned getRARegister() const
This method should return the register where the return address can be found.
MCSymbol * endSection(MCSection *Section)
StringRef getName() const
getName - Get the symbol name.
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void emitRef(MCStreamer *MCOS, StringRef Path)
Emit a reference to the string.
std::array< uint8_t, 16 > Bytes
const MCRegisterInfo * getRegisterInfo() const
LLVM Value Representation.
Generic interface to target specific assembler backends.
ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
uint64_t tell() const
tell - Return the current offset with the file.
static void emitEncodingByte(MCObjectStreamer &Streamer, unsigned Encoding)
This class implements an extremely fast bulk output stream that can only output to a stream...
void emitSection(MCStreamer *MCOS)
Emit the .debug_line_str section if appropriate.
static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH)
StringRef - Represent a constant reference to a string, i.e.
Instances of this class represent the name of the dwarf .file directive and its associated dwarf file...
MCSection * getDwarfRangesSection() const
void EmitULEB128IntValue(uint64_t Value)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Represents a location in source code.
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
virtual const MCExpr * getExprForFDESymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...