LLVM: lib/MC/MCDwarf.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

17#include "llvm/Config/config.h"

35#include

36#include

37#include

38#include

39#include

40#include

41

42using namespace llvm;

43

51 }

60 S.AddComment("Segment selector size");

62 return End;

63}

64

66 unsigned MinInsnLength = Context.getAsmInfo()->getMinInstAlignment();

67 if (MinInsnLength == 1)

68 return AddrDelta;

69 if (AddrDelta % MinInsnLength != 0) {

70

71 ;

72 }

73 return AddrDelta / MinInsnLength;

74}

75

77 UseRelocs = Ctx.getAsmInfo()->doesDwarfUseRelocationsAcrossSections();

78 if (UseRelocs) {

80 Ctx.getObjectFileInfo()->getDwarfLineStrSection();

81 assert(DwarfLineStrSection && "DwarfLineStrSection must not be NULL");

83 }

84}

85

86

87

88

89

90

93 return;

94

95

97

99

100

102

103

105

106

108

109

114}

115

116

117

118

122 int IntVal) {

128 return Res3;

129}

130

131

132

133

134static inline const MCExpr *

141

144

145

146

147

148

149

150

151

152

153 auto I = MCLineDivisions.find(Sec);

154 if (I == MCLineDivisions.end())

155 return;

156

157 auto &Entries = I->second;

158

159 if (Entries.empty())

160 return;

161

162

164

165

166

167

168

171 Entries.push_back(EndEntry);

172}

173

174

175

176

177

181

182 unsigned FileNum, LastLine, Column, Flags, Isa, Discriminator;

183 bool IsAtStartSeq;

185 auto init = [&]() {

186 FileNum = 1;

187 LastLine = 1;

188 Column = 0;

190 Isa = 0;

191 Discriminator = 0;

192 PrevLabel = nullptr;

193 IsAtStartSeq = true;

194 };

195 init();

196

197

198 bool EndEntryEmitted = false;

199 for (auto It = LineEntries.begin(); It != LineEntries.end(); ++It) {

200 auto LineEntry = *It;

201 MCSymbol *CurrLabel = LineEntry.getLabel();

203

204 if (LineEntry.LineStreamLabel) {

205 if (!IsAtStartSeq) {

206 auto *Label = CurrLabel;

207 auto NextIt = It + 1;

208

209

210

211

212 if (!Label && NextIt != LineEntries.end()) {

213 Label = NextIt->getLabel();

214 }

216 Label);

217 init();

218 }

219 MCOS->emitLabel(LineEntry.LineStreamLabel, LineEntry.StreamLabelDefLoc);

220 continue;

221 }

222

223 if (LineEntry.IsEndEntry) {

226 init();

227 EndEntryEmitted = true;

228 continue;

229 }

230

231 int64_t LineDelta = static_cast<int64_t>(LineEntry.getLine()) - LastLine;

232

233 if (FileNum != LineEntry.getFileNum()) {

234 FileNum = LineEntry.getFileNum();

235 MCOS->emitInt8(dwarf::DW_LNS_set_file);

237 }

238 if (Column != LineEntry.getColumn()) {

239 Column = LineEntry.getColumn();

240 MCOS->emitInt8(dwarf::DW_LNS_set_column);

242 }

243 if (Discriminator != LineEntry.getDiscriminator() &&

245 Discriminator = LineEntry.getDiscriminator();

247 MCOS->emitInt8(dwarf::DW_LNS_extended_op);

249 MCOS->emitInt8(dwarf::DW_LNE_set_discriminator);

251 }

252 if (Isa != LineEntry.getIsa()) {

253 Isa = LineEntry.getIsa();

254 MCOS->emitInt8(dwarf::DW_LNS_set_isa);

256 }

258 Flags = LineEntry.getFlags();

259 MCOS->emitInt8(dwarf::DW_LNS_negate_stmt);

260 }

262 MCOS->emitInt8(dwarf::DW_LNS_set_basic_block);

264 MCOS->emitInt8(dwarf::DW_LNS_set_prologue_end);

266 MCOS->emitInt8(dwarf::DW_LNS_set_epilogue_begin);

267

268

269

270

273

274 Discriminator = 0;

275 LastLine = LineEntry.getLine();

276 PrevLabel = CurrLabel;

277 IsAtStartSeq = false;

278 }

279

280

281

282

283

284

285 if (!EndEntryEmitted && !IsAtStartSeq)

287}

288

294 auto *LineSym = ctx.createTempSymbol();

296 const MCDwarfLoc &DwarfLoc = ctx.getCurrentDwarfLoc();

297

298

299

300

301 MCDwarfLineEntry LineEntry(LineSym, DwarfLoc, LineStreamLabel, DefLoc);

303}

304

305

306

307

310

312

313

314

315 if (LineTables.empty())

316 return;

317

318

319 std::optional LineStr;

321 LineStr.emplace(context);

322

323

325

326

327 for (const auto &CUIDTablePair : LineTables) {

328 CUIDTablePair.second.emitCU(MCOS, Params, LineStr);

329 }

330

331 if (LineStr)

332 LineStr->emitSection(MCOS);

333}

334

337 if (!HasSplitLineTable)

338 return;

339 std::optional NoLineStr(std::nullopt);

341 MCOS.emitLabel(Header.Emit(&MCOS, Params, {}, NoLineStr).second);

342}

343

344std::pair<MCSymbol *, MCSymbol *>

346 std::optional &LineStr) const {

347 static const char StandardOpcodeLengths[] = {

348 0,

349 1,

350 1,

351 1,

352 1,

353 0,

354 0,

355 0,

356 1,

357 0,

358 0,

359 1

360 };

361 assert(std::size(StandardOpcodeLengths) >=

363 return Emit(MCOS, Params,

365 LineStr);

366}

367

371 if (!Context.getAsmInfo()->doesSetDirectiveSuppressReloc())

372 return Expr;

373

374

375 MCSymbol *ABS = Context.createTempSymbol();

378}

379

384

392

394

395 if (!LineStrings.isFinalized())

396 LineStrings.finalizeInOrder();

398 Data.resize(LineStrings.getSize());

399 LineStrings.write((uint8_t *)Data.data());

401}

402

404 return LineStrings.add(Path);

405}

406

408 int RefSize =

411 if (UseRelocs) {

413 if (Ctx.getAsmInfo()->needsDwarfSectionOffsetDirective()) {

415 } else {

417 RefSize);

418 }

419 } else

421}

422

423void MCDwarfLineTableHeader::emitV2FileDirTables(MCStreamer *MCOS) const {

424

426 MCOS->emitBytes(Dir);

428 }

429 MCOS->emitInt8(0);

430

431

432 for (unsigned i = 1; i < MCDwarfFiles.size(); i++) {

437 MCOS->emitInt8(0);

438 MCOS->emitInt8(0);

439 }

440 MCOS->emitInt8(0);

441}

442

444 bool EmitMD5, bool HasAnySource,

445 std::optional &LineStr) {

447 if (LineStr)

448 LineStr->emitRef(MCOS, DwarfFile.Name);

449 else {

452 }

454 if (EmitMD5) {

457 StringRef(reinterpret_cast<const char *>(Cksum.data()), Cksum.size()));

458 }

459 if (HasAnySource) {

460

461

463

464

466 Source = "\n";

467 if (LineStr)

468 LineStr->emitRef(MCOS, Source);

469 else {

470 MCOS->emitBytes(Source);

472 }

473 }

474}

475

476void MCDwarfLineTableHeader::emitV5FileDirTables(

477 MCStreamer *MCOS, std::optional &LineStr) const {

478

479

480

484 : dwarf::DW_FORM_string);

486

487 SmallString<256> Dir;

492 CompDir = Dir.str();

493 if (LineStr)

494 CompDir = LineStr->getSaver().save(CompDir);

495 }

496 if (LineStr) {

497

498 LineStr->emitRef(MCOS, CompDir);

500 LineStr->emitRef(MCOS, Dir);

501 } else {

502

504 MCOS->emitBytes(StringRef("\0", 1));

506 MCOS->emitBytes(Dir);

507 MCOS->emitBytes(StringRef("\0", 1));

508 }

509 }

510

511

512

513

514 uint64_t Entries = 2;

515 if (HasAllMD5)

516 Entries += 1;

518 Entries += 1;

522 : dwarf::DW_FORM_string);

525 if (HasAllMD5) {

528 }

532 : dwarf::DW_FORM_string);

533 }

534

535

536

537

539

540

542 "No root file and no .file directives");

545 for (unsigned i = 1; i < MCDwarfFiles.size(); ++i)

547}

548

549std::pair<MCSymbol *, MCSymbol *>

552 std::optional &LineStr) const {

554

555

557 if (!LineStartSym)

559

560

562

564

566

567

569 MCOS->emitInt16(LineTableVersion);

570

571

572 if (LineTableVersion >= 5) {

574 MCOS->emitInt8(0);

575 }

576

577

580

581

582

584

586

587

589

590

591

592 if (LineTableVersion >= 4)

597 MCOS->emitInt8(StandardOpcodeLengths.size() + 1);

598

599

600 for (char Length : StandardOpcodeLengths)

602

603

604

605 if (LineTableVersion >= 5)

606 emitV5FileDirTables(MCOS, LineStr);

607 else

608 emitV2FileDirTables(MCOS);

609

610

611

613

614 return std::make_pair(LineStartSym, LineEndSym);

615}

616

618 std::optional &LineStr) const {

619 MCSymbol *LineEndSym = Header.Emit(MCOS, Params, LineStr).second;

620

621

622 for (const auto &LineSec : MCLineSections.getMCLineEntries())

623 emitOne(MCOS, LineSec.first, LineSec.second);

624

625

626

628}

629

632 std::optionalMD5::MD5Result Checksum,

633 std::optional Source,

634 uint16_t DwarfVersion, unsigned FileNumber) {

635 return Header.tryGetFile(Directory, FileName, Checksum, Source, DwarfVersion,

636 FileNumber);

637}

638

641 std::optionalMD5::MD5Result Checksum) {

642 if (RootFile.Name.empty() || StringRef(RootFile.Name) != FileName)

643 return false;

644 return RootFile.Checksum == Checksum;

645}

646

649 std::optionalMD5::MD5Result Checksum,

650 std::optional Source,

651 uint16_t DwarfVersion, unsigned FileNumber) {

653 Directory = "";

654 if (FileName.empty()) {

655 FileName = "";

656 Directory = "";

657 }

659

660

664 }

665 if (DwarfVersion >= 5 && isRootFile(RootFile, Directory, FileName, Checksum))

666 return 0;

667 if (FileNumber == 0) {

668

669

673 std::make_pair((Directory + Twine('\0') + FileName).toStringRef(Buffer),

674 FileNumber));

675 if (!IterBool.second)

676 return IterBool.first->second;

677 }

678

681

682

684

685

686 if (!File.Name.empty())

689

690 if (Directory.empty()) {

691

693 if (!tFileName.empty()) {

695 if (!Directory.empty())

696 FileName = tFileName;

697 }

698 }

699

700

701

702 unsigned DirIndex;

703 if (Directory.empty()) {

704

705 DirIndex = 0;

706 } else {

709 MCDwarfDirs.push_back(std::string(Directory));

710

711

712

713

714 DirIndex++;

715 }

716

717 File.Name = std::string(FileName);

718 File.DirIndex = DirIndex;

719 File.Checksum = Checksum;

721 File.Source = Source;

722 if (Source.has_value())

724

725

726 return FileNumber;

727}

728

729

731 int64_t LineDelta, uint64_t AddrDelta) {

736}

737

738

739

743

744

746 int64_t LineDelta, uint64_t AddrDelta,

750 bool NeedCopy = false;

751

752

754

755

757

758

759

760

762 if (AddrDelta == MaxSpecialAddrDelta)

763 Out.push_back(dwarf::DW_LNS_const_add_pc);

764 else if (AddrDelta) {

765 Out.push_back(dwarf::DW_LNS_advance_pc);

767 }

768 Out.push_back(dwarf::DW_LNS_extended_op);

770 Out.push_back(dwarf::DW_LNE_end_sequence);

771 return;

772 }

773

774

776

777

778

781 Out.push_back(dwarf::DW_LNS_advance_line);

783

784 LineDelta = 0;

786 NeedCopy = true;

787 }

788

789

790 if (LineDelta == 0 && AddrDelta == 0) {

791 Out.push_back(dwarf::DW_LNS_copy);

792 return;

793 }

794

795

797

798

799 if (AddrDelta < 256 + MaxSpecialAddrDelta) {

800

802 if (Opcode <= 255) {

804 return;

805 }

806

807

808 Opcode = Temp + (AddrDelta - MaxSpecialAddrDelta) * Params.DWARF2LineRange;

809 if (Opcode <= 255) {

810 Out.push_back(dwarf::DW_LNS_const_add_pc);

812 return;

813 }

814 }

815

816

817 Out.push_back(dwarf::DW_LNS_advance_pc);

819

820 if (NeedCopy)

821 Out.push_back(dwarf::DW_LNS_copy);

822 else {

823 assert(Temp <= 255 && "Buggy special opcode encoding.");

825 }

826}

827

828

833

834

835

839

840

846 ? dwarf::DW_FORM_sec_offset

848 : dwarf::DW_FORM_data4);

849 EmitAbbrev(MCOS, dwarf::DW_AT_stmt_list, SecOffsetForm);

852 EmitAbbrev(MCOS, dwarf::DW_AT_ranges, SecOffsetForm);

853 } else {

854 EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr);

855 EmitAbbrev(MCOS, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr);

856 }

857 EmitAbbrev(MCOS, dwarf::DW_AT_name, dwarf::DW_FORM_string);

859 EmitAbbrev(MCOS, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string);

861 if (!DwarfDebugFlags.empty())

862 EmitAbbrev(MCOS, dwarf::DW_AT_APPLE_flags, dwarf::DW_FORM_string);

863 EmitAbbrev(MCOS, dwarf::DW_AT_producer, dwarf::DW_FORM_string);

864 EmitAbbrev(MCOS, dwarf::DW_AT_language, dwarf::DW_FORM_data2);

866

867

871 EmitAbbrev(MCOS, dwarf::DW_AT_name, dwarf::DW_FORM_string);

872 EmitAbbrev(MCOS, dwarf::DW_AT_decl_file, dwarf::DW_FORM_data4);

873 EmitAbbrev(MCOS, dwarf::DW_AT_decl_line, dwarf::DW_FORM_data4);

874 EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr);

876

877

879}

880

881

882

883

884

886 const MCSymbol *InfoSectionSymbol) {

888

890

892

893 unsigned UnitLengthBytes =

896

897

898

899 int Length = UnitLengthBytes + 2 + OffsetSize + 1 + 1;

900

901

902

905 int Pad = 2 * AddrSize - (Length & (2 * AddrSize - 1));

906 if (Pad == 2 * AddrSize)

907 Pad = 0;

909

910

911

912 Length += 2 * AddrSize * Sections.size();

913

914 Length += 2 * AddrSize;

915

916

918

920

921

923

925

926

927 if (InfoSectionSymbol)

930 else

932

934

936

937 for(int i = 0; i < Pad; i++)

939

940

941

942 for (MCSection *Sec : Sections) {

943 const MCSymbol *StartSymbol = Sec->getBeginSymbol();

944 MCSymbol *EndSymbol = Sec->getEndSymbol(context);

945 assert(StartSymbol && "StartSymbol must not be NULL");

946 assert(EndSymbol && "EndSymbol must not be NULL");

947

953 }

954

955

958}

959

960

961

962

964 const MCSymbol *AbbrevSectionSymbol,

965 const MCSymbol *LineSectionSymbol,

966 const MCSymbol *RangesSymbol) {

968

970

971

972

976

977

978

979 unsigned UnitLengthBytes =

982

984

986

987

988

992

993

995

996

997

1001 MCOS->emitInt8(dwarf::DW_UT_compile);

1003 }

1004

1005

1006 if (AbbrevSectionSymbol)

1009 else

1010

1014

1015

1016

1017

1019

1020

1021

1022 if (LineSectionSymbol)

1025 else

1026

1028

1029 if (RangesSymbol) {

1030

1031

1032

1034 } else {

1035

1036

1037

1038

1040 const auto TextSection = Sections.begin();

1041 assert(TextSection != Sections.end() && "No text section found");

1042

1043 MCSymbol *StartSymbol = (*TextSection)->getBeginSymbol();

1044 MCSymbol *EndSymbol = (*TextSection)->getEndSymbol(context);

1045 assert(StartSymbol && "StartSymbol must not be NULL");

1046 assert(EndSymbol && "EndSymbol must not be NULL");

1047

1048

1050 MCOS->emitValue(Start, AddrSize);

1051

1052

1055 }

1056

1057

1058

1060 if (MCDwarfDirs.size() > 0) {

1061 MCOS->emitBytes(MCDwarfDirs[0]);

1063 }

1065

1066

1067 assert(MCDwarfFiles.empty() || MCDwarfFiles.size() >= 2);

1069 MCDwarfFiles.empty()

1071 : MCDwarfFiles[1];

1073 MCOS->emitInt8(0);

1074

1075

1078 MCOS->emitInt8(0);

1079 }

1080

1081

1083 if (!DwarfDebugFlags.empty()){

1084 MCOS->emitBytes(DwarfDebugFlags);

1085 MCOS->emitInt8(0);

1086 }

1087

1088

1090 if (!DwarfDebugProducer.empty())

1091 MCOS->emitBytes(DwarfDebugProducer);

1092 else

1093 MCOS->emitBytes(StringRef("llvm-mc (based on LLVM " PACKAGE_VERSION ")"));

1094 MCOS->emitInt8(0);

1095

1096

1097

1098 MCOS->emitInt16(dwarf::DW_LANG_Mips_Assembler);

1099

1100

1101

1102

1103 const std::vector &Entries =

1105 for (const auto &Entry : Entries) {

1106

1108

1109

1110 MCOS->emitBytes(Entry.getName());

1111 MCOS->emitInt8(0);

1112

1113

1114 MCOS->emitInt32(Entry.getFileNumber());

1115

1116

1117 MCOS->emitInt32(Entry.getLineNumber());

1118

1119

1121 MCOS->emitValue(AT_low_pc, AddrSize);

1122 }

1123

1124

1126

1127

1129}

1130

1131

1132

1133

1137

1141

1145 MCOS->AddComment("Offset entry count");

1147 RangesSymbol = context.createTempSymbol("debug_rnglist0_start");

1149 for (MCSection *Sec : Sections) {

1150 const MCSymbol *StartSymbol = Sec->getBeginSymbol();

1151 const MCSymbol *EndSymbol = Sec->getEndSymbol(context);

1152 const MCExpr *SectionStartAddr =

1154 const MCExpr *SectionSize =

1156 MCOS->emitInt8(dwarf::DW_RLE_start_length);

1157 MCOS->emitValue(SectionStartAddr, AddrSize);

1159 }

1160 MCOS->emitInt8(dwarf::DW_RLE_end_of_list);

1162 } else {

1164 RangesSymbol = context.createTempSymbol("debug_ranges_start");

1166 for (MCSection *Sec : Sections) {

1167 const MCSymbol *StartSymbol = Sec->getBeginSymbol();

1168 const MCSymbol *EndSymbol = Sec->getEndSymbol(context);

1169

1170

1171 const MCExpr *SectionStartAddr =

1173 MCOS->emitFill(AddrSize, 0xFF);

1174 MCOS->emitValue(SectionStartAddr, AddrSize);

1175

1176

1177 const MCExpr *SectionSize =

1181 }

1182

1183

1186 }

1187

1188 return RangesSymbol;

1189}

1190

1191

1192

1193

1194

1197

1198

1200 bool CreateDwarfSectionSymbols =

1202 MCSymbol *LineSectionSymbol = nullptr;

1203 if (CreateDwarfSectionSymbols)

1205 MCSymbol *AbbrevSectionSymbol = nullptr;

1206 MCSymbol *InfoSectionSymbol = nullptr;

1207 MCSymbol *RangesSymbol = nullptr;

1208

1209

1211

1212

1213

1215 return;

1216

1217

1218

1219 const bool UseRangesSection =

1222 CreateDwarfSectionSymbols |= UseRangesSection;

1223

1225 if (CreateDwarfSectionSymbols) {

1227 MCOS->emitLabel(InfoSectionSymbol);

1228 }

1230 if (CreateDwarfSectionSymbols) {

1232 MCOS->emitLabel(AbbrevSectionSymbol);

1233 }

1234

1236

1237

1239

1240 if (UseRangesSection) {

1242 assert(RangesSymbol);

1243 }

1244

1245

1247

1248

1249 EmitGenDwarfInfo(MCOS, AbbrevSectionSymbol, LineSectionSymbol, RangesSymbol);

1250}

1251

1252

1253

1254

1255

1256

1257

1260

1261 if (Symbol->isTemporary())

1262 return;

1264

1265

1267 return;

1268

1269

1270

1271 StringRef Name = Symbol->getName();

1272 if (Name.starts_with("_"))

1273 Name = Name.substr(1, Name.size()-1);

1274

1275

1277

1278

1279

1280 unsigned CurBuffer = SrcMgr.FindBufferContainingLoc(Loc);

1281 unsigned LineNumber = SrcMgr.FindLineNumber(Loc, CurBuffer);

1282

1283

1284

1285

1286

1289

1290

1293}

1294

1300 return size;

1301 else

1302 return -size;

1303}

1304

1306 unsigned symbolEncoding) {

1308 unsigned format = symbolEncoding & 0x0f;

1316 return 2;

1319 return 4;

1322 return 8;

1323 }

1324}

1325

1327 unsigned symbolEncoding, bool isEH) {

1331 symbolEncoding,

1332 streamer);

1336 else

1338}

1339

1341 unsigned symbolEncoding) {

1345 symbolEncoding,

1346 streamer);

1349}

1350

1351namespace {

1352

1353class FrameEmitterImpl {

1354 int64_t CFAOffset = 0;

1355 int64_t InitialCFAOffset = 0;

1356 bool IsEH;

1357 MCObjectStreamer &Streamer;

1358

1359public:

1360 FrameEmitterImpl(bool IsEH, MCObjectStreamer &Streamer)

1361 : IsEH(IsEH), Streamer(Streamer) {}

1362

1363

1364 void EmitCompactUnwind(const MCDwarfFrameInfo &frame);

1365

1366 const MCSymbol &EmitCIE(const MCDwarfFrameInfo &F);

1367 void EmitFDE(const MCSymbol &cieStart, const MCDwarfFrameInfo &frame,

1368 bool LastInSection, const MCSymbol &SectionStart);

1370 MCSymbol *BaseLabel);

1371 void emitCFIInstruction(const MCCFIInstruction &Instr);

1372};

1373

1374}

1375

1379

1380void FrameEmitterImpl::emitCFIInstruction(const MCCFIInstruction &Instr) {

1382 auto *MRI = Streamer.getContext().getRegisterInfo();

1383

1384 switch (Instr.getOperation()) {

1386 unsigned Reg1 = Instr.getRegister();

1387 unsigned Reg2 = Instr.getRegister2();

1388 if (!IsEH) {

1389 Reg1 = MRI->getDwarfRegNumFromDwarfEHRegNum(Reg1);

1390 Reg2 = MRI->getDwarfRegNumFromDwarfEHRegNum(Reg2);

1391 }

1392 Streamer.emitInt8(dwarf::DW_CFA_register);

1393 Streamer.emitULEB128IntValue(Reg1);

1394 Streamer.emitULEB128IntValue(Reg2);

1395 return;

1396 }

1398 Streamer.emitInt8(dwarf::DW_CFA_GNU_window_save);

1399 return;

1400

1402 Streamer.emitInt8(dwarf::DW_CFA_AARCH64_negate_ra_state);

1403 return;

1404

1406 Streamer.emitInt8(dwarf::DW_CFA_AARCH64_negate_ra_state_with_pc);

1407 return;

1408

1410 unsigned Reg = Instr.getRegister();

1411 Streamer.emitInt8(dwarf::DW_CFA_undefined);

1412 Streamer.emitULEB128IntValue(Reg);

1413 return;

1414 }

1417 const bool IsRelative =

1419

1420 Streamer.emitInt8(dwarf::DW_CFA_def_cfa_offset);

1421

1422 if (IsRelative)

1423 CFAOffset += Instr.getOffset();

1424 else

1425 CFAOffset = Instr.getOffset();

1426

1427 Streamer.emitULEB128IntValue(CFAOffset);

1428

1429 return;

1430 }

1432 unsigned Reg = Instr.getRegister();

1433 if (!IsEH)

1434 Reg = MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);

1435 Streamer.emitInt8(dwarf::DW_CFA_def_cfa);

1436 Streamer.emitULEB128IntValue(Reg);

1437 CFAOffset = Instr.getOffset();

1438 Streamer.emitULEB128IntValue(CFAOffset);

1439

1440 return;

1441 }

1443 unsigned Reg = Instr.getRegister();

1444 if (!IsEH)

1445 Reg = MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);

1446 Streamer.emitInt8(dwarf::DW_CFA_def_cfa_register);

1447 Streamer.emitULEB128IntValue(Reg);

1448

1449 return;

1450 }

1451

1453 unsigned Reg = Instr.getRegister();

1454 if (!IsEH)

1455 Reg = MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);

1456 Streamer.emitIntValue(dwarf::DW_CFA_LLVM_def_aspace_cfa, 1);

1457 Streamer.emitULEB128IntValue(Reg);

1458 CFAOffset = Instr.getOffset();

1459 Streamer.emitULEB128IntValue(CFAOffset);

1460 Streamer.emitULEB128IntValue(Instr.getAddressSpace());

1461

1462 return;

1463 }

1466 const bool IsRelative =

1468

1469 unsigned Reg = Instr.getRegister();

1470 if (!IsEH)

1471 Reg = MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);

1472

1474 if (IsRelative)

1475 Offset -= CFAOffset;

1477

1479 Streamer.emitInt8(dwarf::DW_CFA_offset_extended_sf);

1480 Streamer.emitULEB128IntValue(Reg);

1481 Streamer.emitSLEB128IntValue(Offset);

1482 } else if (Reg < 64) {

1483 Streamer.emitInt8(dwarf::DW_CFA_offset + Reg);

1484 Streamer.emitULEB128IntValue(Offset);

1485 } else {

1486 Streamer.emitInt8(dwarf::DW_CFA_offset_extended);

1487 Streamer.emitULEB128IntValue(Reg);

1488 Streamer.emitULEB128IntValue(Offset);

1489 }

1490 return;

1491 }

1493 Streamer.emitInt8(dwarf::DW_CFA_remember_state);

1494 return;

1496 Streamer.emitInt8(dwarf::DW_CFA_restore_state);

1497 return;

1499 unsigned Reg = Instr.getRegister();

1500 Streamer.emitInt8(dwarf::DW_CFA_same_value);

1501 Streamer.emitULEB128IntValue(Reg);

1502 return;

1503 }

1505 unsigned Reg = Instr.getRegister();

1506 if (!IsEH)

1507 Reg = MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);

1508 if (Reg < 64) {

1509 Streamer.emitInt8(dwarf::DW_CFA_restore | Reg);

1510 } else {

1511 Streamer.emitInt8(dwarf::DW_CFA_restore_extended);

1512 Streamer.emitULEB128IntValue(Reg);

1513 }

1514 return;

1515 }

1517 Streamer.emitInt8(dwarf::DW_CFA_GNU_args_size);

1518 Streamer.emitULEB128IntValue(Instr.getOffset());

1519 return;

1520

1522 Streamer.emitBytes(Instr.getValues());

1523 return;

1525 Streamer.emitLabel(Instr.getCfiLabel(), Instr.getLoc());

1526 return;

1528 unsigned Reg = Instr.getRegister();

1529 if (!IsEH)

1530 Reg = MRI->getDwarfRegNumFromDwarfEHRegNum(Reg);

1531

1534

1536 Streamer.emitInt8(dwarf::DW_CFA_val_offset_sf);

1537 Streamer.emitULEB128IntValue(Reg);

1538 Streamer.emitSLEB128IntValue(Offset);

1539 } else {

1540 Streamer.emitInt8(dwarf::DW_CFA_val_offset);

1541 Streamer.emitULEB128IntValue(Reg);

1542 Streamer.emitULEB128IntValue(Offset);

1543 }

1544 return;

1545 }

1546 }

1548}

1549

1550

1555

1556 if (Label && Label->isDefined()) continue;

1557

1558

1559 if (BaseLabel && Label) {

1561 if (ThisSym != BaseLabel) {

1562 Streamer.emitDwarfAdvanceFrameAddr(BaseLabel, ThisSym, Instr.getLoc());

1563 BaseLabel = ThisSym;

1564 }

1565 }

1566

1567 emitCFIInstruction(Instr);

1568 }

1569}

1570

1571

1572void FrameEmitterImpl::EmitCompactUnwind(const MCDwarfFrameInfo &Frame) {

1575

1576

1577

1578

1579

1580

1581

1582

1583

1584

1585

1586

1587

1588

1589

1590

1591

1592

1593

1594

1595

1596

1597

1599 if (!Encoding) return;

1601

1602

1603 if (!DwarfEHFrameOnly && Frame.Lsda)

1604 Encoding |= 0x40000000;

1605

1606

1609 Streamer.emitSymbolValue(Frame.Begin, Size);

1610

1611

1615

1616

1618 Streamer.emitIntValue(Encoding, Size);

1619

1620

1622 if (!DwarfEHFrameOnly && Frame.Personality)

1624 else

1625 Streamer.emitIntValue(0, Size);

1626

1627

1629 if (!DwarfEHFrameOnly && Frame.Lsda)

1630 Streamer.emitSymbolValue(Frame.Lsda, Size);

1631 else

1632 Streamer.emitIntValue(0, Size);

1633}

1634

1635static unsigned getCIEVersion(bool IsEH, unsigned DwarfVersion) {

1636 if (IsEH)

1637 return 1;

1638 switch (DwarfVersion) {

1639 case 2:

1640 return 1;

1641 case 3:

1642 return 3;

1643 case 4:

1644 case 5:

1645 return 4;

1646 }

1648}

1649

1651 MCContext &context = Streamer.getContext();

1654

1656 Streamer.emitLabel(sectionStart);

1657

1659

1664

1665 if (IsDwarf64)

1666

1668

1669

1671 *sectionEnd, UnitLengthBytes);

1673

1674

1675 uint64_t CIE_ID =

1677 Streamer.emitIntValue(CIE_ID, OffsetSize);

1678

1679

1681 Streamer.emitInt8(CIEVersion);

1682

1683 if (IsEH) {

1685 Augmentation += "z";

1687 Augmentation += "P";

1688 if (Frame.Lsda)

1689 Augmentation += "L";

1690 Augmentation += "R";

1692 Augmentation += "S";

1694 Augmentation += "B";

1696 Augmentation += "G";

1697 Streamer.emitBytes(Augmentation);

1698 }

1699 Streamer.emitInt8(0);

1700

1701 if (CIEVersion >= 4) {

1702

1704

1705

1706 Streamer.emitInt8(0);

1707 }

1708

1709

1711

1712

1714

1715

1717 if (RAReg == static_cast<unsigned>(INT_MAX))

1718 RAReg = MRI->getDwarfRegNum(MRI->getRARegister(), IsEH);

1719

1720 if (CIEVersion == 1) {

1722 "DWARF 2 encodes return_address_register in one byte");

1723 Streamer.emitInt8(RAReg);

1724 } else {

1725 Streamer.emitULEB128IntValue(RAReg);

1726 }

1727

1728

1729 unsigned augmentationLength = 0;

1730 if (IsEH) {

1732

1733 augmentationLength += 1;

1734

1735 augmentationLength +=

1737 }

1738 if (Frame.Lsda)

1739 augmentationLength += 1;

1740

1741 augmentationLength += 1;

1742

1743 Streamer.emitULEB128IntValue(augmentationLength);

1744

1745

1747

1749

1751 }

1752

1753 if (Frame.Lsda)

1755

1756

1758 }

1759

1760

1761

1764 const std::vector &Instructions =

1766 emitCFIInstructions(Instructions, nullptr);

1767 }

1768

1769 InitialCFAOffset = CFAOffset;

1770

1771

1773

1774 Streamer.emitLabel(sectionEnd);

1775 return *sectionStart;

1776}

1777

1778void FrameEmitterImpl::EmitFDE(const MCSymbol &cieStart,

1780 bool LastInSection,

1781 const MCSymbol &SectionStart) {

1782 MCContext &context = Streamer.getContext();

1786

1787 CFAOffset = InitialCFAOffset;

1788

1791

1793

1795

1796

1799

1800 Streamer.emitLabel(fdeStart);

1801

1802

1804 if (IsEH) {

1805 const MCExpr *offset =

1809 const MCExpr *offset =

1812 } else {

1813 Streamer.emitSymbolValue(&cieStart, OffsetSize,

1815 }

1816

1817

1818 unsigned PCEncoding =

1822

1823

1827

1828 if (IsEH) {

1829

1830 unsigned augmentationLength = 0;

1831

1832 if (frame.Lsda)

1834

1835 Streamer.emitULEB128IntValue(augmentationLength);

1836

1837

1838 if (frame.Lsda)

1840 }

1841

1842

1844

1845

1846

1847

1848

1849 unsigned Alignment = LastInSection ? asmInfo->getCodePointerSize() : PCSize;

1850 Streamer.emitValueToAlignment(Align(Alignment));

1851

1852 Streamer.emitLabel(fdeEnd);

1853}

1854

1855namespace {

1856

1857struct CIEKey {

1858 CIEKey() = default;

1859

1860 explicit CIEKey(const MCDwarfFrameInfo &Frame)

1861 : Personality(Frame.Personality),

1862 PersonalityEncoding(Frame.PersonalityEncoding),

1863 LsdaEncoding(Frame.LsdaEncoding), IsSignalFrame(Frame.IsSignalFrame),

1864 IsSimple(Frame.IsSimple), RAReg(Frame.RAReg),

1865 IsBKeyFrame(Frame.IsBKeyFrame),

1866 IsMTETaggedFrame(Frame.IsMTETaggedFrame) {}

1867

1868 StringRef PersonalityName() const {

1869 if (!Personality)

1870 return StringRef();

1871 return Personality->getName();

1872 }

1873

1875 return std::make_tuple(PersonalityName(), PersonalityEncoding, LsdaEncoding,

1876 IsSignalFrame, IsSimple, RAReg, IsBKeyFrame,

1877 IsMTETaggedFrame) <

1878 std::make_tuple(Other.PersonalityName(), Other.PersonalityEncoding,

1879 Other.LsdaEncoding, Other.IsSignalFrame,

1881 Other.IsMTETaggedFrame);

1882 }

1883

1885 return Personality == Other.Personality &&

1886 PersonalityEncoding == Other.PersonalityEncoding &&

1887 LsdaEncoding == Other.LsdaEncoding &&

1888 IsSignalFrame == Other.IsSignalFrame && IsSimple == Other.IsSimple &&

1889 RAReg == Other.RAReg && IsBKeyFrame == Other.IsBKeyFrame &&

1890 IsMTETaggedFrame == Other.IsMTETaggedFrame;

1891 }

1893

1894 const MCSymbol *Personality = nullptr;

1895 unsigned PersonalityEncoding = 0;

1896 unsigned LsdaEncoding = -1;

1897 bool IsSignalFrame = false;

1898 bool IsSimple = false;

1899 unsigned RAReg = UINT_MAX;

1900 bool IsBKeyFrame = false;

1901 bool IsMTETaggedFrame = false;

1902};

1903

1904}

1905

1907 bool IsEH) {

1910 const MCAsmInfo *AsmInfo = Context.getAsmInfo();

1911 FrameEmitterImpl Emitter(IsEH, Streamer);

1913

1914

1918 bool SectionEmitted = false;

1921 if (!SectionEmitted) {

1924 SectionEmitted = true;

1925 }

1926 NeedsEHFrameSection |=

1929 Emitter.EmitCompactUnwind(Frame);

1930 }

1931 }

1932

1933

1934

1935

1936

1937 if (!NeedsEHFrameSection && IsEH) return;

1938

1940 IsEH ? *const_cast<MCObjectFileInfo *>(MOFI)->getEHFrameSection()

1942

1944 MCSymbol *SectionStart = Context.createTempSymbol();

1945 Streamer.emitLabel(SectionStart);

1946

1948

1949

1950

1951

1952 std::vector FrameArrayX(FrameArray.begin(), FrameArray.end());

1955 return CIEKey(X) < CIEKey(Y);

1956 });

1957 CIEKey LastKey;

1958 const MCSymbol *LastCIEStart = nullptr;

1959 for (auto I = FrameArrayX.begin(), E = FrameArrayX.end(); I != E;) {

1961 ++I;

1964

1965

1966

1967

1968

1969

1970 continue;

1971

1972 CIEKey Key(Frame);

1973 if (!LastCIEStart || (IsEH && Key != LastKey)) {

1974 LastKey = Key;

1975 LastCIEStart = &Emitter.EmitCIE(Frame);

1976 }

1977

1978 Emitter.EmitFDE(*LastCIEStart, Frame, I == E, *SectionStart);

1979 }

1980}

1981

1985

1987 if (AddrDelta == 0)

1988 return;

1989

1993

1994 if (isUIntN(6, AddrDelta)) {

1995 uint8_t Opcode = dwarf::DW_CFA_advance_loc | AddrDelta;

1997 } else if (isUInt<8>(AddrDelta)) {

1998 Out.push_back(dwarf::DW_CFA_advance_loc1);

2001 Out.push_back(dwarf::DW_CFA_advance_loc2);

2003 } else {

2005 Out.push_back(dwarf::DW_CFA_advance_loc4);

2007 }

2008}

unsigned const MachineRegisterInfo * MRI

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

dxil DXContainer Global Emitter

This file contains constants used for implementing Dwarf debug support.

static void emitFDESymbol(MCObjectStreamer &streamer, const MCSymbol &symbol, unsigned symbolEncoding, bool isEH)

Definition MCDwarf.cpp:1326

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).

Definition MCDwarf.cpp:740

static void EmitGenDwarfAranges(MCStreamer *MCOS, const MCSymbol *InfoSectionSymbol)

Definition MCDwarf.cpp:885

static bool isRootFile(const MCDwarfFile &RootFile, StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum)

Definition MCDwarf.cpp:639

static uint64_t ScaleAddrDelta(MCContext &Context, uint64_t AddrDelta)

Definition MCDwarf.cpp:65

static const MCExpr * forceExpAbs(MCStreamer &OS, const MCExpr *Expr)

Definition MCDwarf.cpp:368

static void emitAbsValue(MCStreamer &OS, const MCExpr *Value, unsigned Size)

Definition MCDwarf.cpp:380

static void emitOneV5FileEntry(MCStreamer *MCOS, const MCDwarfFile &DwarfFile, bool EmitMD5, bool HasAnySource, std::optional< MCDwarfLineStr > &LineStr)

Definition MCDwarf.cpp:443

static const MCExpr * makeEndMinusStartExpr(MCContext &Ctx, const MCSymbol &Start, const MCSymbol &End, int IntVal)

Definition MCDwarf.cpp:119

static unsigned getCIEVersion(bool IsEH, unsigned DwarfVersion)

Definition MCDwarf.cpp:1635

static void EmitGenDwarfInfo(MCStreamer *MCOS, const MCSymbol *AbbrevSectionSymbol, const MCSymbol *LineSectionSymbol, const MCSymbol *RangesSymbol)

Definition MCDwarf.cpp:963

static void EmitAbbrev(MCStreamer *MCOS, uint64_t Name, uint64_t Form)

Definition MCDwarf.cpp:829

static void EmitPersonality(MCStreamer &streamer, const MCSymbol &symbol, unsigned symbolEncoding)

Definition MCDwarf.cpp:1340

static void emitEncodingByte(MCObjectStreamer &Streamer, unsigned Encoding)

Definition MCDwarf.cpp:1376

static int getDataAlignmentFactor(MCStreamer &streamer)

Definition MCDwarf.cpp:1295

static MCSymbol * emitGenDwarfRanges(MCStreamer *MCOS)

Definition MCDwarf.cpp:1134

static const MCExpr * makeStartPlusIntExpr(MCContext &Ctx, const MCSymbol &Start, int IntVal)

Definition MCDwarf.cpp:135

static void EmitGenDwarfAbbrev(MCStreamer *MCOS)

Definition MCDwarf.cpp:836

static unsigned getSizeForEncoding(MCStreamer &streamer, unsigned symbolEncoding)

Definition MCDwarf.cpp:1305

#define DWARF2_FLAG_IS_STMT

#define DWARF2_FLAG_BASIC_BLOCK

#define DWARF2_LINE_DEFAULT_IS_STMT

#define DWARF2_FLAG_PROLOGUE_END

#define DWARF2_FLAG_EPILOGUE_BEGIN

ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))

static constexpr MCPhysReg RAReg

This file defines the SmallString class.

This file defines the SmallVector class.

static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")

static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

size_t size() const

size - Get the array size.

Tagged union holding either a T or a Error.

Generic interface to target specific assembler backends.

This class is intended to be used as a base class for asm properties and features specific to the tar...

unsigned getMinInstAlignment() const

const std::vector< MCCFIInstruction > & getInitialFrameState() const

bool needsDwarfSectionOffsetDirective() const

bool doesDwarfUseRelocationsAcrossSections() const

virtual const MCExpr * getExprForFDESymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const

bool isStackGrowthDirectionUp() const

True if target stack grow up.

unsigned getCalleeSaveStackSlotSize() const

Get the callee-saved register stack slot size in bytes.

bool doDwarfFDESymbolsUseAbsDiff() const

virtual const MCExpr * getExprForPersonalitySymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const

unsigned getCodePointerSize() const

Get the code pointer size in bytes.

static LLVM_ABI const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())

static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)

Context object for machine code objects.

const MCObjectFileInfo * getObjectFileInfo() const

LLVM_ABI void remapDebugPath(SmallVectorImpl< char > &Path)

Remap one path in-place as per the debug prefix map.

const SetVector< MCSection * > & getGenDwarfSectionSyms()

const SmallVectorImpl< std::string > & getMCDwarfDirs(unsigned CUID=0)

StringRef getDwarfDebugProducer()

StringRef getDwarfDebugFlags()

LLVM_ABI MCSymbol * createTempSymbol()

Create a temporary symbol with a unique name.

StringRef getCompilationDir() const

Get the compilation directory for DW_AT_comp_dir The compilation directory should be set with setComp...

MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)

unsigned getDwarfCompileUnitID()

const MCRegisterInfo * getRegisterInfo() const

const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)

const std::map< unsigned, MCDwarfLineTable > & getMCDwarfLineTables() const

unsigned getGenDwarfFileNumber()

uint16_t getDwarfVersion() const

const MCAsmInfo * getAsmInfo() const

LLVM_ABI void finalizeDwarfSections(MCStreamer &MCOS)

Remove empty sections from SectionsForRanges, to avoid generating useless debug info for them.

void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E)

LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)

Lookup the symbol inside with the specified Name.

const MCDwarfLoc & getCurrentDwarfLoc()

dwarf::DwarfFormat getDwarfFormat() const

const std::vector< MCGenDwarfLabelEntry > & getMCGenDwarfLabelEntries() const

LLVM_ABI void Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params, MCSection *Section) const

Definition MCDwarf.cpp:335

static LLVM_ABI void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH)

Definition MCDwarf.cpp:1906

static LLVM_ABI void encodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, SmallVectorImpl< char > &OS)

Definition MCDwarf.cpp:1982

static LLVM_ABI void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)

Utility function to emit the encoding to a streamer.

Definition MCDwarf.cpp:730

static LLVM_ABI void encode(MCContext &Context, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta, SmallVectorImpl< char > &OS)

Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.

Definition MCDwarf.cpp:745

Instances of this class represent the line information for the dwarf line table entries.

void setEndLabel(MCSymbol *EndLabel)

MCDwarfLineEntry(MCSymbol *label, const MCDwarfLoc loc, MCSymbol *lineStreamLabel=nullptr, SMLoc streamLabelDefLoc={})

MCSymbol * LineStreamLabel

static LLVM_ABI void make(MCStreamer *MCOS, MCSection *Section)

Definition MCDwarf.cpp:91

LLVM_ABI void emitSection(MCStreamer *MCOS)

Emit the .debug_line_str section if appropriate.

Definition MCDwarf.cpp:385

LLVM_ABI MCDwarfLineStr(MCContext &Ctx)

Construct an instance that can emit .debug_line_str (for use in a normal v5 line table).

Definition MCDwarf.cpp:76

LLVM_ABI SmallString< 0 > getFinalizedData()

Returns finalized section.

Definition MCDwarf.cpp:393

LLVM_ABI void emitRef(MCStreamer *MCOS, StringRef Path)

Emit a reference to the string.

Definition MCDwarf.cpp:407

LLVM_ABI size_t addString(StringRef Path)

Adds path Path to the line string.

Definition MCDwarf.cpp:403

LLVM_ABI void endCurrentSeqAndEmitLineStreamLabel(MCStreamer *MCOS, SMLoc DefLoc, StringRef Name)

Definition MCDwarf.cpp:289

MCDwarfFile & getRootFile()

const MCLineSection & getMCLineSections() const

static LLVM_ABI void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params)

Definition MCDwarf.cpp:308

static LLVM_ABI void emitOne(MCStreamer *MCOS, MCSection *Section, const MCLineSection::MCDwarfLineEntryCollection &LineEntries)

Definition MCDwarf.cpp:178

LLVM_ABI Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)

Definition MCDwarf.cpp:631

LLVM_ABI void emitCU(MCStreamer *MCOS, MCDwarfLineTableParams Params, std::optional< MCDwarfLineStr > &LineStr) const

Definition MCDwarf.cpp:617

Instances of this class represent the information from a dwarf .loc directive.

Base class for the full range of assembler expressions which are needed for parsing.

static LLVM_ABI void Emit(MCStreamer *MCOS)

Definition MCDwarf.cpp:1195

MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber, MCSymbol *label)

static LLVM_ABI void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr, SMLoc &Loc)

Definition MCDwarf.cpp:1258

LLVM_ABI void addEndEntry(MCSymbol *EndLabel)

Definition MCDwarf.cpp:142

void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec)

std::vector< MCDwarfLineEntry > MCDwarfLineEntryCollection

MCSection * getDwarfRangesSection() const

bool getSupportsCompactUnwindWithoutEHFrame() const

MCSection * getDwarfLineStrSection() const

unsigned getCompactUnwindDwarfEHFrameOnly() const

MCSection * getDwarfRnglistsSection() const

MCSection * getDwarfLineSection() const

MCSection * getDwarfInfoSection() const

MCSection * getDwarfFrameSection() const

unsigned getFDEEncoding() const

MCSection * getDwarfAbbrevSection() const

bool getOmitDwarfIfHaveCompactUnwind() const

MCSection * getDwarfARangesSection() const

MCSection * getCompactUnwindSection() const

Streaming object file generation interface.

void emitValueToAlignment(Align Alignment, int64_t Fill=0, uint8_t FillLen=1, unsigned MaxBytesToEmit=0) override

Emit some number of copies of Value until the byte alignment ByteAlignment is reached.

void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override

Emit a label for Symbol into the current section.

MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...

Instances of this class represent a uniqued identifier for a section in the current translation unit.

MCSymbol * getBeginSymbol()

Streaming machine code generation interface.

virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)

Emit an assignment of Value to Symbol.

void generateCompactUnwindEncodings(MCAsmBackend *MAB)

virtual void emitBinaryData(StringRef Data)

Functionally identical to EmitBytes.

virtual void emitDwarfUnitLength(uint64_t Length, const Twine &Comment)

Emit a unit length field.

MCContext & getContext() const

virtual void AddComment(const Twine &T, bool EOL=true)

Add a textual comment.

virtual void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset)

Emits a COFF section relative relocation.

void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())

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.

virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)

Emit the debug line start label.

virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)

Emit the absolute difference between two symbols.

virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())

Emit a label for Symbol into the current section.

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.

virtual void emitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, unsigned PointerSize)

If targets does not support representing debug line section by .loc/.file directives in assembly outp...

void emitInt16(uint64_t Value)

virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)

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 emitULEB128Value(const MCExpr *Value)

ArrayRef< MCDwarfFrameInfo > getDwarfFrameInfos() const

virtual void switchSection(MCSection *Section, uint32_t Subsec=0)

Set the current section where code is being emitted to Section.

void emitInt32(uint64_t Value)

MCSection * getCurrentSectionOnly() const

virtual void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel, MCSymbol *EndLabel=nullptr)

Emit the debug line end entry.

void emitInt8(uint64_t Value)

void emitFill(uint64_t NumBytes, uint8_t FillValue)

Emit NumBytes bytes worth of the value specified by FillValue.

virtual void emitBytes(StringRef Data)

Emit the bytes in Data into the output.

static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

MCSection & getSection() const

Get the section associated with a defined, non-absolute symbol.

Represents a location in source code.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

StringRef str() const

Explicit conversion to StringRef.

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

void append(ItTy in_start, ItTy in_end)

Add the specified range to the end of the SmallVector.

void push_back(const T &Elt)

This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.

StringRef - Represent a constant reference to a string, i.e.

constexpr StringRef substr(size_t Start, size_t N=npos) const

Return a reference to the substring from [Start, Start + N).

constexpr bool empty() const

empty - Check if the string is empty.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

LLVM Value Representation.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

const uint32_t DW_CIE_ID

Special ID values that distinguish a CIE from a FDE in DWARF CFI.

uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)

Get the byte size of the unit length field depending on the DWARF format.

const uint64_t DW64_CIE_ID

DwarfFormat

Constants that define the DWARF format as 32 or 64 bit.

uint8_t getDwarfOffsetByteSize(DwarfFormat Format)

The size of a reference determined by the DWARF 32/64-bit format.

@ DW_LENGTH_DWARF64

Indicator of 64-bit DWARF format.

LLVM_ABI MCSymbol * emitListsTableHeaderStart(MCStreamer &S)

Definition MCDwarf.cpp:44

NodeAddr< InstrNode * > Instr

void write(void *memory, value_type value, endianness endian)

Write a value to memory with a particular endianness.

LLVM_ABI StringRef get_separator(Style style=Style::native)

Return the preferred separator for this platform.

LLVM_ABI StringRef parent_path(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)

Get parent path.

LLVM_ABI StringRef filename(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)

Get filename.

This is an optimization pass for GlobalISel generic memory operations.

bool operator<(int64_t V1, const APSInt &V2)

void stable_sort(R &&Range)

auto find(R &&Range, const T &Val)

Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.

auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)

Get the size of a range.

LLVM_ABI std::error_code inconvertibleErrorCode()

The value returned by this function can be returned from convertToErrorCode for Error values where no...

bool operator!=(uint64_t V1, const APInt &V2)

constexpr bool isUIntN(unsigned N, uint64_t x)

Checks if an unsigned integer fits into the given (dynamic) bit width.

bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)

constexpr bool isUInt(uint64_t x)

Checks if an unsigned integer fits into the given bit width.

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.

LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key

Error make_error(ArgTs &&... Args)

Make a Error instance representing failure using the given error info type.

LLVM_ABI unsigned getULEB128Size(uint64_t Value)

Utility function to get the size of the ULEB128-encoded value.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

ArrayRef(const T &OneElt) -> ArrayRef< T >

unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)

Utility function to encode a SLEB128 value to an output stream.

unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)

Utility function to encode a ULEB128 value to an output stream.

StringRef toStringRef(bool B)

Construct a string ref from a boolean.

This struct is a compact representation of a valid (non-zero power of two) alignment.

Instances of this class represent the name of the dwarf .file directive and its associated dwarf file...

std::optional< MD5::MD5Result > Checksum

The MD5 checksum, if there is one.

const MCSymbol * Personality

unsigned PersonalityEncoding

uint64_t CompactUnwindEncoding

std::vector< MCCFIInstruction > Instructions

uint8_t DWARF2LineOpcodeBase

First special line opcode - leave room for the standard opcodes.

uint8_t DWARF2LineRange

Range of line offsets in a special line info. opcode.

int8_t DWARF2LineBase

Minimum line offset in a special line info.