Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
DwarfDebug.cpp
Go to the documentation of this file.
1//===- llvm/CodeGen/DwarfDebug.cpp - Dwarf Debug Framework ----------------===//
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//
9// This file contains support for writing dwarf debug info into asm files.
10//
11//===----------------------------------------------------------------------===//
12
13#include "DwarfDebug.h"
14#include "ByteStreamer.h"
15#include "DIEHash.h"
16#include "DwarfCompileUnit.h"
17#include "DwarfExpression.h"
18#include "DwarfUnit.h"
19#include "llvm/ADT/APInt.h"
20#include "llvm/ADT/Statistic.h"
21#include "llvm/ADT/StringExtras.h"
22#include "llvm/ADT/Twine.h"
23#include "llvm/CodeGen/AsmPrinter.h"
24#include "llvm/CodeGen/DIE.h"
25#include "llvm/CodeGen/LexicalScopes.h"
26#include "llvm/CodeGen/MachineBasicBlock.h"
27#include "llvm/CodeGen/MachineFunction.h"
28#include "llvm/CodeGen/MachineModuleInfo.h"
29#include "llvm/CodeGen/MachineOperand.h"
30#include "llvm/CodeGen/TargetInstrInfo.h"
31#include "llvm/CodeGen/TargetLowering.h"
32#include "llvm/CodeGen/TargetRegisterInfo.h"
33#include "llvm/CodeGen/TargetSubtargetInfo.h"
34#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
35#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
36#include "llvm/IR/Constants.h"
37#include "llvm/IR/DebugInfoMetadata.h"
38#include "llvm/IR/Function.h"
39#include "llvm/IR/GlobalVariable.h"
40#include "llvm/IR/Module.h"
41#include "llvm/MC/MCAsmInfo.h"
42#include "llvm/MC/MCContext.h"
43#include "llvm/MC/MCSection.h"
44#include "llvm/MC/MCStreamer.h"
45#include "llvm/MC/MCSymbol.h"
46#include "llvm/MC/MCTargetOptions.h"
47#include "llvm/MC/MachineLocation.h"
48#include "llvm/Support/Casting.h"
49#include "llvm/Support/CommandLine.h"
50#include "llvm/Support/Debug.h"
51#include "llvm/Support/ErrorHandling.h"
52#include "llvm/Support/MD5.h"
53#include "llvm/Support/raw_ostream.h"
54#include "llvm/Target/TargetLoweringObjectFile.h"
55#include "llvm/Target/TargetMachine.h"
56#include "llvm/TargetParser/Triple.h"
57#include <algorithm>
58#include <cstddef>
59#include <iterator>
60#include <optional>
61#include <string>
62
63using namespacellvm;
64
65#define DEBUG_TYPE "dwarfdebug"
66
67STATISTIC(NumCSParams,"Number of dbg call site params created");
68
69staticcl::opt<bool>UseDwarfRangesBaseAddressSpecifier(
70"use-dwarf-ranges-base-address-specifier",cl::Hidden,
71cl::desc("Use base address specifiers in debug_ranges"),cl::init(false));
72
73staticcl::opt<bool>GenerateARangeSection("generate-arange-section",
74cl::Hidden,
75cl::desc("Generate dwarf aranges"),
76cl::init(false));
77
78staticcl::opt<bool>
79GenerateDwarfTypeUnits("generate-type-units",cl::Hidden,
80cl::desc("Generate DWARF4 type units."),
81cl::init(false));
82
83staticcl::opt<bool>SplitDwarfCrossCuReferences(
84"split-dwarf-cross-cu-references",cl::Hidden,
85cl::desc("Enable cross-cu references in DWO files"),cl::init(false));
86
87enumDefaultOnOff {Default,Enable,Disable };
88
89staticcl::opt<DefaultOnOff>UnknownLocations(
90"use-unknown-locations",cl::Hidden,
91cl::desc("Make an absence of debug location information explicit."),
92cl::values(clEnumVal(Default,"At top of block or after label"),
93clEnumVal(Enable,"In all cases"),clEnumVal(Disable,"Never")),
94cl::init(Default));
95
96staticcl::opt<AccelTableKind>AccelTables(
97"accel-tables",cl::Hidden,cl::desc("Output dwarf accelerator tables."),
98cl::values(clEnumValN(AccelTableKind::Default,"Default",
99"Default for platform"),
100clEnumValN(AccelTableKind::None,"Disable","Disabled."),
101clEnumValN(AccelTableKind::Apple,"Apple","Apple"),
102clEnumValN(AccelTableKind::Dwarf,"Dwarf","DWARF")),
103cl::init(AccelTableKind::Default));
104
105staticcl::opt<DefaultOnOff>
106DwarfInlinedStrings("dwarf-inlined-strings",cl::Hidden,
107cl::desc("Use inlined strings rather than string section."),
108cl::values(clEnumVal(Default,"Default for platform"),
109clEnumVal(Enable,"Enabled"),
110clEnumVal(Disable,"Disabled")),
111cl::init(Default));
112
113staticcl::opt<bool>
114NoDwarfRangesSection("no-dwarf-ranges-section",cl::Hidden,
115cl::desc("Disable emission .debug_ranges section."),
116cl::init(false));
117
118staticcl::opt<DefaultOnOff>DwarfSectionsAsReferences(
119"dwarf-sections-as-references",cl::Hidden,
120cl::desc("Use sections+offset as references rather than labels."),
121cl::values(clEnumVal(Default,"Default for platform"),
122clEnumVal(Enable,"Enabled"),clEnumVal(Disable,"Disabled")),
123cl::init(Default));
124
125staticcl::opt<bool>
126UseGNUDebugMacro("use-gnu-debug-macro",cl::Hidden,
127cl::desc("Emit the GNU .debug_macro format with DWARF <5"),
128cl::init(false));
129
130staticcl::opt<DefaultOnOff>DwarfOpConvert(
131"dwarf-op-convert",cl::Hidden,
132cl::desc("Enable use of the DWARFv5 DW_OP_convert operator"),
133cl::values(clEnumVal(Default,"Default for platform"),
134clEnumVal(Enable,"Enabled"),clEnumVal(Disable,"Disabled")),
135cl::init(Default));
136
137enumLinkageNameOption {
138DefaultLinkageNames,
139AllLinkageNames,
140AbstractLinkageNames
141};
142
143staticcl::opt<LinkageNameOption>
144DwarfLinkageNames("dwarf-linkage-names",cl::Hidden,
145cl::desc("Which DWARF linkage-name attributes to emit."),
146cl::values(clEnumValN(DefaultLinkageNames,"Default",
147"Default for platform"),
148clEnumValN(AllLinkageNames,"All","All"),
149clEnumValN(AbstractLinkageNames,"Abstract",
150"Abstract subprograms")),
151cl::init(DefaultLinkageNames));
152
153staticcl::opt<DwarfDebug::MinimizeAddrInV5>MinimizeAddrInV5Option(
154"minimize-addr-in-v5",cl::Hidden,
155cl::desc("Always use DW_AT_ranges in DWARFv5 whenever it could allow more "
156"address pool entry sharing to reduce relocations/object size"),
157cl::values(clEnumValN(DwarfDebug::MinimizeAddrInV5::Default,"Default",
158"Default address minimization strategy"),
159clEnumValN(DwarfDebug::MinimizeAddrInV5::Ranges,"Ranges",
160"Use rnglists for contiguous ranges if that allows "
161"using a pre-existing base address"),
162clEnumValN(DwarfDebug::MinimizeAddrInV5::Expressions,
163"Expressions",
164"Use exprloc addrx+offset expressions for any "
165"address with a prior base address"),
166clEnumValN(DwarfDebug::MinimizeAddrInV5::Form,"Form",
167"Use addrx+offset extension form for any address "
168"with a prior base address"),
169clEnumValN(DwarfDebug::MinimizeAddrInV5::Disabled,"Disabled",
170"Stuff")),
171cl::init(DwarfDebug::MinimizeAddrInV5::Default));
172
173staticconstexprunsignedULEB128PadSize = 4;
174
175void DebugLocDwarfExpression::emitOp(uint8_tOp,constchar *Comment) {
176 getActiveStreamer().emitInt8(
177Op, Comment ?Twine(Comment) +" " +dwarf::OperationEncodingString(Op)
178 :dwarf::OperationEncodingString(Op));
179}
180
181void DebugLocDwarfExpression::emitSigned(int64_tValue) {
182 getActiveStreamer().emitSLEB128(Value,Twine(Value));
183}
184
185void DebugLocDwarfExpression::emitUnsigned(uint64_tValue) {
186 getActiveStreamer().emitULEB128(Value,Twine(Value));
187}
188
189void DebugLocDwarfExpression::emitData1(uint8_tValue) {
190 getActiveStreamer().emitInt8(Value,Twine(Value));
191}
192
193void DebugLocDwarfExpression::emitBaseTypeRef(uint64_tIdx) {
194assert(Idx < (1ULL << (ULEB128PadSize * 7)) &&"Idx wont fit");
195 getActiveStreamer().emitULEB128(Idx,Twine(Idx),ULEB128PadSize);
196}
197
198bool DebugLocDwarfExpression::isFrameRegister(constTargetRegisterInfo &TRI,
199llvm::Register MachineReg) {
200// This information is not available while emitting .debug_loc entries.
201returnfalse;
202}
203
204void DebugLocDwarfExpression::enableTemporaryBuffer() {
205assert(!IsBuffering &&"Already buffering?");
206if (!TmpBuf)
207 TmpBuf = std::make_unique<TempBuffer>(OutBS.GenerateComments);
208 IsBuffering =true;
209}
210
211void DebugLocDwarfExpression::disableTemporaryBuffer() { IsBuffering =false; }
212
213unsigned DebugLocDwarfExpression::getTemporaryBufferSize() {
214return TmpBuf ? TmpBuf->Bytes.size() : 0;
215}
216
217void DebugLocDwarfExpression::commitTemporaryBuffer() {
218if (!TmpBuf)
219return;
220for (auto Byte :enumerate(TmpBuf->Bytes)) {
221constchar *Comment = (Byte.index() < TmpBuf->Comments.size())
222 ? TmpBuf->Comments[Byte.index()].c_str()
223 :"";
224 OutBS.emitInt8(Byte.value(),Comment);
225 }
226 TmpBuf->Bytes.clear();
227 TmpBuf->Comments.clear();
228}
229
230constDIType *DbgVariable::getType() const{
231returngetVariable()->getType();
232}
233
234/// Get .debug_loc entry for the instruction range starting at MI.
235staticDbgValueLocgetDebugLocValue(constMachineInstr *MI) {
236constDIExpression *Expr =MI->getDebugExpression();
237auto SingleLocExprOpt =DIExpression::convertToNonVariadicExpression(Expr);
238constbool IsVariadic = !SingleLocExprOpt;
239// If we have a variadic debug value instruction that is equivalent to a
240// non-variadic instruction, then convert it to non-variadic form here.
241if (!IsVariadic && !MI->isNonListDebugValue()) {
242assert(MI->getNumDebugOperands() == 1 &&
243"Mismatched DIExpression and debug operands for debug instruction.");
244 Expr = *SingleLocExprOpt;
245 }
246assert(MI->getNumOperands() >= 3);
247SmallVector<DbgValueLocEntry, 4> DbgValueLocEntries;
248for (constMachineOperand &Op :MI->debug_operands()) {
249if (Op.isReg()) {
250MachineLocation MLoc(Op.getReg(),
251MI->isNonListDebugValue() &&MI->isDebugOffsetImm());
252 DbgValueLocEntries.push_back(DbgValueLocEntry(MLoc));
253 }elseif (Op.isTargetIndex()) {
254 DbgValueLocEntries.push_back(
255DbgValueLocEntry(TargetIndexLocation(Op.getIndex(),Op.getOffset())));
256 }elseif (Op.isImm())
257 DbgValueLocEntries.push_back(DbgValueLocEntry(Op.getImm()));
258elseif (Op.isFPImm())
259 DbgValueLocEntries.push_back(DbgValueLocEntry(Op.getFPImm()));
260elseif (Op.isCImm())
261 DbgValueLocEntries.push_back(DbgValueLocEntry(Op.getCImm()));
262else
263llvm_unreachable("Unexpected debug operand in DBG_VALUE* instruction!");
264 }
265returnDbgValueLoc(Expr, DbgValueLocEntries, IsVariadic);
266}
267
268staticuint64_tgetFragmentOffsetInBits(constDIExpression &Expr) {
269 std::optional<DIExpression::FragmentInfo> Fragment = Expr.getFragmentInfo();
270return Fragment ? Fragment->OffsetInBits : 0;
271}
272
273boolllvm::operator<(constFrameIndexExpr &LHS,constFrameIndexExpr &RHS) {
274returngetFragmentOffsetInBits(*LHS.Expr) <
275getFragmentOffsetInBits(*RHS.Expr);
276}
277
278boolllvm::operator<(constEntryValueInfo &LHS,constEntryValueInfo &RHS) {
279returngetFragmentOffsetInBits(LHS.Expr) <getFragmentOffsetInBits(RHS.Expr);
280}
281
282Loc::Single::Single(DbgValueLoc ValueLoc)
283 : ValueLoc(std::make_unique<DbgValueLoc>(ValueLoc)),
284 Expr(ValueLoc.getExpression()) {
285if (!Expr->getNumElements())
286 Expr =nullptr;
287}
288
289Loc::Single::Single(constMachineInstr *DbgValue)
290 :Single(getDebugLocValue(DbgValue)) {}
291
292const std::set<FrameIndexExpr> &Loc::MMI::getFrameIndexExprs() const{
293return FrameIndexExprs;
294}
295
296voidLoc::MMI::addFrameIndexExpr(constDIExpression *Expr,int FI) {
297 FrameIndexExprs.insert({FI, Expr});
298assert((FrameIndexExprs.size() == 1 ||
299llvm::all_of(FrameIndexExprs,
300 [](constFrameIndexExpr &FIE) {
301 return FIE.Expr && FIE.Expr->isFragment();
302 })) &&
303"conflicting locations for variable");
304}
305
306staticAccelTableKindcomputeAccelTableKind(unsigned DwarfVersion,
307bool GenerateTypeUnits,
308DebuggerKind Tuning,
309constTriple &TT) {
310// Honor an explicit request.
311if (AccelTables !=AccelTableKind::Default)
312returnAccelTables;
313
314// Generating DWARF5 acceleration table.
315// Currently Split dwarf and non ELF format is not supported.
316if (GenerateTypeUnits && (DwarfVersion < 5 || !TT.isOSBinFormatELF()))
317returnAccelTableKind::None;
318
319// Accelerator tables get emitted if targetting DWARF v5 or LLDB. DWARF v5
320// always implies debug_names. For lower standard versions we use apple
321// accelerator tables on apple platforms and debug_names elsewhere.
322if (DwarfVersion >= 5)
323returnAccelTableKind::Dwarf;
324if (Tuning ==DebuggerKind::LLDB)
325return TT.isOSBinFormatMachO() ?AccelTableKind::Apple
326 :AccelTableKind::Dwarf;
327returnAccelTableKind::None;
328}
329
330DwarfDebug::DwarfDebug(AsmPrinter *A)
331 :DebugHandlerBase(A), DebugLocs(A->OutStreamer->isVerboseAsm()),
332 InfoHolder(A,"info_string", DIEValueAllocator),
333 SkeletonHolder(A,"skel_string", DIEValueAllocator),
334 IsDarwin(A->TM.getTargetTriple().isOSDarwin()) {
335constTriple &TT =Asm->TM.getTargetTriple();
336
337// Make sure we know our "debugger tuning". The target option takes
338// precedence; fall back to triple-based defaults.
339if (Asm->TM.Options.DebuggerTuning !=DebuggerKind::Default)
340 DebuggerTuning =Asm->TM.Options.DebuggerTuning;
341elseif (IsDarwin)
342 DebuggerTuning =DebuggerKind::LLDB;
343elseif (TT.isPS())
344 DebuggerTuning =DebuggerKind::SCE;
345elseif (TT.isOSAIX())
346 DebuggerTuning =DebuggerKind::DBX;
347else
348 DebuggerTuning =DebuggerKind::GDB;
349
350if (DwarfInlinedStrings ==Default)
351 UseInlineStrings = TT.isNVPTX() ||tuneForDBX();
352else
353 UseInlineStrings =DwarfInlinedStrings ==Enable;
354
355// Always emit .debug_aranges for SCE tuning.
356 UseARangesSection =GenerateARangeSection ||tuneForSCE();
357
358 HasAppleExtensionAttributes =tuneForLLDB();
359
360// Handle split DWARF.
361 HasSplitDwarf = !Asm->TM.Options.MCOptions.SplitDwarfFile.empty();
362
363// SCE defaults to linkage names only for abstract subprograms.
364if (DwarfLinkageNames ==DefaultLinkageNames)
365 UseAllLinkageNames = !tuneForSCE();
366else
367 UseAllLinkageNames =DwarfLinkageNames ==AllLinkageNames;
368
369unsigned DwarfVersionNumber =Asm->TM.Options.MCOptions.DwarfVersion;
370unsigned DwarfVersion = DwarfVersionNumber ? DwarfVersionNumber
371 :MMI->getModule()->getDwarfVersion();
372// Use dwarf 4 by default if nothing is requested. For NVPTX, use dwarf 2.
373 DwarfVersion =
374 TT.isNVPTX() ? 2 : (DwarfVersion ? DwarfVersion :dwarf::DWARF_VERSION);
375
376bool Dwarf64 = DwarfVersion >= 3 &&// DWARF64 was introduced in DWARFv3.
377 TT.isArch64Bit();// DWARF64 requires 64-bit relocations.
378
379// Support DWARF64
380// 1: For ELF when requested.
381// 2: For XCOFF64: the AIX assembler will fill in debug section lengths
382// according to the DWARF64 format for 64-bit assembly, so we must use
383// DWARF64 in the compiler too for 64-bit mode.
384 Dwarf64 &=
385 ((Asm->TM.Options.MCOptions.Dwarf64 ||MMI->getModule()->isDwarf64()) &&
386 TT.isOSBinFormatELF()) ||
387 TT.isOSBinFormatXCOFF();
388
389if (!Dwarf64 && TT.isArch64Bit() && TT.isOSBinFormatXCOFF())
390report_fatal_error("XCOFF requires DWARF64 for 64-bit mode!");
391
392 UseRangesSection = !NoDwarfRangesSection && !TT.isNVPTX();
393
394// Use sections as references. Force for NVPTX.
395if (DwarfSectionsAsReferences ==Default)
396 UseSectionsAsReferences = TT.isNVPTX();
397else
398 UseSectionsAsReferences =DwarfSectionsAsReferences ==Enable;
399
400// Don't generate type units for unsupported object file formats.
401 GenerateTypeUnits = (A->TM.getTargetTriple().isOSBinFormatELF() ||
402A->TM.getTargetTriple().isOSBinFormatWasm()) &&
403GenerateDwarfTypeUnits;
404
405 TheAccelTableKind =computeAccelTableKind(
406 DwarfVersion, GenerateTypeUnits, DebuggerTuning,A->TM.getTargetTriple());
407
408// Work around a GDB bug. GDB doesn't support the standard opcode;
409// SCE doesn't support GNU's; LLDB prefers the standard opcode, which
410// is defined as of DWARF 3.
411// See GDB bug 11616 - DW_OP_form_tls_address is unimplemented
412// https://sourceware.org/bugzilla/show_bug.cgi?id=11616
413 UseGNUTLSOpcode =tuneForGDB() || DwarfVersion < 3;
414
415 UseDWARF2Bitfields = DwarfVersion < 4;
416
417// The DWARF v5 string offsets table has - possibly shared - contributions
418// from each compile and type unit each preceded by a header. The string
419// offsets table used by the pre-DWARF v5 split-DWARF implementation uses
420// a monolithic string offsets table without any header.
421 UseSegmentedStringOffsetsTable = DwarfVersion >= 5;
422
423// Emit call-site-param debug info for GDB and LLDB, if the target supports
424// the debug entry values feature. It can also be enabled explicitly.
425 EmitDebugEntryValues =Asm->TM.Options.ShouldEmitDebugEntryValues();
426
427// It is unclear if the GCC .debug_macro extension is well-specified
428// for split DWARF. For now, do not allow LLVM to emit it.
429 UseDebugMacroSection =
430 DwarfVersion >= 5 || (UseGNUDebugMacro && !useSplitDwarf());
431if (DwarfOpConvert ==Default)
432 EnableOpConvert = !((tuneForGDB() &&useSplitDwarf()) || (tuneForLLDB() && !TT.isOSBinFormatMachO()));
433else
434 EnableOpConvert = (DwarfOpConvert ==Enable);
435
436// Split DWARF would benefit object size significantly by trading reductions
437// in address pool usage for slightly increased range list encodings.
438if (DwarfVersion >= 5)
439 MinimizeAddr =MinimizeAddrInV5Option;
440
441Asm->OutStreamer->getContext().setDwarfVersion(DwarfVersion);
442Asm->OutStreamer->getContext().setDwarfFormat(Dwarf64 ?dwarf::DWARF64
443 :dwarf::DWARF32);
444}
445
446// Define out of line so we don't have to include DwarfUnit.h in DwarfDebug.h.
447DwarfDebug::~DwarfDebug() =default;
448
449staticboolisObjCClass(StringRefName) {
450returnName.starts_with("+") ||Name.starts_with("-");
451}
452
453staticboolhasObjCCategory(StringRefName) {
454if (!isObjCClass(Name))
455returnfalse;
456
457returnName.contains(") ");
458}
459
460staticvoidgetObjCClassCategory(StringRef In,StringRef &Class,
461StringRef &Category) {
462if (!hasObjCCategory(In)) {
463 Class = In.slice(In.find('[') + 1, In.find(' '));
464 Category ="";
465return;
466 }
467
468 Class = In.slice(In.find('[') + 1, In.find('('));
469 Category = In.slice(In.find('[') + 1, In.find(' '));
470}
471
472staticStringRefgetObjCMethodName(StringRef In) {
473return In.slice(In.find(' ') + 1, In.find(']'));
474}
475
476// Add the various names to the Dwarf accelerator table names.
477voidDwarfDebug::addSubprogramNames(
478constDwarfUnit &Unit,
479constDICompileUnit::DebugNameTableKind NameTableKind,
480constDISubprogram *SP,DIE &Die) {
481if (getAccelTableKind() !=AccelTableKind::Apple &&
482 NameTableKind !=DICompileUnit::DebugNameTableKind::Apple &&
483 NameTableKind ==DICompileUnit::DebugNameTableKind::None)
484return;
485
486if (!SP->isDefinition())
487return;
488
489if (SP->getName() !="")
490addAccelName(Unit, NameTableKind, SP->getName(), Die);
491
492// If the linkage name is different than the name, go ahead and output that as
493// well into the name table. Only do that if we are going to actually emit
494// that name.
495if (SP->getLinkageName() !="" && SP->getName() != SP->getLinkageName() &&
496 (useAllLinkageNames() || InfoHolder.getAbstractScopeDIEs().lookup(SP)))
497addAccelName(Unit, NameTableKind, SP->getLinkageName(), Die);
498
499// If this is an Objective-C selector name add it to the ObjC accelerator
500// too.
501if (isObjCClass(SP->getName())) {
502StringRef Class, Category;
503getObjCClassCategory(SP->getName(), Class, Category);
504addAccelObjC(Unit, NameTableKind, Class, Die);
505if (Category !="")
506addAccelObjC(Unit, NameTableKind, Category, Die);
507// Also add the base method name to the name table.
508addAccelName(Unit, NameTableKind,getObjCMethodName(SP->getName()), Die);
509 }
510}
511
512/// Check whether we should create a DIE for the given Scope, return true
513/// if we don't create a DIE (the corresponding DIE is null).
514boolDwarfDebug::isLexicalScopeDIENull(LexicalScope *Scope) {
515if (Scope->isAbstractScope())
516returnfalse;
517
518// We don't create a DIE if there is no Range.
519constSmallVectorImpl<InsnRange> &Ranges = Scope->getRanges();
520if (Ranges.empty())
521returntrue;
522
523if (Ranges.size() > 1)
524returnfalse;
525
526// We don't create a DIE if we have a single Range and the end label
527// is null.
528return !getLabelAfterInsn(Ranges.front().second);
529}
530
531template <typename Func>staticvoidforBothCUs(DwarfCompileUnit &CU, FuncF) {
532F(CU);
533if (auto *SkelCU =CU.getSkeleton())
534if (CU.getCUNode()->getSplitDebugInlining())
535F(*SkelCU);
536}
537
538boolDwarfDebug::shareAcrossDWOCUs() const{
539returnSplitDwarfCrossCuReferences;
540}
541
542void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU,
543LexicalScope *Scope) {
544assert(Scope && Scope->getScopeNode());
545assert(Scope->isAbstractScope());
546assert(!Scope->getInlinedAt());
547
548auto *SP = cast<DISubprogram>(Scope->getScopeNode());
549
550// Find the subprogram's DwarfCompileUnit in the SPMap in case the subprogram
551// was inlined from another compile unit.
552if (useSplitDwarf() && !shareAcrossDWOCUs() && !SP->getUnit()->getSplitDebugInlining())
553// Avoid building the original CU if it won't be used
554 SrcCU.constructAbstractSubprogramScopeDIE(Scope);
555else {
556auto &CU = getOrCreateDwarfCompileUnit(SP->getUnit());
557if (auto *SkelCU =CU.getSkeleton()) {
558 (shareAcrossDWOCUs() ?CU : SrcCU)
559 .constructAbstractSubprogramScopeDIE(Scope);
560if (CU.getCUNode()->getSplitDebugInlining())
561 SkelCU->constructAbstractSubprogramScopeDIE(Scope);
562 }else
563CU.constructAbstractSubprogramScopeDIE(Scope);
564 }
565}
566
567/// Represents a parameter whose call site value can be described by applying a
568/// debug expression to a register in the forwarded register worklist.
569structFwdRegParamInfo {
570 /// The described parameter register.
571uint64_tParamReg;
572
573 /// Debug expression that has been built up when walking through the
574 /// instruction chain that produces the parameter's value.
575constDIExpression *Expr;
576};
577
578/// Register worklist for finding call site values.
579usingFwdRegWorklist =MapVector<uint64_t, SmallVector<FwdRegParamInfo, 2>>;
580/// Container for the set of registers known to be clobbered on the path to a
581/// call site.
582usingClobberedRegSet =SmallSet<Register, 16>;
583
584/// Append the expression \p Addition to \p Original and return the result.
585staticconstDIExpression *combineDIExpressions(constDIExpression *Original,
586constDIExpression *Addition) {
587 std::vector<uint64_t> Elts = Addition->getElements().vec();
588// Avoid multiple DW_OP_stack_values.
589if (Original->isImplicit() && Addition->isImplicit())
590llvm::erase(Elts, dwarf::DW_OP_stack_value);
591constDIExpression *CombinedExpr =
592 (Elts.size() > 0) ?DIExpression::append(Original, Elts) : Original;
593return CombinedExpr;
594}
595
596/// Emit call site parameter entries that are described by the given value and
597/// debug expression.
598template <typename ValT>
599staticvoidfinishCallSiteParams(ValT Val,constDIExpression *Expr,
600ArrayRef<FwdRegParamInfo> DescribedParams,
601ParamSet &Params) {
602for (auto Param : DescribedParams) {
603bool ShouldCombineExpressions = Expr && Param.Expr->getNumElements() > 0;
604
605// TODO: Entry value operations can currently not be combined with any
606// other expressions, so we can't emit call site entries in those cases.
607if (ShouldCombineExpressions && Expr->isEntryValue())
608continue;
609
610// If a parameter's call site value is produced by a chain of
611// instructions we may have already created an expression for the
612// parameter when walking through the instructions. Append that to the
613// base expression.
614constDIExpression *CombinedExpr =
615 ShouldCombineExpressions ?combineDIExpressions(Expr, Param.Expr)
616 : Expr;
617assert((!CombinedExpr || CombinedExpr->isValid()) &&
618"Combined debug expression is invalid");
619
620DbgValueLoc DbgLocVal(CombinedExpr,DbgValueLocEntry(Val));
621DbgCallSiteParam CSParm(Param.ParamReg, DbgLocVal);
622 Params.push_back(CSParm);
623 ++NumCSParams;
624 }
625}
626
627/// Add \p Reg to the worklist, if it's not already present, and mark that the
628/// given parameter registers' values can (potentially) be described using
629/// that register and an debug expression.
630staticvoidaddToFwdRegWorklist(FwdRegWorklist &Worklist,unsigned Reg,
631constDIExpression *Expr,
632ArrayRef<FwdRegParamInfo> ParamsToAdd) {
633auto &ParamsForFwdReg = Worklist[Reg];
634for (auto Param : ParamsToAdd) {
635assert(none_of(ParamsForFwdReg,
636 [Param](constFwdRegParamInfo &D) {
637returnD.ParamReg == Param.ParamReg;
638 }) &&
639"Same parameter described twice by forwarding reg");
640
641// If a parameter's call site value is produced by a chain of
642// instructions we may have already created an expression for the
643// parameter when walking through the instructions. Append that to the
644// new expression.
645constDIExpression *CombinedExpr =combineDIExpressions(Expr, Param.Expr);
646 ParamsForFwdReg.push_back({Param.ParamReg, CombinedExpr});
647 }
648}
649
650/// Interpret values loaded into registers by \p CurMI.
651staticvoidinterpretValues(constMachineInstr *CurMI,
652FwdRegWorklist &ForwardedRegWorklist,
653ParamSet &Params,
654ClobberedRegSet &ClobberedRegUnits) {
655
656constMachineFunction *MF = CurMI->getMF();
657constDIExpression *EmptyExpr =
658DIExpression::get(MF->getFunction().getContext(), {});
659constauto &TRI = *MF->getSubtarget().getRegisterInfo();
660constauto &TII = *MF->getSubtarget().getInstrInfo();
661constauto &TLI = *MF->getSubtarget().getTargetLowering();
662
663// If an instruction defines more than one item in the worklist, we may run
664// into situations where a worklist register's value is (potentially)
665// described by the previous value of another register that is also defined
666// by that instruction.
667//
668// This can for example occur in cases like this:
669//
670// $r1 = mov 123
671// $r0, $r1 = mvrr $r1, 456
672// call @foo, $r0, $r1
673//
674// When describing $r1's value for the mvrr instruction, we need to make sure
675// that we don't finalize an entry value for $r0, as that is dependent on the
676// previous value of $r1 (123 rather than 456).
677//
678// In order to not have to distinguish between those cases when finalizing
679// entry values, we simply postpone adding new parameter registers to the
680// worklist, by first keeping them in this temporary container until the
681// instruction has been handled.
682FwdRegWorklist TmpWorklistItems;
683
684// If the MI is an instruction defining one or more parameters' forwarding
685// registers, add those defines.
686ClobberedRegSet NewClobberedRegUnits;
687auto getForwardingRegsDefinedByMI = [&](constMachineInstr &MI,
688SmallSetVector<unsigned, 4> &Defs) {
689if (MI.isDebugInstr())
690return;
691
692for (constMachineOperand &MO :MI.all_defs()) {
693if (MO.getReg().isPhysical()) {
694for (auto &FwdReg : ForwardedRegWorklist)
695if (TRI.regsOverlap(FwdReg.first, MO.getReg()))
696 Defs.insert(FwdReg.first);
697for (MCRegUnit Unit :TRI.regunits(MO.getReg()))
698 NewClobberedRegUnits.insert(Unit);
699 }
700 }
701 };
702
703// Set of worklist registers that are defined by this instruction.
704SmallSetVector<unsigned, 4> FwdRegDefs;
705
706 getForwardingRegsDefinedByMI(*CurMI, FwdRegDefs);
707if (FwdRegDefs.empty()) {
708// Any definitions by this instruction will clobber earlier reg movements.
709 ClobberedRegUnits.insert(NewClobberedRegUnits.begin(),
710 NewClobberedRegUnits.end());
711return;
712 }
713
714// It's possible that we find a copy from a non-volatile register to the param
715// register, which is clobbered in the meantime. Test for clobbered reg unit
716// overlaps before completing.
717auto IsRegClobberedInMeantime = [&](Register Reg) ->bool {
718for (auto &RegUnit : ClobberedRegUnits)
719if (TRI.hasRegUnit(Reg, RegUnit))
720returntrue;
721returnfalse;
722 };
723
724for (auto ParamFwdReg : FwdRegDefs) {
725if (auto ParamValue =TII.describeLoadedValue(*CurMI, ParamFwdReg)) {
726if (ParamValue->first.isImm()) {
727 int64_t Val = ParamValue->first.getImm();
728finishCallSiteParams(Val, ParamValue->second,
729 ForwardedRegWorklist[ParamFwdReg], Params);
730 }elseif (ParamValue->first.isReg()) {
731Register RegLoc = ParamValue->first.getReg();
732Register SP = TLI.getStackPointerRegisterToSaveRestore();
733RegisterFP =TRI.getFrameRegister(*MF);
734bool IsSPorFP = (RegLoc == SP) || (RegLoc ==FP);
735if (!IsRegClobberedInMeantime(RegLoc) &&
736 (TRI.isCalleeSavedPhysReg(RegLoc, *MF) || IsSPorFP)) {
737MachineLocation MLoc(RegLoc,/*Indirect=*/IsSPorFP);
738finishCallSiteParams(MLoc, ParamValue->second,
739 ForwardedRegWorklist[ParamFwdReg], Params);
740 }else {
741// ParamFwdReg was described by the non-callee saved register
742// RegLoc. Mark that the call site values for the parameters are
743// dependent on that register instead of ParamFwdReg. Since RegLoc
744// may be a register that will be handled in this iteration, we
745// postpone adding the items to the worklist, and instead keep them
746// in a temporary container.
747addToFwdRegWorklist(TmpWorklistItems, RegLoc, ParamValue->second,
748 ForwardedRegWorklist[ParamFwdReg]);
749 }
750 }
751 }
752 }
753
754// Remove all registers that this instruction defines from the worklist.
755for (auto ParamFwdReg : FwdRegDefs)
756 ForwardedRegWorklist.erase(ParamFwdReg);
757
758// Any definitions by this instruction will clobber earlier reg movements.
759 ClobberedRegUnits.insert(NewClobberedRegUnits.begin(),
760 NewClobberedRegUnits.end());
761
762// Now that we are done handling this instruction, add items from the
763// temporary worklist to the real one.
764for (auto &New : TmpWorklistItems)
765addToFwdRegWorklist(ForwardedRegWorklist, New.first, EmptyExpr, New.second);
766 TmpWorklistItems.clear();
767}
768
769staticboolinterpretNextInstr(constMachineInstr *CurMI,
770FwdRegWorklist &ForwardedRegWorklist,
771ParamSet &Params,
772ClobberedRegSet &ClobberedRegUnits) {
773// Skip bundle headers.
774if (CurMI->isBundle())
775returntrue;
776
777// If the next instruction is a call we can not interpret parameter's
778// forwarding registers or we finished the interpretation of all
779// parameters.
780if (CurMI->isCall())
781returnfalse;
782
783if (ForwardedRegWorklist.empty())
784returnfalse;
785
786// Avoid NOP description.
787if (CurMI->getNumOperands() == 0)
788returntrue;
789
790interpretValues(CurMI, ForwardedRegWorklist, Params, ClobberedRegUnits);
791
792returntrue;
793}
794
795/// Try to interpret values loaded into registers that forward parameters
796/// for \p CallMI. Store parameters with interpreted value into \p Params.
797staticvoidcollectCallSiteParameters(constMachineInstr *CallMI,
798ParamSet &Params) {
799constMachineFunction *MF = CallMI->getMF();
800constauto &CalleesMap = MF->getCallSitesInfo();
801auto CSInfo = CalleesMap.find(CallMI);
802
803// There is no information for the call instruction.
804if (CSInfo == CalleesMap.end())
805return;
806
807constMachineBasicBlock *MBB = CallMI->getParent();
808
809// Skip the call instruction.
810autoI = std::next(CallMI->getReverseIterator());
811
812FwdRegWorklist ForwardedRegWorklist;
813
814constDIExpression *EmptyExpr =
815DIExpression::get(MF->getFunction().getContext(), {});
816
817// Add all the forwarding registers into the ForwardedRegWorklist.
818for (constauto &ArgReg : CSInfo->second.ArgRegPairs) {
819bool InsertedReg =
820 ForwardedRegWorklist.insert({ArgReg.Reg, {{ArgReg.Reg, EmptyExpr}}})
821 .second;
822assert(InsertedReg &&"Single register used to forward two arguments?");
823 (void)InsertedReg;
824 }
825
826// Do not emit CSInfo for undef forwarding registers.
827for (constauto &MO : CallMI->uses())
828if (MO.isReg() && MO.isUndef())
829 ForwardedRegWorklist.erase(MO.getReg());
830
831// We erase, from the ForwardedRegWorklist, those forwarding registers for
832// which we successfully describe a loaded value (by using
833// the describeLoadedValue()). For those remaining arguments in the working
834// list, for which we do not describe a loaded value by
835// the describeLoadedValue(), we try to generate an entry value expression
836// for their call site value description, if the call is within the entry MBB.
837// TODO: Handle situations when call site parameter value can be described
838// as the entry value within basic blocks other than the first one.
839bool ShouldTryEmitEntryVals =MBB->getIterator() == MF->begin();
840
841// Search for a loading value in forwarding registers inside call delay slot.
842ClobberedRegSet ClobberedRegUnits;
843if (CallMI->hasDelaySlot()) {
844auto Suc = std::next(CallMI->getIterator());
845// Only one-instruction delay slot is supported.
846auto BundleEnd =llvm::getBundleEnd(CallMI->getIterator());
847 (void)BundleEnd;
848assert(std::next(Suc) == BundleEnd &&
849"More than one instruction in call delay slot");
850// Try to interpret value loaded by instruction.
851if (!interpretNextInstr(&*Suc, ForwardedRegWorklist, Params, ClobberedRegUnits))
852return;
853 }
854
855// Search for a loading value in forwarding registers.
856for (;I !=MBB->rend(); ++I) {
857// Try to interpret values loaded by instruction.
858if (!interpretNextInstr(&*I, ForwardedRegWorklist, Params, ClobberedRegUnits))
859return;
860 }
861
862// Emit the call site parameter's value as an entry value.
863if (ShouldTryEmitEntryVals) {
864// Create an expression where the register's entry value is used.
865DIExpression *EntryExpr =DIExpression::get(
866 MF->getFunction().getContext(), {dwarf::DW_OP_LLVM_entry_value, 1});
867for (auto &RegEntry : ForwardedRegWorklist) {
868MachineLocation MLoc(RegEntry.first);
869finishCallSiteParams(MLoc, EntryExpr, RegEntry.second, Params);
870 }
871 }
872}
873
874void DwarfDebug::constructCallSiteEntryDIEs(constDISubprogram &SP,
875DwarfCompileUnit &CU,DIE &ScopeDIE,
876constMachineFunction &MF) {
877// Add a call site-related attribute (DWARF5, Sec. 3.3.1.3). Do this only if
878// the subprogram is required to have one.
879if (!SP.areAllCallsDescribed() || !SP.isDefinition())
880return;
881
882// Use DW_AT_call_all_calls to express that call site entries are present
883// for both tail and non-tail calls. Don't use DW_AT_call_all_source_calls
884// because one of its requirements is not met: call site entries for
885// optimized-out calls are elided.
886CU.addFlag(ScopeDIE,CU.getDwarf5OrGNUAttr(dwarf::DW_AT_call_all_calls));
887
888constTargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
889assert(TII &&"TargetInstrInfo not found: cannot label tail calls");
890
891// Delay slot support check.
892auto delaySlotSupported = [&](constMachineInstr &MI) {
893if (!MI.isBundledWithSucc())
894returnfalse;
895auto Suc = std::next(MI.getIterator());
896auto CallInstrBundle =getBundleStart(MI.getIterator());
897 (void)CallInstrBundle;
898auto DelaySlotBundle =getBundleStart(Suc);
899 (void)DelaySlotBundle;
900// Ensure that label after call is following delay slot instruction.
901// Ex. CALL_INSTRUCTION {
902// DELAY_SLOT_INSTRUCTION }
903// LABEL_AFTER_CALL
904assert(getLabelAfterInsn(&*CallInstrBundle) ==
905getLabelAfterInsn(&*DelaySlotBundle) &&
906"Call and its successor instruction don't have same label after.");
907returntrue;
908 };
909
910// Emit call site entries for each call or tail call in the function.
911for (constMachineBasicBlock &MBB : MF) {
912for (constMachineInstr &MI :MBB.instrs()) {
913// Bundles with call in them will pass the isCall() test below but do not
914// have callee operand information so skip them here. Iterator will
915// eventually reach the call MI.
916if (MI.isBundle())
917continue;
918
919// Skip instructions which aren't calls. Both calls and tail-calling jump
920// instructions (e.g TAILJMPd64) are classified correctly here.
921if (!MI.isCandidateForAdditionalCallInfo())
922continue;
923
924// Skip instructions marked as frame setup, as they are not interesting to
925// the user.
926if (MI.getFlag(MachineInstr::FrameSetup))
927continue;
928
929// Check if delay slot support is enabled.
930if (MI.hasDelaySlot() && !delaySlotSupported(*&MI))
931return;
932
933// If this is a direct call, find the callee's subprogram.
934// In the case of an indirect call find the register that holds
935// the callee.
936constMachineOperand &CalleeOp =TII->getCalleeOperand(MI);
937if (!CalleeOp.isGlobal() &&
938 (!CalleeOp.isReg() || !CalleeOp.getReg().isPhysical()))
939continue;
940
941unsigned CallReg = 0;
942constDISubprogram *CalleeSP =nullptr;
943constFunction *CalleeDecl =nullptr;
944if (CalleeOp.isReg()) {
945 CallReg = CalleeOp.getReg();
946if (!CallReg)
947continue;
948 }else {
949 CalleeDecl = dyn_cast<Function>(CalleeOp.getGlobal());
950if (!CalleeDecl || !CalleeDecl->getSubprogram())
951continue;
952 CalleeSP = CalleeDecl->getSubprogram();
953 }
954
955// TODO: Omit call site entries for runtime calls (objc_msgSend, etc).
956
957bool IsTail =TII->isTailCall(MI);
958
959// If MI is in a bundle, the label was created after the bundle since
960// EmitFunctionBody iterates over top-level MIs. Get that top-level MI
961// to search for that label below.
962constMachineInstr *TopLevelCallMI =
963MI.isInsideBundle() ? &*getBundleStart(MI.getIterator()) : &MI;
964
965// For non-tail calls, the return PC is needed to disambiguate paths in
966// the call graph which could lead to some target function. For tail
967// calls, no return PC information is needed, unless tuning for GDB in
968// DWARF4 mode in which case we fake a return PC for compatibility.
969constMCSymbol *PCAddr =
970 (!IsTail ||CU.useGNUAnalogForDwarf5Feature())
971 ?const_cast<MCSymbol *>(getLabelAfterInsn(TopLevelCallMI))
972 :nullptr;
973
974// For tail calls, it's necessary to record the address of the branch
975// instruction so that the debugger can show where the tail call occurred.
976constMCSymbol *CallAddr =
977 IsTail ?getLabelBeforeInsn(TopLevelCallMI) : nullptr;
978
979assert((IsTail || PCAddr) &&"Non-tail call without return PC");
980
981LLVM_DEBUG(dbgs() <<"CallSiteEntry: " << MF.getName() <<" -> "
982 << (CalleeDecl ? CalleeDecl->getName()
983 :StringRef(MF.getSubtarget()
984 .getRegisterInfo()
985 ->getName(CallReg)))
986 << (IsTail ?" [IsTail]" :"") <<"\n");
987
988DIE &CallSiteDIE =CU.constructCallSiteEntryDIE(
989 ScopeDIE, CalleeSP, IsTail, PCAddr, CallAddr, CallReg);
990
991// Optionally emit call-site-param debug info.
992if (emitDebugEntryValues()) {
993ParamSet Params;
994// Try to interpret values of call site parameters.
995collectCallSiteParameters(&MI, Params);
996CU.constructCallSiteParmEntryDIEs(CallSiteDIE, Params);
997 }
998 }
999 }
1000}
1001
1002void DwarfDebug::addGnuPubAttributes(DwarfCompileUnit &U,DIE &D) const{
1003if (!U.hasDwarfPubSections())
1004return;
1005
1006U.addFlag(D, dwarf::DW_AT_GNU_pubnames);
1007}
1008
1009void DwarfDebug::finishUnitAttributes(constDICompileUnit *DIUnit,
1010DwarfCompileUnit &NewCU) {
1011DIE &Die = NewCU.getUnitDie();
1012StringRef FN = DIUnit->getFilename();
1013
1014StringRefProducer = DIUnit->getProducer();
1015StringRefFlags = DIUnit->getFlags();
1016if (!Flags.empty() && !useAppleExtensionAttributes()) {
1017 std::string ProducerWithFlags =Producer.str() +" " +Flags.str();
1018 NewCU.addString(Die, dwarf::DW_AT_producer, ProducerWithFlags);
1019 }else
1020 NewCU.addString(Die, dwarf::DW_AT_producer, Producer);
1021
1022 NewCU.addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
1023 DIUnit->getSourceLanguage());
1024 NewCU.addString(Die, dwarf::DW_AT_name, FN);
1025StringRef SysRoot = DIUnit->getSysRoot();
1026if (!SysRoot.empty())
1027 NewCU.addString(Die, dwarf::DW_AT_LLVM_sysroot, SysRoot);
1028StringRef SDK = DIUnit->getSDK();
1029if (!SDK.empty())
1030 NewCU.addString(Die, dwarf::DW_AT_APPLE_sdk, SDK);
1031
1032if (!useSplitDwarf()) {
1033// Add DW_str_offsets_base to the unit DIE, except for split units.
1034if (useSegmentedStringOffsetsTable())
1035 NewCU.addStringOffsetsStart();
1036
1037 NewCU.initStmtList();
1038
1039// If we're using split dwarf the compilation dir is going to be in the
1040// skeleton CU and so we don't need to duplicate it here.
1041if (!CompilationDir.empty())
1042 NewCU.addString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
1043 addGnuPubAttributes(NewCU, Die);
1044 }
1045
1046if (useAppleExtensionAttributes()) {
1047if (DIUnit->isOptimized())
1048 NewCU.addFlag(Die, dwarf::DW_AT_APPLE_optimized);
1049
1050StringRefFlags = DIUnit->getFlags();
1051if (!Flags.empty())
1052 NewCU.addString(Die, dwarf::DW_AT_APPLE_flags, Flags);
1053
1054if (unsigned RVer = DIUnit->getRuntimeVersion())
1055 NewCU.addUInt(Die, dwarf::DW_AT_APPLE_major_runtime_vers,
1056 dwarf::DW_FORM_data1, RVer);
1057 }
1058
1059if (DIUnit->getDWOId()) {
1060// This CU is either a clang module DWO or a skeleton CU.
1061 NewCU.addUInt(Die, dwarf::DW_AT_GNU_dwo_id, dwarf::DW_FORM_data8,
1062 DIUnit->getDWOId());
1063if (!DIUnit->getSplitDebugFilename().empty()) {
1064// This is a prefabricated skeleton CU.
1065dwarf::Attribute attrDWOName =getDwarfVersion() >= 5
1066 ? dwarf::DW_AT_dwo_name
1067 : dwarf::DW_AT_GNU_dwo_name;
1068 NewCU.addString(Die, attrDWOName, DIUnit->getSplitDebugFilename());
1069 }
1070 }
1071}
1072// Create new DwarfCompileUnit for the given metadata node with tag
1073// DW_TAG_compile_unit.
1074DwarfCompileUnit &
1075DwarfDebug::getOrCreateDwarfCompileUnit(constDICompileUnit *DIUnit) {
1076if (auto *CU = CUMap.lookup(DIUnit))
1077return *CU;
1078
1079if (useSplitDwarf() &&
1080 !shareAcrossDWOCUs() &&
1081 (!DIUnit->getSplitDebugInlining() ||
1082 DIUnit->getEmissionKind() ==DICompileUnit::FullDebug) &&
1083 !CUMap.empty()) {
1084return *CUMap.begin()->second;
1085 }
1086 CompilationDir = DIUnit->getDirectory();
1087
1088auto OwnedUnit = std::make_unique<DwarfCompileUnit>(
1089 InfoHolder.getUnits().size(), DIUnit,Asm,this, &InfoHolder);
1090DwarfCompileUnit &NewCU = *OwnedUnit;
1091 InfoHolder.addUnit(std::move(OwnedUnit));
1092
1093// LTO with assembly output shares a single line table amongst multiple CUs.
1094// To avoid the compilation directory being ambiguous, let the line table
1095// explicitly describe the directory of all files, never relying on the
1096// compilation directory.
1097if (!Asm->OutStreamer->hasRawTextSupport() || SingleCU)
1098Asm->OutStreamer->emitDwarfFile0Directive(
1099 CompilationDir, DIUnit->getFilename(),getMD5AsBytes(DIUnit->getFile()),
1100 DIUnit->getSource(), NewCU.getUniqueID());
1101
1102if (useSplitDwarf()) {
1103 NewCU.setSkeleton(constructSkeletonCU(NewCU));
1104 NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoDWOSection());
1105 }else {
1106 finishUnitAttributes(DIUnit, NewCU);
1107 NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoSection());
1108 }
1109
1110 CUMap.insert({DIUnit, &NewCU});
1111 CUDieMap.insert({&NewCU.getUnitDie(), &NewCU});
1112return NewCU;
1113}
1114
1115/// Sort and unique GVEs by comparing their fragment offset.
1116staticSmallVectorImpl<DwarfCompileUnit::GlobalExpr> &
1117sortGlobalExprs(SmallVectorImpl<DwarfCompileUnit::GlobalExpr> &GVEs) {
1118llvm::sort(
1119 GVEs, [](DwarfCompileUnit::GlobalExprA,DwarfCompileUnit::GlobalExprB) {
1120// Sort order: first null exprs, then exprs without fragment
1121// info, then sort by fragment offset in bits.
1122// FIXME: Come up with a more comprehensive comparator so
1123// the sorting isn't non-deterministic, and so the following
1124// std::unique call works correctly.
1125if (!A.Expr || !B.Expr)
1126return !!B.Expr;
1127auto FragmentA =A.Expr->getFragmentInfo();
1128auto FragmentB =B.Expr->getFragmentInfo();
1129if (!FragmentA || !FragmentB)
1130return !!FragmentB;
1131return FragmentA->OffsetInBits < FragmentB->OffsetInBits;
1132 });
1133 GVEs.erase(llvm::unique(GVEs,
1134 [](DwarfCompileUnit::GlobalExprA,
1135DwarfCompileUnit::GlobalExprB) {
1136returnA.Expr ==B.Expr;
1137 }),
1138 GVEs.end());
1139return GVEs;
1140}
1141
1142// Emit all Dwarf sections that should come prior to the content. Create
1143// global DIEs and emit initial debug info sections. This is invoked by
1144// the target AsmPrinter.
1145voidDwarfDebug::beginModule(Module *M) {
1146DebugHandlerBase::beginModule(M);
1147
1148if (!Asm)
1149return;
1150
1151unsigned NumDebugCUs = std::distance(M->debug_compile_units_begin(),
1152 M->debug_compile_units_end());
1153if (NumDebugCUs == 0)
1154return;
1155
1156assert(NumDebugCUs > 0 &&"Asm unexpectedly initialized");
1157 SingleCU = NumDebugCUs == 1;
1158DenseMap<DIGlobalVariable *, SmallVector<DwarfCompileUnit::GlobalExpr, 1>>
1159 GVMap;
1160for (constGlobalVariable &Global : M->globals()) {
1161SmallVector<DIGlobalVariableExpression *, 1> GVs;
1162Global.getDebugInfo(GVs);
1163for (auto *GVE : GVs)
1164 GVMap[GVE->getVariable()].push_back({&Global, GVE->getExpression()});
1165 }
1166
1167// Create the symbol that designates the start of the unit's contribution
1168// to the string offsets table. In a split DWARF scenario, only the skeleton
1169// unit has the DW_AT_str_offsets_base attribute (and hence needs the symbol).
1170if (useSegmentedStringOffsetsTable())
1171 (useSplitDwarf() ? SkeletonHolder : InfoHolder)
1172 .setStringOffsetsStartSym(Asm->createTempSymbol("str_offsets_base"));
1173
1174
1175// Create the symbols that designates the start of the DWARF v5 range list
1176// and locations list tables. They are located past the table headers.
1177if (getDwarfVersion() >= 5) {
1178DwarfFile &Holder =useSplitDwarf() ? SkeletonHolder : InfoHolder;
1179 Holder.setRnglistsTableBaseSym(
1180Asm->createTempSymbol("rnglists_table_base"));
1181
1182if (useSplitDwarf())
1183 InfoHolder.setRnglistsTableBaseSym(
1184Asm->createTempSymbol("rnglists_dwo_table_base"));
1185 }
1186
1187// Create the symbol that points to the first entry following the debug
1188// address table (.debug_addr) header.
1189 AddrPool.setLabel(Asm->createTempSymbol("addr_table_base"));
1190 DebugLocs.setSym(Asm->createTempSymbol("loclists_table_base"));
1191
1192for (DICompileUnit *CUNode : M->debug_compile_units()) {
1193if (CUNode->getImportedEntities().empty() &&
1194 CUNode->getEnumTypes().empty() && CUNode->getRetainedTypes().empty() &&
1195 CUNode->getGlobalVariables().empty() && CUNode->getMacros().empty())
1196continue;
1197
1198DwarfCompileUnit &CU = getOrCreateDwarfCompileUnit(CUNode);
1199
1200// Global Variables.
1201for (auto *GVE : CUNode->getGlobalVariables()) {
1202// Don't bother adding DIGlobalVariableExpressions listed in the CU if we
1203// already know about the variable and it isn't adding a constant
1204// expression.
1205auto &GVMapEntry = GVMap[GVE->getVariable()];
1206auto *Expr = GVE->getExpression();
1207if (!GVMapEntry.size() || (Expr && Expr->isConstant()))
1208 GVMapEntry.push_back({nullptr, Expr});
1209 }
1210
1211DenseSet<DIGlobalVariable *> Processed;
1212for (auto *GVE : CUNode->getGlobalVariables()) {
1213DIGlobalVariable *GV = GVE->getVariable();
1214if (Processed.insert(GV).second)
1215CU.getOrCreateGlobalVariableDIE(GV,sortGlobalExprs(GVMap[GV]));
1216 }
1217
1218for (auto *Ty : CUNode->getEnumTypes())
1219CU.getOrCreateTypeDIE(cast<DIType>(Ty));
1220
1221for (auto *Ty : CUNode->getRetainedTypes()) {
1222// The retained types array by design contains pointers to
1223// MDNodes rather than DIRefs. Unique them here.
1224if (DIType *RT = dyn_cast<DIType>(Ty))
1225// There is no point in force-emitting a forward declaration.
1226CU.getOrCreateTypeDIE(RT);
1227 }
1228 }
1229}
1230
1231void DwarfDebug::finishEntityDefinitions() {
1232for (constauto &Entity : ConcreteEntities) {
1233DIE *Die = Entity->getDIE();
1234assert(Die);
1235// FIXME: Consider the time-space tradeoff of just storing the unit pointer
1236// in the ConcreteEntities list, rather than looking it up again here.
1237// DIE::getUnit isn't simple - it walks parent pointers, etc.
1238DwarfCompileUnit *Unit = CUDieMap.lookup(Die->getUnitDie());
1239assert(Unit);
1240 Unit->finishEntityDefinition(Entity.get());
1241 }
1242}
1243
1244void DwarfDebug::finishSubprogramDefinitions() {
1245for (constDISubprogram *SP : ProcessedSPNodes) {
1246assert(SP->getUnit()->getEmissionKind() !=DICompileUnit::NoDebug);
1247forBothCUs(
1248 getOrCreateDwarfCompileUnit(SP->getUnit()),
1249 [&](DwarfCompileUnit &CU) { CU.finishSubprogramDefinition(SP); });
1250 }
1251}
1252
1253void DwarfDebug::finalizeModuleInfo() {
1254constTargetLoweringObjectFile &TLOF =Asm->getObjFileLowering();
1255
1256 finishSubprogramDefinitions();
1257
1258 finishEntityDefinitions();
1259
1260bool HasEmittedSplitCU =false;
1261
1262// Handle anything that needs to be done on a per-unit basis after
1263// all other generation.
1264for (constauto &P : CUMap) {
1265auto &TheCU = *P.second;
1266if (TheCU.getCUNode()->isDebugDirectivesOnly())
1267continue;
1268// Emit DW_AT_containing_type attribute to connect types with their
1269// vtable holding type.
1270 TheCU.constructContainingTypeDIEs();
1271
1272// Add CU specific attributes if we need to add any.
1273// If we're splitting the dwarf out now that we've got the entire
1274// CU then add the dwo id to it.
1275auto *SkCU = TheCU.getSkeleton();
1276
1277bool HasSplitUnit = SkCU && !TheCU.getUnitDie().children().empty();
1278
1279if (HasSplitUnit) {
1280 (void)HasEmittedSplitCU;
1281assert((shareAcrossDWOCUs() || !HasEmittedSplitCU) &&
1282"Multiple CUs emitted into a single dwo file");
1283 HasEmittedSplitCU =true;
1284dwarf::Attribute attrDWOName =getDwarfVersion() >= 5
1285 ? dwarf::DW_AT_dwo_name
1286 : dwarf::DW_AT_GNU_dwo_name;
1287 finishUnitAttributes(TheCU.getCUNode(), TheCU);
1288StringRef DWOName =Asm->TM.Options.MCOptions.SplitDwarfFile;
1289 TheCU.addString(TheCU.getUnitDie(), attrDWOName, DWOName);
1290 SkCU->addString(SkCU->getUnitDie(), attrDWOName, DWOName);
1291// Emit a unique identifier for this CU. Include the DWO file name in the
1292// hash to avoid the case where two (almost) empty compile units have the
1293// same contents. This can happen if link-time optimization removes nearly
1294// all (unused) code from a CU.
1295uint64_tID =
1296DIEHash(Asm, &TheCU).computeCUSignature(DWOName, TheCU.getUnitDie());
1297if (getDwarfVersion() >= 5) {
1298 TheCU.setDWOId(ID);
1299 SkCU->setDWOId(ID);
1300 }else {
1301 TheCU.addUInt(TheCU.getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
1302 dwarf::DW_FORM_data8,ID);
1303 SkCU->addUInt(SkCU->getUnitDie(), dwarf::DW_AT_GNU_dwo_id,
1304 dwarf::DW_FORM_data8,ID);
1305 }
1306
1307if (getDwarfVersion() < 5 && !SkeletonHolder.getRangeLists().empty()) {
1308constMCSymbol *Sym = TLOF.getDwarfRangesSection()->getBeginSymbol();
1309 SkCU->addSectionLabel(SkCU->getUnitDie(), dwarf::DW_AT_GNU_ranges_base,
1310Sym,Sym);
1311 }
1312 }elseif (SkCU) {
1313 finishUnitAttributes(SkCU->getCUNode(), *SkCU);
1314 }
1315
1316// If we have code split among multiple sections or non-contiguous
1317// ranges of code then emit a DW_AT_ranges attribute on the unit that will
1318// remain in the .o file, otherwise add a DW_AT_low_pc.
1319// FIXME: We should use ranges allow reordering of code ala
1320// .subsections_via_symbols in mach-o. This would mean turning on
1321// ranges for all subprogram DIEs for mach-o.
1322DwarfCompileUnit &U = SkCU ? *SkCU : TheCU;
1323
1324if (unsigned NumRanges = TheCU.getRanges().size()) {
1325// PTX does not support subtracting labels from the code section in the
1326// debug_loc section. To work around this, the NVPTX backend needs the
1327// compile unit to have no low_pc in order to have a zero base_address
1328// when handling debug_loc in cuda-gdb.
1329if (!(Asm->TM.getTargetTriple().isNVPTX() &&tuneForGDB())) {
1330if (NumRanges > 1 &&useRangesSection())
1331// A DW_AT_low_pc attribute may also be specified in combination with
1332// DW_AT_ranges to specify the default base address for use in
1333// location lists (see Section 2.6.2) and range lists (see Section
1334// 2.17.3).
1335U.addUInt(U.getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr,
1336 0);
1337else
1338U.setBaseAddress(TheCU.getRanges().front().Begin);
1339U.attachRangesOrLowHighPC(U.getUnitDie(), TheCU.takeRanges());
1340 }
1341 }
1342
1343// We don't keep track of which addresses are used in which CU so this
1344// is a bit pessimistic under LTO.
1345if ((HasSplitUnit ||getDwarfVersion() >= 5) && !AddrPool.isEmpty())
1346U.addAddrTableBase();
1347
1348if (getDwarfVersion() >= 5) {
1349if (U.hasRangeLists())
1350U.addRnglistsBase();
1351
1352if (!DebugLocs.getLists().empty() && !useSplitDwarf()) {
1353U.addSectionLabel(U.getUnitDie(), dwarf::DW_AT_loclists_base,
1354 DebugLocs.getSym(),
1355 TLOF.getDwarfLoclistsSection()->getBeginSymbol());
1356 }
1357 }
1358
1359auto *CUNode = cast<DICompileUnit>(P.first);
1360// If compile Unit has macros, emit "DW_AT_macro_info/DW_AT_macros"
1361// attribute.
1362if (CUNode->getMacros()) {
1363if (UseDebugMacroSection) {
1364if (useSplitDwarf())
1365 TheCU.addSectionDelta(
1366 TheCU.getUnitDie(), dwarf::DW_AT_macros,U.getMacroLabelBegin(),
1367 TLOF.getDwarfMacroDWOSection()->getBeginSymbol());
1368else {
1369dwarf::Attribute MacrosAttr =getDwarfVersion() >= 5
1370 ? dwarf::DW_AT_macros
1371 : dwarf::DW_AT_GNU_macros;
1372U.addSectionLabel(U.getUnitDie(), MacrosAttr,U.getMacroLabelBegin(),
1373 TLOF.getDwarfMacroSection()->getBeginSymbol());
1374 }
1375 }else {
1376if (useSplitDwarf())
1377 TheCU.addSectionDelta(
1378 TheCU.getUnitDie(), dwarf::DW_AT_macro_info,
1379U.getMacroLabelBegin(),
1380 TLOF.getDwarfMacinfoDWOSection()->getBeginSymbol());
1381else
1382U.addSectionLabel(U.getUnitDie(), dwarf::DW_AT_macro_info,
1383U.getMacroLabelBegin(),
1384 TLOF.getDwarfMacinfoSection()->getBeginSymbol());
1385 }
1386 }
1387 }
1388
1389// Emit all frontend-produced Skeleton CUs, i.e., Clang modules.
1390for (auto *CUNode :MMI->getModule()->debug_compile_units())
1391if (CUNode->getDWOId())
1392 getOrCreateDwarfCompileUnit(CUNode);
1393
1394// Compute DIE offsets and sizes.
1395 InfoHolder.computeSizeAndOffsets();
1396if (useSplitDwarf())
1397 SkeletonHolder.computeSizeAndOffsets();
1398
1399// Now that offsets are computed, can replace DIEs in debug_names Entry with
1400// an actual offset.
1401 AccelDebugNames.convertDieToOffset();
1402}
1403
1404// Emit all Dwarf sections that should come after the content.
1405voidDwarfDebug::endModule() {
1406// Terminate the pending line table.
1407if (PrevCU)
1408terminateLineTable(PrevCU);
1409 PrevCU =nullptr;
1410assert(CurFn ==nullptr);
1411assert(CurMI ==nullptr);
1412
1413for (constauto &P : CUMap) {
1414constauto *CUNode = cast<DICompileUnit>(P.first);
1415DwarfCompileUnit *CU = &*P.second;
1416
1417// Emit imported entities.
1418for (auto *IE : CUNode->getImportedEntities()) {
1419assert(!isa_and_nonnull<DILocalScope>(IE->getScope()) &&
1420"Unexpected function-local entity in 'imports' CU field.");
1421CU->getOrCreateImportedEntityDIE(IE);
1422 }
1423for (constauto *D :CU->getDeferredLocalDecls()) {
1424if (auto *IE = dyn_cast<DIImportedEntity>(D))
1425CU->getOrCreateImportedEntityDIE(IE);
1426else
1427llvm_unreachable("Unexpected local retained node!");
1428 }
1429
1430// Emit base types.
1431CU->createBaseTypeDIEs();
1432 }
1433
1434// If we aren't actually generating debug info (check beginModule -
1435// conditionalized on the presence of the llvm.dbg.cu metadata node)
1436if (!Asm || !Asm->hasDebugInfo())
1437return;
1438
1439// Finalize the debug info for the module.
1440 finalizeModuleInfo();
1441
1442if (useSplitDwarf())
1443// Emit debug_loc.dwo/debug_loclists.dwo section.
1444 emitDebugLocDWO();
1445else
1446// Emit debug_loc/debug_loclists section.
1447 emitDebugLoc();
1448
1449// Corresponding abbreviations into a abbrev section.
1450 emitAbbreviations();
1451
1452// Emit all the DIEs into a debug info section.
1453 emitDebugInfo();
1454
1455// Emit info into a debug aranges section.
1456if (UseARangesSection)
1457 emitDebugARanges();
1458
1459// Emit info into a debug ranges section.
1460 emitDebugRanges();
1461
1462if (useSplitDwarf())
1463// Emit info into a debug macinfo.dwo section.
1464 emitDebugMacinfoDWO();
1465else
1466// Emit info into a debug macinfo/macro section.
1467 emitDebugMacinfo();
1468
1469 emitDebugStr();
1470
1471if (useSplitDwarf()) {
1472 emitDebugStrDWO();
1473 emitDebugInfoDWO();
1474 emitDebugAbbrevDWO();
1475 emitDebugLineDWO();
1476 emitDebugRangesDWO();
1477 }
1478
1479 emitDebugAddr();
1480
1481// Emit info into the dwarf accelerator table sections.
1482switch (getAccelTableKind()) {
1483caseAccelTableKind::Apple:
1484 emitAccelNames();
1485 emitAccelObjC();
1486 emitAccelNamespaces();
1487 emitAccelTypes();
1488break;
1489caseAccelTableKind::Dwarf:
1490 emitAccelDebugNames();
1491break;
1492caseAccelTableKind::None:
1493break;
1494caseAccelTableKind::Default:
1495llvm_unreachable("Default should have already been resolved.");
1496 }
1497
1498// Emit the pubnames and pubtypes sections if requested.
1499 emitDebugPubSections();
1500
1501// clean up.
1502// FIXME: AbstractVariables.clear();
1503}
1504
1505void DwarfDebug::ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &CU,
1506constDINode *Node,constMDNode *ScopeNode) {
1507if (CU.getExistingAbstractEntity(Node))
1508return;
1509
1510if (LexicalScope *Scope =
1511LScopes.findAbstractScope(cast_or_null<DILocalScope>(ScopeNode)))
1512CU.createAbstractEntity(Node, Scope);
1513}
1514
1515staticconstDILocalScope *getRetainedNodeScope(constMDNode *N) {
1516constDIScope *S;
1517if (constauto *LV = dyn_cast<DILocalVariable>(N))
1518 S = LV->getScope();
1519elseif (constauto *L = dyn_cast<DILabel>(N))
1520 S = L->getScope();
1521elseif (constauto *IE = dyn_cast<DIImportedEntity>(N))
1522 S = IE->getScope();
1523else
1524llvm_unreachable("Unexpected retained node!");
1525
1526// Ensure the scope is not a DILexicalBlockFile.
1527return cast<DILocalScope>(S)->getNonLexicalBlockFileScope();
1528}
1529
1530// Collect variable information from side table maintained by MF.
1531void DwarfDebug::collectVariableInfoFromMFTable(
1532DwarfCompileUnit &TheCU,DenseSet<InlinedEntity> &Processed) {
1533SmallDenseMap<InlinedEntity, DbgVariable *> MFVars;
1534LLVM_DEBUG(dbgs() <<"DwarfDebug: collecting variables from MF side table\n");
1535for (constauto &VI :Asm->MF->getVariableDbgInfo()) {
1536if (!VI.Var)
1537continue;
1538assert(VI.Var->isValidLocationForIntrinsic(VI.Loc) &&
1539"Expected inlined-at fields to agree");
1540
1541 InlinedEntity Var(VI.Var,VI.Loc->getInlinedAt());
1542 Processed.insert(Var);
1543LexicalScope *Scope =LScopes.findLexicalScope(VI.Loc);
1544
1545// If variable scope is not found then skip this variable.
1546if (!Scope) {
1547LLVM_DEBUG(dbgs() <<"Dropping debug info for " <<VI.Var->getName()
1548 <<", no variable scope found\n");
1549continue;
1550 }
1551
1552 ensureAbstractEntityIsCreatedIfScoped(TheCU, Var.first,Scope->getScopeNode());
1553
1554// If we have already seen information for this variable, add to what we
1555// already know.
1556if (DbgVariable *PreviousLoc = MFVars.lookup(Var)) {
1557auto *PreviousMMI = std::get_if<Loc::MMI>(PreviousLoc);
1558auto *PreviousEntryValue = std::get_if<Loc::EntryValue>(PreviousLoc);
1559// Previous and new locations are both stack slots (MMI).
1560if (PreviousMMI &&VI.inStackSlot())
1561 PreviousMMI->addFrameIndexExpr(VI.Expr,VI.getStackSlot());
1562// Previous and new locations are both entry values.
1563elseif (PreviousEntryValue &&VI.inEntryValueRegister())
1564 PreviousEntryValue->addExpr(VI.getEntryValueRegister(), *VI.Expr);
1565else {
1566// Locations differ, this should (rarely) happen in optimized async
1567// coroutines.
1568// Prefer whichever location has an EntryValue.
1569if (PreviousLoc->holds<Loc::MMI>())
1570 PreviousLoc->emplace<Loc::EntryValue>(VI.getEntryValueRegister(),
1571 *VI.Expr);
1572LLVM_DEBUG(dbgs() <<"Dropping debug info for " <<VI.Var->getName()
1573 <<", conflicting fragment location types\n");
1574 }
1575continue;
1576 }
1577
1578auto RegVar = std::make_unique<DbgVariable>(
1579 cast<DILocalVariable>(Var.first), Var.second);
1580if (VI.inStackSlot())
1581 RegVar->emplace<Loc::MMI>(VI.Expr,VI.getStackSlot());
1582else
1583 RegVar->emplace<Loc::EntryValue>(VI.getEntryValueRegister(), *VI.Expr);
1584LLVM_DEBUG(dbgs() <<"Created DbgVariable for " <<VI.Var->getName()
1585 <<"\n");
1586 InfoHolder.addScopeVariable(Scope, RegVar.get());
1587 MFVars.insert({Var, RegVar.get()});
1588 ConcreteEntities.push_back(std::move(RegVar));
1589 }
1590}
1591
1592/// Determine whether a *singular* DBG_VALUE is valid for the entirety of its
1593/// enclosing lexical scope. The check ensures there are no other instructions
1594/// in the same lexical scope preceding the DBG_VALUE and that its range is
1595/// either open or otherwise rolls off the end of the scope.
1596staticboolvalidThroughout(LexicalScopes &LScopes,
1597constMachineInstr *DbgValue,
1598constMachineInstr *RangeEnd,
1599constInstructionOrdering &Ordering) {
1600assert(DbgValue->getDebugLoc() &&"DBG_VALUE without a debug location");
1601autoMBB =DbgValue->getParent();
1602autoDL =DbgValue->getDebugLoc();
1603auto *LScope = LScopes.findLexicalScope(DL);
1604// Scope doesn't exist; this is a dead DBG_VALUE.
1605if (!LScope)
1606returnfalse;
1607auto &LSRange = LScope->getRanges();
1608if (LSRange.size() == 0)
1609returnfalse;
1610
1611constMachineInstr *LScopeBegin = LSRange.front().first;
1612// If the scope starts before the DBG_VALUE then we may have a negative
1613// result. Otherwise the location is live coming into the scope and we
1614// can skip the following checks.
1615if (!Ordering.isBefore(DbgValue, LScopeBegin)) {
1616// Exit if the lexical scope begins outside of the current block.
1617if (LScopeBegin->getParent() !=MBB)
1618returnfalse;
1619
1620MachineBasicBlock::const_reverse_iterator Pred(DbgValue);
1621for (++Pred; Pred !=MBB->rend(); ++Pred) {
1622if (Pred->getFlag(MachineInstr::FrameSetup))
1623break;
1624auto PredDL = Pred->getDebugLoc();
1625if (!PredDL || Pred->isMetaInstruction())
1626continue;
1627// Check whether the instruction preceding the DBG_VALUE is in the same
1628// (sub)scope as the DBG_VALUE.
1629if (DL->getScope() == PredDL->getScope())
1630returnfalse;
1631auto *PredScope = LScopes.findLexicalScope(PredDL);
1632if (!PredScope || LScope->dominates(PredScope))
1633returnfalse;
1634 }
1635 }
1636
1637// If the range of the DBG_VALUE is open-ended, report success.
1638if (!RangeEnd)
1639returntrue;
1640
1641// Single, constant DBG_VALUEs in the prologue are promoted to be live
1642// throughout the function. This is a hack, presumably for DWARF v2 and not
1643// necessarily correct. It would be much better to use a dbg.declare instead
1644// if we know the constant is live throughout the scope.
1645if (MBB->pred_empty() &&
1646all_of(DbgValue->debug_operands(),
1647 [](constMachineOperand &Op) { return Op.isImm(); }))
1648returntrue;
1649
1650// Test if the location terminates before the end of the scope.
1651constMachineInstr *LScopeEnd = LSRange.back().second;
1652if (Ordering.isBefore(RangeEnd, LScopeEnd))
1653returnfalse;
1654
1655// There's a single location which starts at the scope start, and ends at or
1656// after the scope end.
1657returntrue;
1658}
1659
1660/// Build the location list for all DBG_VALUEs in the function that
1661/// describe the same variable. The resulting DebugLocEntries will have
1662/// strict monotonically increasing begin addresses and will never
1663/// overlap. If the resulting list has only one entry that is valid
1664/// throughout variable's scope return true.
1665//
1666// See the definition of DbgValueHistoryMap::Entry for an explanation of the
1667// different kinds of history map entries. One thing to be aware of is that if
1668// a debug value is ended by another entry (rather than being valid until the
1669// end of the function), that entry's instruction may or may not be included in
1670// the range, depending on if the entry is a clobbering entry (it has an
1671// instruction that clobbers one or more preceding locations), or if it is an
1672// (overlapping) debug value entry. This distinction can be seen in the example
1673// below. The first debug value is ended by the clobbering entry 2, and the
1674// second and third debug values are ended by the overlapping debug value entry
1675// 4.
1676//
1677// Input:
1678//
1679// History map entries [type, end index, mi]
1680//
1681// 0 | [DbgValue, 2, DBG_VALUE $reg0, [...] (fragment 0, 32)]
1682// 1 | | [DbgValue, 4, DBG_VALUE $reg1, [...] (fragment 32, 32)]
1683// 2 | | [Clobber, $reg0 = [...], -, -]
1684// 3 | | [DbgValue, 4, DBG_VALUE 123, [...] (fragment 64, 32)]
1685// 4 [DbgValue, ~0, DBG_VALUE @g, [...] (fragment 0, 96)]
1686//
1687// Output [start, end) [Value...]:
1688//
1689// [0-1) [(reg0, fragment 0, 32)]
1690// [1-3) [(reg0, fragment 0, 32), (reg1, fragment 32, 32)]
1691// [3-4) [(reg1, fragment 32, 32), (123, fragment 64, 32)]
1692// [4-) [(@g, fragment 0, 96)]
1693bool DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
1694constDbgValueHistoryMap::Entries &Entries) {
1695usingOpenRange =
1696 std::pair<DbgValueHistoryMap::EntryIndex, DbgValueLoc>;
1697SmallVector<OpenRange, 4> OpenRanges;
1698bool isSafeForSingleLocation =true;
1699constMachineInstr *StartDebugMI =nullptr;
1700constMachineInstr *EndMI =nullptr;
1701
1702for (auto EB = Entries.begin(), EI = EB, EE = Entries.end(); EI != EE; ++EI) {
1703constMachineInstr *Instr = EI->getInstr();
1704
1705// Remove all values that are no longer live.
1706size_tIndex = std::distance(EB, EI);
1707erase_if(OpenRanges, [&](OpenRange &R) {returnR.first <=Index; });
1708
1709// If we are dealing with a clobbering entry, this iteration will result in
1710// a location list entry starting after the clobbering instruction.
1711constMCSymbol *StartLabel =
1712 EI->isClobber() ?getLabelAfterInsn(Instr) :getLabelBeforeInsn(Instr);
1713assert(StartLabel &&
1714"Forgot label before/after instruction starting a range!");
1715
1716constMCSymbol *EndLabel;
1717if (std::next(EI) == Entries.end()) {
1718constMachineBasicBlock &EndMBB =Asm->MF->back();
1719 EndLabel =Asm->MBBSectionRanges[EndMBB.getSectionID()].EndLabel;
1720if (EI->isClobber())
1721 EndMI = EI->getInstr();
1722 }
1723elseif (std::next(EI)->isClobber())
1724 EndLabel =getLabelAfterInsn(std::next(EI)->getInstr());
1725else
1726 EndLabel =getLabelBeforeInsn(std::next(EI)->getInstr());
1727assert(EndLabel &&"Forgot label after instruction ending a range!");
1728
1729if (EI->isDbgValue())
1730LLVM_DEBUG(dbgs() <<"DotDebugLoc: " << *Instr <<"\n");
1731
1732// If this history map entry has a debug value, add that to the list of
1733// open ranges and check if its location is valid for a single value
1734// location.
1735if (EI->isDbgValue()) {
1736// Do not add undef debug values, as they are redundant information in
1737// the location list entries. An undef debug results in an empty location
1738// description. If there are any non-undef fragments then padding pieces
1739// with empty location descriptions will automatically be inserted, and if
1740// all fragments are undef then the whole location list entry is
1741// redundant.
1742if (!Instr->isUndefDebugValue()) {
1743autoValue =getDebugLocValue(Instr);
1744 OpenRanges.emplace_back(EI->getEndIndex(),Value);
1745
1746// TODO: Add support for single value fragment locations.
1747if (Instr->getDebugExpression()->isFragment())
1748 isSafeForSingleLocation =false;
1749
1750if (!StartDebugMI)
1751 StartDebugMI =Instr;
1752 }else {
1753 isSafeForSingleLocation =false;
1754 }
1755 }
1756
1757// Location list entries with empty location descriptions are redundant
1758// information in DWARF, so do not emit those.
1759if (OpenRanges.empty())
1760continue;
1761
1762// Omit entries with empty ranges as they do not have any effect in DWARF.
1763if (StartLabel == EndLabel) {
1764LLVM_DEBUG(dbgs() <<"Omitting location list entry with empty range.\n");
1765continue;
1766 }
1767
1768SmallVector<DbgValueLoc, 4> Values;
1769for (auto &R : OpenRanges)
1770 Values.push_back(R.second);
1771
1772// With Basic block sections, it is posssible that the StartLabel and the
1773// Instr are not in the same section. This happens when the StartLabel is
1774// the function begin label and the dbg value appears in a basic block
1775// that is not the entry. In this case, the range needs to be split to
1776// span each individual section in the range from StartLabel to EndLabel.
1777if (Asm->MF->hasBBSections() && StartLabel ==Asm->getFunctionBegin() &&
1778 !Instr->getParent()->sameSection(&Asm->MF->front())) {
1779for (constauto &[MBBSectionId, MBBSectionRange] :
1780Asm->MBBSectionRanges) {
1781if (Instr->getParent()->getSectionID() == MBBSectionId) {
1782DebugLoc.emplace_back(MBBSectionRange.BeginLabel, EndLabel, Values);
1783break;
1784 }
1785DebugLoc.emplace_back(MBBSectionRange.BeginLabel,
1786 MBBSectionRange.EndLabel, Values);
1787 }
1788 }else {
1789DebugLoc.emplace_back(StartLabel, EndLabel, Values);
1790 }
1791
1792// Attempt to coalesce the ranges of two otherwise identical
1793// DebugLocEntries.
1794auto CurEntry =DebugLoc.rbegin();
1795LLVM_DEBUG({
1796dbgs() << CurEntry->getValues().size() <<" Values:\n";
1797for (auto &Value : CurEntry->getValues())
1798Value.dump();
1799dbgs() <<"-----\n";
1800 });
1801
1802auto PrevEntry = std::next(CurEntry);
1803if (PrevEntry !=DebugLoc.rend() && PrevEntry->MergeRanges(*CurEntry))
1804DebugLoc.pop_back();
1805 }
1806
1807if (!isSafeForSingleLocation ||
1808 !validThroughout(LScopes, StartDebugMI, EndMI,getInstOrdering()))
1809returnfalse;
1810
1811if (DebugLoc.size() == 1)
1812returntrue;
1813
1814if (!Asm->MF->hasBBSections())
1815returnfalse;
1816
1817// Check here to see if loclist can be merged into a single range. If not,
1818// we must keep the split loclists per section. This does exactly what
1819// MergeRanges does without sections. We don't actually merge the ranges
1820// as the split ranges must be kept intact if this cannot be collapsed
1821// into a single range.
1822constMachineBasicBlock *RangeMBB =nullptr;
1823if (DebugLoc[0].getBeginSym() ==Asm->getFunctionBegin())
1824 RangeMBB = &Asm->MF->front();
1825else
1826 RangeMBB = Entries.begin()->getInstr()->getParent();
1827auto RangeIt =Asm->MBBSectionRanges.find(RangeMBB->getSectionID());
1828assert(RangeIt !=Asm->MBBSectionRanges.end() &&
1829"Range MBB not found in MBBSectionRanges!");
1830auto *CurEntry =DebugLoc.begin();
1831auto *NextEntry = std::next(CurEntry);
1832auto NextRangeIt = std::next(RangeIt);
1833while (NextEntry !=DebugLoc.end()) {
1834if (NextRangeIt ==Asm->MBBSectionRanges.end())
1835returnfalse;
1836// CurEntry should end the current section and NextEntry should start
1837// the next section and the Values must match for these two ranges to be
1838// merged. Do not match the section label end if it is the entry block
1839// section. This is because the end label for the Debug Loc and the
1840// Function end label could be different.
1841if ((RangeIt->second.EndLabel !=Asm->getFunctionEnd() &&
1842 CurEntry->getEndSym() != RangeIt->second.EndLabel) ||
1843 NextEntry->getBeginSym() != NextRangeIt->second.BeginLabel ||
1844 CurEntry->getValues() != NextEntry->getValues())
1845returnfalse;
1846 RangeIt = NextRangeIt;
1847 NextRangeIt = std::next(RangeIt);
1848 CurEntry = NextEntry;
1849 NextEntry = std::next(CurEntry);
1850 }
1851returntrue;
1852}
1853
1854DbgEntity *DwarfDebug::createConcreteEntity(DwarfCompileUnit &TheCU,
1855LexicalScope &Scope,
1856constDINode *Node,
1857constDILocation *Location,
1858constMCSymbol *Sym) {
1859 ensureAbstractEntityIsCreatedIfScoped(TheCU,Node,Scope.getScopeNode());
1860if (isa<const DILocalVariable>(Node)) {
1861 ConcreteEntities.push_back(
1862 std::make_unique<DbgVariable>(cast<const DILocalVariable>(Node),
1863 Location));
1864 InfoHolder.addScopeVariable(&Scope,
1865 cast<DbgVariable>(ConcreteEntities.back().get()));
1866 }elseif (isa<const DILabel>(Node)) {
1867 ConcreteEntities.push_back(
1868 std::make_unique<DbgLabel>(cast<const DILabel>(Node),
1869 Location,Sym));
1870 InfoHolder.addScopeLabel(&Scope,
1871 cast<DbgLabel>(ConcreteEntities.back().get()));
1872 }
1873return ConcreteEntities.back().get();
1874}
1875
1876// Find variables for each lexical scope.
1877void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
1878constDISubprogram *SP,
1879DenseSet<InlinedEntity> &Processed) {
1880// Grab the variable info that was squirreled away in the MMI side-table.
1881 collectVariableInfoFromMFTable(TheCU, Processed);
1882
1883for (constauto &I :DbgValues) {
1884 InlinedEntityIV =I.first;
1885if (Processed.count(IV))
1886continue;
1887
1888// Instruction ranges, specifying where IV is accessible.
1889constauto &HistoryMapEntries =I.second;
1890
1891// Try to find any non-empty variable location. Do not create a concrete
1892// entity if there are no locations.
1893if (!DbgValues.hasNonEmptyLocation(HistoryMapEntries))
1894continue;
1895
1896LexicalScope *Scope =nullptr;
1897constDILocalVariable *LocalVar = cast<DILocalVariable>(IV.first);
1898if (constDILocation *IA =IV.second)
1899Scope =LScopes.findInlinedScope(LocalVar->getScope(), IA);
1900else
1901Scope =LScopes.findLexicalScope(LocalVar->getScope());
1902// If variable scope is not found then skip this variable.
1903if (!Scope)
1904continue;
1905
1906 Processed.insert(IV);
1907DbgVariable *RegVar = cast<DbgVariable>(createConcreteEntity(TheCU,
1908 *Scope, LocalVar,IV.second));
1909
1910constMachineInstr *MInsn = HistoryMapEntries.front().getInstr();
1911assert(MInsn->isDebugValue() &&"History must begin with debug value");
1912
1913// Check if there is a single DBG_VALUE, valid throughout the var's scope.
1914// If the history map contains a single debug value, there may be an
1915// additional entry which clobbers the debug value.
1916size_t HistSize = HistoryMapEntries.size();
1917bool SingleValueWithClobber =
1918 HistSize == 2 && HistoryMapEntries[1].isClobber();
1919if (HistSize == 1 || SingleValueWithClobber) {
1920constauto *End =
1921 SingleValueWithClobber ? HistoryMapEntries[1].getInstr() :nullptr;
1922if (validThroughout(LScopes, MInsn,End,getInstOrdering())) {
1923 RegVar->emplace<Loc::Single>(MInsn);
1924continue;
1925 }
1926 }
1927
1928// Handle multiple DBG_VALUE instructions describing one variable.
1929DebugLocStream::ListBuilderList(DebugLocs, TheCU, *Asm, *RegVar);
1930
1931// Build the location list for this variable.
1932SmallVector<DebugLocEntry, 8> Entries;
1933bool isValidSingleLocation = buildLocationList(Entries, HistoryMapEntries);
1934
1935// Check whether buildLocationList managed to merge all locations to one
1936// that is valid throughout the variable's scope. If so, produce single
1937// value location.
1938if (isValidSingleLocation) {
1939 RegVar->emplace<Loc::Single>(Entries[0].getValues()[0]);
1940continue;
1941 }
1942
1943// If the variable has a DIBasicType, extract it. Basic types cannot have
1944// unique identifiers, so don't bother resolving the type with the
1945// identifier map.
1946constDIBasicType *BT = dyn_cast<DIBasicType>(
1947static_cast<constMetadata *>(LocalVar->getType()));
1948
1949// Finalize the entry by lowering it into a DWARF bytestream.
1950for (auto &Entry : Entries)
1951Entry.finalize(*Asm,List,BT, TheCU);
1952 }
1953
1954// For each InlinedEntity collected from DBG_LABEL instructions, convert to
1955// DWARF-related DbgLabel.
1956for (constauto &I :DbgLabels) {
1957 InlinedEntity IL =I.first;
1958constMachineInstr *MI =I.second;
1959if (MI ==nullptr)
1960continue;
1961
1962LexicalScope *Scope =nullptr;
1963constDILabel *Label = cast<DILabel>(IL.first);
1964// The scope could have an extra lexical block file.
1965constDILocalScope *LocalScope =
1966Label->getScope()->getNonLexicalBlockFileScope();
1967// Get inlined DILocation if it is inlined label.
1968if (constDILocation *IA = IL.second)
1969Scope =LScopes.findInlinedScope(LocalScope, IA);
1970else
1971Scope =LScopes.findLexicalScope(LocalScope);
1972// If label scope is not found then skip this label.
1973if (!Scope)
1974continue;
1975
1976 Processed.insert(IL);
1977 /// At this point, the temporary label is created.
1978 /// Save the temporary label to DbgLabel entity to get the
1979 /// actually address when generating Dwarf DIE.
1980MCSymbol *Sym =getLabelBeforeInsn(MI);
1981 createConcreteEntity(TheCU, *Scope, Label, IL.second,Sym);
1982 }
1983
1984// Collect info for retained nodes.
1985for (constDINode *DN : SP->getRetainedNodes()) {
1986constauto *LS =getRetainedNodeScope(DN);
1987if (isa<DILocalVariable>(DN) || isa<DILabel>(DN)) {
1988if (!Processed.insert(InlinedEntity(DN,nullptr)).second)
1989continue;
1990LexicalScope *LexS =LScopes.findLexicalScope(LS);
1991if (LexS)
1992 createConcreteEntity(TheCU, *LexS, DN,nullptr);
1993 }else {
1994 LocalDeclsPerLS[LS].insert(DN);
1995 }
1996 }
1997}
1998
1999// Process beginning of an instruction.
2000voidDwarfDebug::beginInstruction(constMachineInstr *MI) {
2001constMachineFunction &MF = *MI->getMF();
2002constauto *SP = MF.getFunction().getSubprogram();
2003bool NoDebug =
2004 !SP || SP->getUnit()->getEmissionKind() ==DICompileUnit::NoDebug;
2005
2006// Delay slot support check.
2007auto delaySlotSupported = [](constMachineInstr &MI) {
2008if (!MI.isBundledWithSucc())
2009returnfalse;
2010auto Suc = std::next(MI.getIterator());
2011 (void)Suc;
2012// Ensure that delay slot instruction is successor of the call instruction.
2013// Ex. CALL_INSTRUCTION {
2014// DELAY_SLOT_INSTRUCTION }
2015assert(Suc->isBundledWithPred() &&
2016"Call bundle instructions are out of order");
2017returntrue;
2018 };
2019
2020// When describing calls, we need a label for the call instruction.
2021if (!NoDebug && SP->areAllCallsDescribed() &&
2022MI->isCandidateForAdditionalCallInfo(MachineInstr::AnyInBundle) &&
2023 (!MI->hasDelaySlot() || delaySlotSupported(*MI))) {
2024constTargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
2025bool IsTail =TII->isTailCall(*MI);
2026// For tail calls, we need the address of the branch instruction for
2027// DW_AT_call_pc.
2028if (IsTail)
2029requestLabelBeforeInsn(MI);
2030// For non-tail calls, we need the return address for the call for
2031// DW_AT_call_return_pc. Under GDB tuning, this information is needed for
2032// tail calls as well.
2033requestLabelAfterInsn(MI);
2034 }
2035
2036DebugHandlerBase::beginInstruction(MI);
2037if (!CurMI)
2038return;
2039
2040if (NoDebug)
2041return;
2042
2043// Check if source location changes, but ignore DBG_VALUE and CFI locations.
2044// If the instruction is part of the function frame setup code, do not emit
2045// any line record, as there is no correspondence with any user code.
2046if (MI->isMetaInstruction() ||MI->getFlag(MachineInstr::FrameSetup))
2047return;
2048constDebugLoc &DL =MI->getDebugLoc();
2049unsigned Flags = 0;
2050
2051if (MI->getFlag(MachineInstr::FrameDestroy) &&DL) {
2052constMachineBasicBlock *MBB =MI->getParent();
2053if (MBB && (MBB !=EpilogBeginBlock)) {
2054// First time FrameDestroy has been seen in this basic block
2055EpilogBeginBlock =MBB;
2056 Flags |=DWARF2_FLAG_EPILOGUE_BEGIN;
2057 }
2058 }
2059
2060// When we emit a line-0 record, we don't update PrevInstLoc; so look at
2061// the last line number actually emitted, to see if it was line 0.
2062unsigned LastAsmLine =
2063Asm->OutStreamer->getContext().getCurrentDwarfLoc().getLine();
2064
2065if (!DL &&MI ==PrologEndLoc) {
2066// In rare situations, we might want to place the end of the prologue
2067// somewhere that doesn't have a source location already. It should be in
2068// the entry block.
2069assert(MI->getParent() == &*MI->getMF()->begin());
2070 recordSourceLine(SP->getScopeLine(), 0, SP,
2071DWARF2_FLAG_PROLOGUE_END |DWARF2_FLAG_IS_STMT);
2072return;
2073 }
2074
2075bool PrevInstInSameSection =
2076 (!PrevInstBB ||
2077PrevInstBB->getSectionID() ==MI->getParent()->getSectionID());
2078bool ForceIsStmt = ForceIsStmtInstrs.contains(MI);
2079if (DL ==PrevInstLoc && PrevInstInSameSection && !ForceIsStmt) {
2080// If we have an ongoing unspecified location, nothing to do here.
2081if (!DL)
2082return;
2083// We have an explicit location, same as the previous location.
2084// But we might be coming back to it after a line 0 record.
2085if ((LastAsmLine == 0 &&DL.getLine() != 0) || Flags) {
2086// Reinstate the source location but not marked as a statement.
2087constMDNode *Scope =DL.getScope();
2088 recordSourceLine(DL.getLine(),DL.getCol(), Scope, Flags);
2089 }
2090return;
2091 }
2092
2093if (!DL) {
2094// We have an unspecified location, which might want to be line 0.
2095// If we have already emitted a line-0 record, don't repeat it.
2096if (LastAsmLine == 0)
2097return;
2098// If user said Don't Do That, don't do that.
2099if (UnknownLocations ==Disable)
2100return;
2101// See if we have a reason to emit a line-0 record now.
2102// Reasons to emit a line-0 record include:
2103// - User asked for it (UnknownLocations).
2104// - Instruction has a label, so it's referenced from somewhere else,
2105// possibly debug information; we want it to have a source location.
2106// - Instruction is at the top of a block; we don't want to inherit the
2107// location from the physically previous (maybe unrelated) block.
2108if (UnknownLocations ==Enable ||PrevLabel ||
2109 (PrevInstBB &&PrevInstBB !=MI->getParent())) {
2110// Preserve the file and column numbers, if we can, to save space in
2111// the encoded line table.
2112// Do not update PrevInstLoc, it remembers the last non-0 line.
2113constMDNode *Scope =nullptr;
2114unsigned Column = 0;
2115if (PrevInstLoc) {
2116 Scope =PrevInstLoc.getScope();
2117 Column =PrevInstLoc.getCol();
2118 }
2119 recordSourceLine(/*Line=*/0, Column, Scope,/*Flags=*/0);
2120 }
2121return;
2122 }
2123
2124// We have an explicit location, different from the previous location.
2125// Don't repeat a line-0 record, but otherwise emit the new location.
2126// (The new location might be an explicit line 0, which we do emit.)
2127if (DL.getLine() == 0 && LastAsmLine == 0)
2128return;
2129if (MI ==PrologEndLoc) {
2130 Flags |=DWARF2_FLAG_PROLOGUE_END |DWARF2_FLAG_IS_STMT;
2131PrologEndLoc =nullptr;
2132 }
2133// If the line changed, we call that a new statement; unless we went to
2134// line 0 and came back, in which case it is not a new statement.
2135unsigned OldLine =PrevInstLoc ?PrevInstLoc.getLine() : LastAsmLine;
2136if (DL.getLine() && (DL.getLine() != OldLine || ForceIsStmt))
2137 Flags |=DWARF2_FLAG_IS_STMT;
2138
2139constMDNode *Scope =DL.getScope();
2140 recordSourceLine(DL.getLine(),DL.getCol(), Scope, Flags);
2141
2142// If we're not at line 0, remember this location.
2143if (DL.getLine())
2144PrevInstLoc =DL;
2145}
2146
2147static std::pair<const MachineInstr *, bool>
2148findPrologueEndLoc(constMachineFunction *MF) {
2149// First known non-DBG_VALUE and non-frame setup location marks
2150// the beginning of the function body.
2151constauto &TII = *MF->getSubtarget().getInstrInfo();
2152constMachineInstr *NonTrivialInst =nullptr;
2153constFunction &F = MF->getFunction();
2154
2155// Some instructions may be inserted into prologue after this function. Must
2156// keep prologue for these cases.
2157bool IsEmptyPrologue =
2158 !(F.hasPrologueData() ||F.getMetadata(LLVMContext::MD_func_sanitize));
2159
2160// Helper lambda to examine each instruction and potentially return it
2161// as the prologue_end point.
2162auto ExamineInst = [&](constMachineInstr &MI)
2163 -> std::optional<std::pair<const MachineInstr *, bool>> {
2164// Is this instruction trivial data shuffling or frame-setup?
2165boolisCopy = (TII.isCopyInstr(MI) ?true :false);
2166bool isTrivRemat =TII.isTriviallyReMaterializable(MI);
2167bool isFrameSetup =MI.getFlag(MachineInstr::FrameSetup);
2168
2169if (!isFrameSetup &&MI.getDebugLoc()) {
2170// Scan forward to try to find a non-zero line number. The
2171// prologue_end marks the first breakpoint in the function after the
2172// frame setup, and a compiler-generated line 0 location is not a
2173// meaningful breakpoint. If none is found, return the first
2174// location after the frame setup.
2175if (MI.getDebugLoc().getLine())
2176return std::make_pair(&MI, IsEmptyPrologue);
2177 }
2178
2179// Keep track of the first "non-trivial" instruction seen, i.e. anything
2180// that doesn't involve shuffling data around or is a frame-setup.
2181if (!isCopy && !isTrivRemat && !isFrameSetup && !NonTrivialInst)
2182 NonTrivialInst = &MI;
2183
2184 IsEmptyPrologue =false;
2185return std::nullopt;
2186 };
2187
2188// Examine all the instructions at the start of the function. This doesn't
2189// necessarily mean just the entry block: unoptimised code can fall-through
2190// into an initial loop, and it makes sense to put the initial breakpoint on
2191// the first instruction of such a loop. However, if we pass branches, we're
2192// better off synthesising an early prologue_end.
2193auto CurBlock = MF->begin();
2194auto CurInst = CurBlock->begin();
2195
2196// Find the initial instruction, we're guaranteed one by the caller, but not
2197// which block it's in.
2198while (CurBlock->empty())
2199 CurInst = (++CurBlock)->begin();
2200assert(CurInst != CurBlock->end());
2201
2202// Helper function for stepping through the initial sequence of
2203// unconditionally executed instructions.
2204auto getNextInst = [&CurBlock, &CurInst, MF]() ->bool {
2205// We've reached the end of the block. Did we just look at a terminator?
2206if (CurInst->isTerminator()) {
2207// Some kind of "real" control flow is occurring. At the very least
2208// we would have to start exploring the CFG, a good signal that the
2209// prologue is over.
2210returnfalse;
2211 }
2212
2213// If we've already fallen through into a loop, don't fall through
2214// further, use a backup-location.
2215if (CurBlock->pred_size() > 1)
2216returnfalse;
2217
2218// Fall-through from entry to the next block. This is common at -O0 when
2219// there's no initialisation in the function. Bail if we're also at the
2220// end of the function, or the remaining blocks have no instructions.
2221// Skip empty blocks, in rare cases the entry can be empty, and
2222// other optimisations may add empty blocks that the control flow falls
2223// through.
2224do {
2225 ++CurBlock;
2226if (CurBlock == MF->end())
2227returnfalse;
2228 }while (CurBlock->empty());
2229 CurInst = CurBlock->begin();
2230returntrue;
2231 };
2232
2233while (true) {
2234// Check whether this non-meta instruction a good position for prologue_end.
2235if (!CurInst->isMetaInstruction()) {
2236auto FoundInst = ExamineInst(*CurInst);
2237if (FoundInst)
2238return *FoundInst;
2239 }
2240
2241// Try to continue searching, but use a backup-location if substantive
2242// computation is happening.
2243auto NextInst = std::next(CurInst);
2244if (NextInst != CurInst->getParent()->end()) {
2245// Continue examining the current block.
2246 CurInst = NextInst;
2247continue;
2248 }
2249
2250if (!getNextInst())
2251break;
2252 }
2253
2254// We couldn't find any source-location, suggesting all meaningful information
2255// got optimised away. Set the prologue_end to be the first non-trivial
2256// instruction, which will get the scope line number. This is better than
2257// nothing.
2258// Only do this in the entry block, as we'll be giving it the scope line for
2259// the function. Return IsEmptyPrologue==true if we've picked the first
2260// instruction.
2261if (NonTrivialInst && NonTrivialInst->getParent() == &*MF->begin()) {
2262 IsEmptyPrologue = NonTrivialInst == &*MF->begin()->begin();
2263return std::make_pair(NonTrivialInst, IsEmptyPrologue);
2264 }
2265
2266// If the entry path is empty, just don't have a prologue_end at all.
2267return std::make_pair(nullptr, IsEmptyPrologue);
2268}
2269
2270/// Register a source line with debug info. Returns the unique label that was
2271/// emitted and which provides correspondence to the source line list.
2272staticvoidrecordSourceLine(AsmPrinter &Asm,unsigned Line,unsigned Col,
2273constMDNode *S,unsigned Flags,unsigned CUID,
2274uint16_t DwarfVersion,
2275ArrayRef<std::unique_ptr<DwarfCompileUnit>> DCUs) {
2276StringRef Fn;
2277unsigned FileNo = 1;
2278unsigned Discriminator = 0;
2279if (auto *Scope = cast_or_null<DIScope>(S)) {
2280 Fn = Scope->getFilename();
2281if (Line != 0 && DwarfVersion >= 4)
2282if (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope))
2283 Discriminator = LBF->getDiscriminator();
2284
2285 FileNo =static_cast<DwarfCompileUnit &>(*DCUs[CUID])
2286 .getOrCreateSourceID(Scope->getFile());
2287 }
2288 Asm.OutStreamer->emitDwarfLocDirective(FileNo, Line, Col, Flags, 0,
2289 Discriminator, Fn);
2290}
2291
2292constMachineInstr *
2293DwarfDebug::emitInitialLocDirective(constMachineFunction &MF,unsigned CUID) {
2294// Don't deal with functions that have no instructions.
2295if (llvm::all_of(MF, [](constMachineBasicBlock &MBB) {returnMBB.empty(); }))
2296returnnullptr;
2297
2298 std::pair<const MachineInstr *, bool> PrologEnd =findPrologueEndLoc(&MF);
2299constMachineInstr *PrologEndLoc = PrologEnd.first;
2300bool IsEmptyPrologue = PrologEnd.second;
2301
2302// If the prolog is empty, no need to generate scope line for the proc.
2303if (IsEmptyPrologue) {
2304// If there's nowhere to put a prologue_end flag, emit a scope line in case
2305// there are simply no source locations anywhere in the function.
2306if (PrologEndLoc) {
2307// Avoid trying to assign prologue_end to a line-zero location.
2308// Instructions with no DebugLoc at all are fine, they'll be given the
2309// scope line nuumber.
2310constDebugLoc &DL =PrologEndLoc->getDebugLoc();
2311if (!DL ||DL->getLine() != 0)
2312returnPrologEndLoc;
2313
2314// Later, don't place the prologue_end flag on this line-zero location.
2315PrologEndLoc =nullptr;
2316 }
2317 }
2318
2319// Ensure the compile unit is created if the function is called before
2320// beginFunction().
2321DISubprogram *SP = MF.getFunction().getSubprogram();
2322 (void)getOrCreateDwarfCompileUnit(SP->getUnit());
2323// We'd like to list the prologue as "not statements" but GDB behaves
2324// poorly if we do that. Revisit this with caution/GDB (7.5+) testing.
2325 ::recordSourceLine(*Asm, SP->getScopeLine(), 0, SP,DWARF2_FLAG_IS_STMT,
2326 CUID,getDwarfVersion(), getUnits());
2327returnPrologEndLoc;
2328}
2329
2330/// For the function \p MF, finds the set of instructions which may represent a
2331/// change in line number from one or more of the preceding MBBs. Stores the
2332/// resulting set of instructions, which should have is_stmt set, in
2333/// ForceIsStmtInstrs.
2334void DwarfDebug::findForceIsStmtInstrs(constMachineFunction *MF) {
2335 ForceIsStmtInstrs.clear();
2336
2337// For this function, we try to find MBBs where the last source line in every
2338// block predecessor matches the first line seen in the block itself; for
2339// every such MBB, we set is_stmt=false on the first line in the block, and
2340// for every other block we set is_stmt=true on the first line.
2341// For example, if we have the block %bb.3, which has 2 predecesors %bb.1 and
2342// %bb.2:
2343// bb.1:
2344// $r3 = MOV64ri 12, debug-location !DILocation(line: 4)
2345// JMP %bb.3, debug-location !DILocation(line: 5)
2346// bb.2:
2347// $r3 = MOV64ri 24, debug-location !DILocation(line: 5)
2348// JMP %bb.3
2349// bb.3:
2350// $r2 = MOV64ri 1
2351// $r1 = ADD $r2, $r3, debug-location !DILocation(line: 5)
2352// When we examine %bb.3, we first check to see if it contains any
2353// instructions with debug locations, and select the first such instruction;
2354// in this case, the ADD, with line=5. We then examine both of its
2355// predecessors to see what the last debug-location in them is. For each
2356// predecessor, if they do not contain any debug-locations, or if the last
2357// debug-location before jumping to %bb.3 does not have line=5, then the ADD
2358// in %bb.3 must use IsStmt. In this case, all predecessors have a
2359// debug-location with line=5 as the last debug-location before jumping to
2360// %bb.3, so we do not set is_stmt for the ADD instruction - we know that
2361// whichever MBB we have arrived from, the line has not changed.
2362
2363constauto *TII = MF->getSubtarget().getInstrInfo();
2364
2365// We only need to the predecessors of MBBs that could have is_stmt set by
2366// this logic.
2367SmallDenseSet<MachineBasicBlock *, 4> PredMBBsToExamine;
2368SmallDenseMap<MachineBasicBlock *, MachineInstr *> PotentialIsStmtMBBInstrs;
2369// We use const_cast even though we won't actually modify MF, because some
2370// methods we need take a non-const MBB.
2371for (auto &MBB : *const_cast<MachineFunction *>(MF)) {
2372if (MBB.empty() ||MBB.pred_empty())
2373continue;
2374for (auto &MI :MBB) {
2375if (MI.getDebugLoc() &&MI.getDebugLoc()->getLine()) {
2376for (auto *Pred :MBB.predecessors())
2377 PredMBBsToExamine.insert(Pred);
2378 PotentialIsStmtMBBInstrs.insert({&MBB, &MI});
2379break;
2380 }
2381 }
2382 }
2383
2384// For each predecessor MBB, we examine the last line seen before each branch
2385// or logical fallthrough. We use analyzeBranch to handle cases where
2386// different branches have different outgoing lines (i.e. if there are
2387// multiple branches that each have their own source location); otherwise we
2388// just use the last line in the block.
2389for (auto *MBB : PredMBBsToExamine) {
2390auto CheckMBBEdge = [&](MachineBasicBlock *Succ,unsigned OutgoingLine) {
2391auto MBBInstrIt = PotentialIsStmtMBBInstrs.find(Succ);
2392if (MBBInstrIt == PotentialIsStmtMBBInstrs.end())
2393return;
2394MachineInstr *MI = MBBInstrIt->second;
2395if (MI->getDebugLoc()->getLine() == OutgoingLine)
2396return;
2397 PotentialIsStmtMBBInstrs.erase(MBBInstrIt);
2398 ForceIsStmtInstrs.insert(MI);
2399 };
2400// If this block is empty, we conservatively assume that its fallthrough
2401// successor needs is_stmt; we could check MBB's predecessors to see if it
2402// has a consistent entry line, but this seems unlikely to be worthwhile.
2403if (MBB->empty()) {
2404for (auto *Succ :MBB->successors())
2405 CheckMBBEdge(Succ, 0);
2406continue;
2407 }
2408// If MBB has no successors that are in the "potential" set, due to one or
2409// more of them having confirmed is_stmt, we can skip this check early.
2410if (none_of(MBB->successors(), [&](auto *SuccMBB) {
2411 return PotentialIsStmtMBBInstrs.contains(SuccMBB);
2412 }))
2413continue;
2414// If we can't determine what DLs this branch's successors use, just treat
2415// all the successors as coming from the last DebugLoc.
2416SmallVector<MachineBasicBlock *, 2> SuccessorBBs;
2417auto MIIt =MBB->rbegin();
2418 {
2419MachineBasicBlock *TBB =nullptr, *FBB =nullptr;
2420SmallVector<MachineOperand, 4>Cond;
2421bool AnalyzeFailed =TII->analyzeBranch(*MBB,TBB, FBB,Cond);
2422// For a conditional branch followed by unconditional branch where the
2423// unconditional branch has a DebugLoc, that loc is the outgoing loc to
2424// the the false destination only; otherwise, both destinations share an
2425// outgoing loc.
2426if (!AnalyzeFailed && !Cond.empty() && FBB !=nullptr &&
2427MBB->back().getDebugLoc() &&MBB->back().getDebugLoc()->getLine()) {
2428unsigned FBBLine =MBB->back().getDebugLoc()->getLine();
2429assert(MIIt->isBranch() &&"Bad result from analyzeBranch?");
2430 CheckMBBEdge(FBB, FBBLine);
2431 ++MIIt;
2432 SuccessorBBs.push_back(TBB);
2433 }else {
2434// For all other cases, all successors share the last outgoing DebugLoc.
2435 SuccessorBBs.assign(MBB->succ_begin(),MBB->succ_end());
2436 }
2437 }
2438
2439// If we don't find an outgoing loc, this block will start with a line 0.
2440// It is possible that we have a block that has no DebugLoc, but acts as a
2441// simple passthrough between two blocks that end and start with the same
2442// line, e.g.:
2443// bb.1:
2444// JMP %bb.2, debug-location !10
2445// bb.2:
2446// JMP %bb.3
2447// bb.3:
2448// $r1 = ADD $r2, $r3, debug-location !10
2449// If these blocks were merged into a single block, we would not attach
2450// is_stmt to the ADD, but with this logic that only checks the immediate
2451// predecessor, we will; we make this tradeoff because doing a full dataflow
2452// analysis would be expensive, and these situations are probably not common
2453// enough for this to be worthwhile.
2454unsigned LastLine = 0;
2455while (MIIt !=MBB->rend()) {
2456if (autoDL = MIIt->getDebugLoc();DL &&DL->getLine()) {
2457 LastLine =DL->getLine();
2458break;
2459 }
2460 ++MIIt;
2461 }
2462for (auto *Succ : SuccessorBBs)
2463 CheckMBBEdge(Succ, LastLine);
2464 }
2465}
2466
2467// Gather pre-function debug information. Assumes being called immediately
2468// after the function entry point has been emitted.
2469voidDwarfDebug::beginFunctionImpl(constMachineFunction *MF) {
2470 CurFn = MF;
2471
2472auto *SP = MF->getFunction().getSubprogram();
2473assert(LScopes.empty() || SP ==LScopes.getCurrentFunctionScope()->getScopeNode());
2474if (SP->getUnit()->getEmissionKind() ==DICompileUnit::NoDebug)
2475return;
2476
2477DwarfCompileUnit &CU = getOrCreateDwarfCompileUnit(SP->getUnit());
2478 FunctionLineTableLabel =CU.emitFuncLineTableOffsets()
2479 ?Asm->OutStreamer->emitLineTableLabel()
2480 :nullptr;
2481
2482Asm->OutStreamer->getContext().setDwarfCompileUnitID(
2483getDwarfCompileUnitIDForLineTable(CU));
2484
2485// Record beginning of function.
2486PrologEndLoc =emitInitialLocDirective(
2487 *MF,Asm->OutStreamer->getContext().getDwarfCompileUnitID());
2488
2489 findForceIsStmtInstrs(MF);
2490}
2491
2492unsigned
2493DwarfDebug::getDwarfCompileUnitIDForLineTable(constDwarfCompileUnit &CU) {
2494// Set DwarfDwarfCompileUnitID in MCContext to the Compile Unit this function
2495// belongs to so that we add to the correct per-cu line table in the
2496// non-asm case.
2497if (Asm->OutStreamer->hasRawTextSupport())
2498// Use a single line table if we are generating assembly.
2499return 0;
2500else
2501returnCU.getUniqueID();
2502}
2503
2504voidDwarfDebug::terminateLineTable(constDwarfCompileUnit *CU) {
2505constauto &CURanges =CU->getRanges();
2506auto &LineTable =Asm->OutStreamer->getContext().getMCDwarfLineTable(
2507getDwarfCompileUnitIDForLineTable(*CU));
2508// Add the last range label for the given CU.
2509 LineTable.getMCLineSections().addEndEntry(
2510const_cast<MCSymbol *>(CURanges.back().End));
2511}
2512
2513voidDwarfDebug::skippedNonDebugFunction() {
2514// If we don't have a subprogram for this function then there will be a hole
2515// in the range information. Keep note of this by setting the previously used
2516// section to nullptr.
2517// Terminate the pending line table.
2518if (PrevCU)
2519terminateLineTable(PrevCU);
2520 PrevCU =nullptr;
2521 CurFn =nullptr;
2522}
2523
2524// Gather and emit post-function debug information.
2525voidDwarfDebug::endFunctionImpl(constMachineFunction *MF) {
2526constDISubprogram *SP = MF->getFunction().getSubprogram();
2527
2528assert(CurFn == MF &&
2529"endFunction should be called with the same function as beginFunction");
2530
2531// Set DwarfDwarfCompileUnitID in MCContext to default value.
2532Asm->OutStreamer->getContext().setDwarfCompileUnitID(0);
2533
2534LexicalScope *FnScope =LScopes.getCurrentFunctionScope();
2535assert(!FnScope || SP == FnScope->getScopeNode());
2536DwarfCompileUnit &TheCU = getOrCreateDwarfCompileUnit(SP->getUnit());
2537if (TheCU.getCUNode()->isDebugDirectivesOnly()) {
2538PrevLabel =nullptr;
2539 CurFn =nullptr;
2540return;
2541 }
2542
2543DenseSet<InlinedEntity> Processed;
2544 collectEntityInfo(TheCU, SP, Processed);
2545
2546// Add the range of this function to the list of ranges for the CU.
2547// With basic block sections, add ranges for all basic block sections.
2548for (constauto &R :Asm->MBBSectionRanges)
2549 TheCU.addRange({R.second.BeginLabel, R.second.EndLabel});
2550
2551// Under -gmlt, skip building the subprogram if there are no inlined
2552// subroutines inside it. But with -fdebug-info-for-profiling, the subprogram
2553// is still needed as we need its source location.
2554if (!TheCU.getCUNode()->getDebugInfoForProfiling() &&
2555 TheCU.getCUNode()->getEmissionKind() ==DICompileUnit::LineTablesOnly &&
2556LScopes.getAbstractScopesList().empty() && !IsDarwin) {
2557for (constauto &R :Asm->MBBSectionRanges)
2558addArangeLabel(SymbolCU(&TheCU, R.second.BeginLabel));
2559
2560assert(InfoHolder.getScopeVariables().empty());
2561PrevLabel =nullptr;
2562 CurFn =nullptr;
2563return;
2564 }
2565
2566#ifndef NDEBUG
2567size_t NumAbstractSubprograms =LScopes.getAbstractScopesList().size();
2568#endif
2569for (LexicalScope *AScope :LScopes.getAbstractScopesList()) {
2570constauto *SP = cast<DISubprogram>(AScope->getScopeNode());
2571for (constDINode *DN : SP->getRetainedNodes()) {
2572constauto *LS =getRetainedNodeScope(DN);
2573// Ensure LexicalScope is created for the scope of this node.
2574auto *LexS =LScopes.getOrCreateAbstractScope(LS);
2575assert(LexS &&"Expected the LexicalScope to be created.");
2576if (isa<DILocalVariable>(DN) || isa<DILabel>(DN)) {
2577// Collect info for variables/labels that were optimized out.
2578if (!Processed.insert(InlinedEntity(DN,nullptr)).second ||
2579 TheCU.getExistingAbstractEntity(DN))
2580continue;
2581 TheCU.createAbstractEntity(DN, LexS);
2582 }else {
2583// Remember the node if this is a local declarations.
2584 LocalDeclsPerLS[LS].insert(DN);
2585 }
2586assert(
2587LScopes.getAbstractScopesList().size() == NumAbstractSubprograms &&
2588"getOrCreateAbstractScope() inserted an abstract subprogram scope");
2589 }
2590 constructAbstractSubprogramScopeDIE(TheCU, AScope);
2591 }
2592
2593 ProcessedSPNodes.insert(SP);
2594DIE &ScopeDIE =
2595 TheCU.constructSubprogramScopeDIE(SP, FnScope, FunctionLineTableLabel);
2596if (auto *SkelCU = TheCU.getSkeleton())
2597if (!LScopes.getAbstractScopesList().empty() &&
2598 TheCU.getCUNode()->getSplitDebugInlining())
2599 SkelCU->constructSubprogramScopeDIE(SP, FnScope, FunctionLineTableLabel);
2600
2601 FunctionLineTableLabel =nullptr;
2602
2603// Construct call site entries.
2604 constructCallSiteEntryDIEs(*SP, TheCU, ScopeDIE, *MF);
2605
2606// Clear debug info
2607// Ownership of DbgVariables is a bit subtle - ScopeVariables owns all the
2608// DbgVariables except those that are also in AbstractVariables (since they
2609// can be used cross-function)
2610 InfoHolder.getScopeVariables().clear();
2611 InfoHolder.getScopeLabels().clear();
2612 LocalDeclsPerLS.clear();
2613PrevLabel =nullptr;
2614 CurFn =nullptr;
2615}
2616
2617// Register a source line with debug info. Returns the unique label that was
2618// emitted and which provides correspondence to the source line list.
2619void DwarfDebug::recordSourceLine(unsigned Line,unsigned Col,constMDNode *S,
2620unsigned Flags) {
2621 ::recordSourceLine(*Asm, Line, Col, S, Flags,
2622Asm->OutStreamer->getContext().getDwarfCompileUnitID(),
2623getDwarfVersion(), getUnits());
2624}
2625
2626//===----------------------------------------------------------------------===//
2627// Emit Methods
2628//===----------------------------------------------------------------------===//
2629
2630// Emit the debug info section.
2631void DwarfDebug::emitDebugInfo() {
2632DwarfFile &Holder =useSplitDwarf() ? SkeletonHolder : InfoHolder;
2633 Holder.emitUnits(/* UseOffsets */false);
2634}
2635
2636// Emit the abbreviation section.
2637void DwarfDebug::emitAbbreviations() {
2638DwarfFile &Holder =useSplitDwarf() ? SkeletonHolder : InfoHolder;
2639
2640 Holder.emitAbbrevs(Asm->getObjFileLowering().getDwarfAbbrevSection());
2641}
2642
2643void DwarfDebug::emitStringOffsetsTableHeader() {
2644DwarfFile &Holder =useSplitDwarf() ? SkeletonHolder : InfoHolder;
2645 Holder.getStringPool().emitStringOffsetsTableHeader(
2646 *Asm,Asm->getObjFileLowering().getDwarfStrOffSection(),
2647 Holder.getStringOffsetsStartSym());
2648}
2649
2650template <typename AccelTableT>
2651void DwarfDebug::emitAccel(AccelTableT &Accel,MCSection *Section,
2652StringRef TableName) {
2653Asm->OutStreamer->switchSection(Section);
2654
2655// Emit the full data.
2656emitAppleAccelTable(Asm, Accel, TableName,Section->getBeginSymbol());
2657}
2658
2659void DwarfDebug::emitAccelDebugNames() {
2660// Don't emit anything if we have no compilation units to index.
2661if (getUnits().empty())
2662return;
2663
2664emitDWARF5AccelTable(Asm, AccelDebugNames, *this, getUnits());
2665}
2666
2667// Emit visible names into a hashed accelerator table section.
2668void DwarfDebug::emitAccelNames() {
2669 emitAccel(AccelNames,Asm->getObjFileLowering().getDwarfAccelNamesSection(),
2670"Names");
2671}
2672
2673// Emit objective C classes and categories into a hashed accelerator table
2674// section.
2675void DwarfDebug::emitAccelObjC() {
2676 emitAccel(AccelObjC,Asm->getObjFileLowering().getDwarfAccelObjCSection(),
2677"ObjC");
2678}
2679
2680// Emit namespace dies into a hashed accelerator table.
2681void DwarfDebug::emitAccelNamespaces() {
2682 emitAccel(AccelNamespace,
2683Asm->getObjFileLowering().getDwarfAccelNamespaceSection(),
2684"namespac");
2685}
2686
2687// Emit type dies into a hashed accelerator table.
2688void DwarfDebug::emitAccelTypes() {
2689 emitAccel(AccelTypes,Asm->getObjFileLowering().getDwarfAccelTypesSection(),
2690"types");
2691}
2692
2693// Public name handling.
2694// The format for the various pubnames:
2695//
2696// dwarf pubnames - offset/name pairs where the offset is the offset into the CU
2697// for the DIE that is named.
2698//
2699// gnu pubnames - offset/index value/name tuples where the offset is the offset
2700// into the CU and the index value is computed according to the type of value
2701// for the DIE that is named.
2702//
2703// For type units the offset is the offset of the skeleton DIE. For split dwarf
2704// it's the offset within the debug_info/debug_types dwo section, however, the
2705// reference in the pubname header doesn't change.
2706
2707/// computeIndexValue - Compute the gdb index value for the DIE and CU.
2708staticdwarf::PubIndexEntryDescriptorcomputeIndexValue(DwarfUnit *CU,
2709constDIE *Die) {
2710// Entities that ended up only in a Type Unit reference the CU instead (since
2711// the pub entry has offsets within the CU there's no real offset that can be
2712// provided anyway). As it happens all such entities (namespaces and types,
2713// types only in C++ at that) are rendered as TYPE+EXTERNAL. If this turns out
2714// not to be true it would be necessary to persist this information from the
2715// point at which the entry is added to the index data structure - since by
2716// the time the index is built from that, the original type/namespace DIE in a
2717// type unit has already been destroyed so it can't be queried for properties
2718// like tag, etc.
2719if (Die->getTag() == dwarf::DW_TAG_compile_unit)
2720returndwarf::PubIndexEntryDescriptor(dwarf::GIEK_TYPE,
2721dwarf::GIEL_EXTERNAL);
2722dwarf::GDBIndexEntryLinkage Linkage =dwarf::GIEL_STATIC;
2723
2724// We could have a specification DIE that has our most of our knowledge,
2725// look for that now.
2726if (DIEValue SpecVal = Die->findAttribute(dwarf::DW_AT_specification)) {
2727DIE &SpecDIE = SpecVal.getDIEEntry().getEntry();
2728if (SpecDIE.findAttribute(dwarf::DW_AT_external))
2729 Linkage =dwarf::GIEL_EXTERNAL;
2730 }elseif (Die->findAttribute(dwarf::DW_AT_external))
2731 Linkage =dwarf::GIEL_EXTERNAL;
2732
2733switch (Die->getTag()) {
2734case dwarf::DW_TAG_class_type:
2735case dwarf::DW_TAG_structure_type:
2736case dwarf::DW_TAG_union_type:
2737case dwarf::DW_TAG_enumeration_type:
2738returndwarf::PubIndexEntryDescriptor(
2739dwarf::GIEK_TYPE,
2740dwarf::isCPlusPlus((dwarf::SourceLanguage)CU->getLanguage())
2741 ?dwarf::GIEL_EXTERNAL
2742 :dwarf::GIEL_STATIC);
2743case dwarf::DW_TAG_typedef:
2744case dwarf::DW_TAG_base_type:
2745case dwarf::DW_TAG_subrange_type:
2746case dwarf::DW_TAG_template_alias:
2747returndwarf::PubIndexEntryDescriptor(dwarf::GIEK_TYPE,dwarf::GIEL_STATIC);
2748case dwarf::DW_TAG_namespace:
2749returndwarf::GIEK_TYPE;
2750case dwarf::DW_TAG_subprogram:
2751returndwarf::PubIndexEntryDescriptor(dwarf::GIEK_FUNCTION, Linkage);
2752case dwarf::DW_TAG_variable:
2753returndwarf::PubIndexEntryDescriptor(dwarf::GIEK_VARIABLE, Linkage);
2754case dwarf::DW_TAG_enumerator:
2755returndwarf::PubIndexEntryDescriptor(dwarf::GIEK_VARIABLE,
2756dwarf::GIEL_STATIC);
2757default:
2758returndwarf::GIEK_NONE;
2759 }
2760}
2761
2762/// emitDebugPubSections - Emit visible names and types into debug pubnames and
2763/// pubtypes sections.
2764void DwarfDebug::emitDebugPubSections() {
2765for (constauto &NU : CUMap) {
2766DwarfCompileUnit *TheU = NU.second;
2767if (!TheU->hasDwarfPubSections())
2768continue;
2769
2770bool GnuStyle = TheU->getCUNode()->getNameTableKind() ==
2771DICompileUnit::DebugNameTableKind::GNU;
2772
2773Asm->OutStreamer->switchSection(
2774 GnuStyle ?Asm->getObjFileLowering().getDwarfGnuPubNamesSection()
2775 :Asm->getObjFileLowering().getDwarfPubNamesSection());
2776 emitDebugPubSection(GnuStyle,"Names", TheU, TheU->getGlobalNames());
2777
2778Asm->OutStreamer->switchSection(
2779 GnuStyle ?Asm->getObjFileLowering().getDwarfGnuPubTypesSection()
2780 :Asm->getObjFileLowering().getDwarfPubTypesSection());
2781 emitDebugPubSection(GnuStyle,"Types", TheU, TheU->getGlobalTypes());
2782 }
2783}
2784
2785void DwarfDebug::emitSectionReference(constDwarfCompileUnit &CU) {
2786if (useSectionsAsReferences())
2787Asm->emitDwarfOffset(CU.getSection()->getBeginSymbol(),
2788CU.getDebugSectionOffset());
2789else
2790Asm->emitDwarfSymbolReference(CU.getLabelBegin());
2791}
2792
2793void DwarfDebug::emitDebugPubSection(bool GnuStyle,StringRefName,
2794DwarfCompileUnit *TheU,
2795constStringMap<const DIE *> &Globals) {
2796if (auto *Skeleton = TheU->getSkeleton())
2797 TheU =Skeleton;
2798
2799// Emit the header.
2800MCSymbol *EndLabel =Asm->emitDwarfUnitLength(
2801"pub" +Name,"Length of Public " +Name +" Info");
2802
2803Asm->OutStreamer->AddComment("DWARF Version");
2804Asm->emitInt16(dwarf::DW_PUBNAMES_VERSION);
2805
2806Asm->OutStreamer->AddComment("Offset of Compilation Unit Info");
2807 emitSectionReference(*TheU);
2808
2809Asm->OutStreamer->AddComment("Compilation Unit Length");
2810Asm->emitDwarfLengthOrOffset(TheU->getLength());
2811
2812// Emit the pubnames for this compilation unit.
2813SmallVector<std::pair<StringRef, const DIE *>, 0> Vec;
2814for (constauto &GI : Globals)
2815 Vec.emplace_back(GI.first(), GI.second);
2816llvm::sort(Vec, [](auto &A,auto &B) {
2817returnA.second->getOffset() <B.second->getOffset();
2818 });
2819for (constauto &[Name, Entity] : Vec) {
2820Asm->OutStreamer->AddComment("DIE offset");
2821Asm->emitDwarfLengthOrOffset(Entity->getOffset());
2822
2823if (GnuStyle) {
2824dwarf::PubIndexEntryDescriptorDesc =computeIndexValue(TheU, Entity);
2825Asm->OutStreamer->AddComment(
2826Twine("Attributes: ") +dwarf::GDBIndexEntryKindString(Desc.Kind) +
2827", " +dwarf::GDBIndexEntryLinkageString(Desc.Linkage));
2828Asm->emitInt8(Desc.toBits());
2829 }
2830
2831Asm->OutStreamer->AddComment("External Name");
2832Asm->OutStreamer->emitBytes(StringRef(Name.data(),Name.size() + 1));
2833 }
2834
2835Asm->OutStreamer->AddComment("End Mark");
2836Asm->emitDwarfLengthOrOffset(0);
2837Asm->OutStreamer->emitLabel(EndLabel);
2838}
2839
2840/// Emit null-terminated strings into a debug str section.
2841void DwarfDebug::emitDebugStr() {
2842MCSection *StringOffsetsSection =nullptr;
2843if (useSegmentedStringOffsetsTable()) {
2844 emitStringOffsetsTableHeader();
2845 StringOffsetsSection =Asm->getObjFileLowering().getDwarfStrOffSection();
2846 }
2847DwarfFile &Holder =useSplitDwarf() ? SkeletonHolder : InfoHolder;
2848 Holder.emitStrings(Asm->getObjFileLowering().getDwarfStrSection(),
2849 StringOffsetsSection,/* UseRelativeOffsets = */true);
2850}
2851
2852voidDwarfDebug::emitDebugLocEntry(ByteStreamer &Streamer,
2853constDebugLocStream::Entry &Entry,
2854constDwarfCompileUnit *CU) {
2855auto &&Comments = DebugLocs.getComments(Entry);
2856auto Comment = Comments.begin();
2857autoEnd = Comments.end();
2858
2859// The expressions are inserted into a byte stream rather early (see
2860// DwarfExpression::addExpression) so for those ops (e.g. DW_OP_convert) that
2861// need to reference a base_type DIE the offset of that DIE is not yet known.
2862// To deal with this we instead insert a placeholder early and then extract
2863// it here and replace it with the real reference.
2864unsigned PtrSize =Asm->MAI->getCodePointerSize();
2865DWARFDataExtractorData(StringRef(DebugLocs.getBytes(Entry).data(),
2866 DebugLocs.getBytes(Entry).size()),
2867Asm->getDataLayout().isLittleEndian(), PtrSize);
2868DWARFExpression Expr(Data, PtrSize,Asm->OutContext.getDwarfFormat());
2869
2870usingEncoding =DWARFExpression::Operation::Encoding;
2871uint64_tOffset = 0;
2872for (constauto &Op : Expr) {
2873assert(Op.getCode() != dwarf::DW_OP_const_type &&
2874"3 operand ops not yet supported");
2875assert(!Op.getSubCode() &&"SubOps not yet supported");
2876 Streamer.emitInt8(Op.getCode(), Comment !=End ? *(Comment++) :"");
2877Offset++;
2878for (unsignedI = 0;I <Op.getDescription().Op.size(); ++I) {
2879if (Op.getDescription().Op[I] == Encoding::BaseTypeRef) {
2880unsignedLength =
2881 Streamer.emitDIERef(*CU->ExprRefedBaseTypes[Op.getRawOperand(I)].Die);
2882// Make sure comments stay aligned.
2883for (unsigned J = 0; J <Length; ++J)
2884if (Comment !=End)
2885 Comment++;
2886 }else {
2887for (uint64_t J =Offset; J <Op.getOperandEndOffset(I); ++J)
2888 Streamer.emitInt8(Data.getData()[J], Comment !=End ? *(Comment++) :"");
2889 }
2890Offset =Op.getOperandEndOffset(I);
2891 }
2892assert(Offset ==Op.getEndOffset());
2893 }
2894}
2895
2896voidDwarfDebug::emitDebugLocValue(constAsmPrinter &AP,constDIBasicType *BT,
2897constDbgValueLoc &Value,
2898DwarfExpression &DwarfExpr) {
2899auto *DIExpr =Value.getExpression();
2900DIExpressionCursor ExprCursor(DIExpr);
2901 DwarfExpr.addFragmentOffset(DIExpr);
2902
2903// If the DIExpr is an Entry Value, we want to follow the same code path
2904// regardless of whether the DBG_VALUE is variadic or not.
2905if (DIExpr && DIExpr->isEntryValue()) {
2906// Entry values can only be a single register with no additional DIExpr,
2907// so just add it directly.
2908assert(Value.getLocEntries().size() == 1);
2909assert(Value.getLocEntries()[0].isLocation());
2910MachineLocation Location =Value.getLocEntries()[0].getLoc();
2911 DwarfExpr.setLocation(Location, DIExpr);
2912
2913 DwarfExpr.beginEntryValueExpression(ExprCursor);
2914
2915constTargetRegisterInfo &TRI = *AP.MF->getSubtarget().getRegisterInfo();
2916if (!DwarfExpr.addMachineRegExpression(TRI, ExprCursor, Location.getReg()))
2917return;
2918return DwarfExpr.addExpression(std::move(ExprCursor));
2919 }
2920
2921// Regular entry.
2922auto EmitValueLocEntry = [&DwarfExpr, &BT,
2923 &AP](constDbgValueLocEntry &Entry,
2924DIExpressionCursor &Cursor) ->bool {
2925if (Entry.isInt()) {
2926if (BT && (BT->getEncoding() == dwarf::DW_ATE_signed ||
2927BT->getEncoding() == dwarf::DW_ATE_signed_char))
2928 DwarfExpr.addSignedConstant(Entry.getInt());
2929else
2930 DwarfExpr.addUnsignedConstant(Entry.getInt());
2931 }elseif (Entry.isLocation()) {
2932MachineLocation Location = Entry.getLoc();
2933if (Location.isIndirect())
2934 DwarfExpr.setMemoryLocationKind();
2935
2936constTargetRegisterInfo &TRI = *AP.MF->getSubtarget().getRegisterInfo();
2937if (!DwarfExpr.addMachineRegExpression(TRI, Cursor, Location.getReg()))
2938returnfalse;
2939 }elseif (Entry.isTargetIndexLocation()) {
2940TargetIndexLocation Loc = Entry.getTargetIndexLocation();
2941// TODO TargetIndexLocation is a target-independent. Currently only the
2942// WebAssembly-specific encoding is supported.
2943assert(AP.TM.getTargetTriple().isWasm());
2944 DwarfExpr.addWasmLocation(Loc.Index,static_cast<uint64_t>(Loc.Offset));
2945 }elseif (Entry.isConstantFP()) {
2946if (AP.getDwarfVersion() >= 4 && !AP.getDwarfDebug()->tuneForSCE() &&
2947 !Cursor) {
2948 DwarfExpr.addConstantFP(Entry.getConstantFP()->getValueAPF(), AP);
2949 }elseif (Entry.getConstantFP()
2950 ->getValueAPF()
2951 .bitcastToAPInt()
2952 .getBitWidth() <= 64/*bits*/) {
2953 DwarfExpr.addUnsignedConstant(
2954 Entry.getConstantFP()->getValueAPF().bitcastToAPInt());
2955 }else {
2956LLVM_DEBUG(
2957dbgs() <<"Skipped DwarfExpression creation for ConstantFP of size"
2958 << Entry.getConstantFP()
2959 ->getValueAPF()
2960 .bitcastToAPInt()
2961 .getBitWidth()
2962 <<" bits\n");
2963returnfalse;
2964 }
2965 }
2966returntrue;
2967 };
2968
2969if (!Value.isVariadic()) {
2970if (!EmitValueLocEntry(Value.getLocEntries()[0], ExprCursor))
2971return;
2972 DwarfExpr.addExpression(std::move(ExprCursor));
2973return;
2974 }
2975
2976// If any of the location entries are registers with the value 0, then the
2977// location is undefined.
2978if (any_of(Value.getLocEntries(), [](constDbgValueLocEntry &Entry) {
2979 return Entry.isLocation() && !Entry.getLoc().getReg();
2980 }))
2981return;
2982
2983 DwarfExpr.addExpression(
2984 std::move(ExprCursor),
2985 [EmitValueLocEntry, &Value](unsignedIdx,
2986DIExpressionCursor &Cursor) ->bool {
2987return EmitValueLocEntry(Value.getLocEntries()[Idx], Cursor);
2988 });
2989}
2990
2991voidDebugLocEntry::finalize(constAsmPrinter &AP,
2992DebugLocStream::ListBuilder &List,
2993constDIBasicType *BT,
2994DwarfCompileUnit &TheCU) {
2995assert(!Values.empty() &&
2996"location list entries without values are redundant");
2997assert(Begin != End &&"unexpected location list entry with empty range");
2998DebugLocStream::EntryBuilder Entry(List, Begin, End);
2999BufferByteStreamer Streamer = Entry.getStreamer();
3000DebugLocDwarfExpression DwarfExpr(AP.getDwarfVersion(), Streamer, TheCU);
3001constDbgValueLoc &Value = Values[0];
3002if (Value.isFragment()) {
3003// Emit all fragments that belong to the same variable and range.
3004assert(llvm::all_of(Values, [](DbgValueLocP) {
3005returnP.isFragment();
3006 }) &&"all values are expected to be fragments");
3007assert(llvm::is_sorted(Values) &&"fragments are expected to be sorted");
3008
3009for (constauto &Fragment : Values)
3010DwarfDebug::emitDebugLocValue(AP,BT, Fragment, DwarfExpr);
3011
3012 }else {
3013assert(Values.size() == 1 &&"only fragments may have >1 value");
3014DwarfDebug::emitDebugLocValue(AP,BT,Value, DwarfExpr);
3015 }
3016 DwarfExpr.finalize();
3017if (DwarfExpr.TagOffset)
3018List.setTagOffset(*DwarfExpr.TagOffset);
3019}
3020
3021voidDwarfDebug::emitDebugLocEntryLocation(constDebugLocStream::Entry &Entry,
3022constDwarfCompileUnit *CU) {
3023// Emit the size.
3024Asm->OutStreamer->AddComment("Loc expr size");
3025if (getDwarfVersion() >= 5)
3026Asm->emitULEB128(DebugLocs.getBytes(Entry).size());
3027elseif (DebugLocs.getBytes(Entry).size() <= std::numeric_limits<uint16_t>::max())
3028Asm->emitInt16(DebugLocs.getBytes(Entry).size());
3029else {
3030// The entry is too big to fit into 16 bit, drop it as there is nothing we
3031// can do.
3032Asm->emitInt16(0);
3033return;
3034 }
3035// Emit the entry.
3036APByteStreamer Streamer(*Asm);
3037emitDebugLocEntry(Streamer, Entry,CU);
3038}
3039
3040// Emit the header of a DWARF 5 range list table list table. Returns the symbol
3041// that designates the end of the table for the caller to emit when the table is
3042// complete.
3043staticMCSymbol *emitRnglistsTableHeader(AsmPrinter *Asm,
3044constDwarfFile &Holder) {
3045MCSymbol *TableEnd =mcdwarf::emitListsTableHeaderStart(*Asm->OutStreamer);
3046
3047 Asm->OutStreamer->AddComment("Offset entry count");
3048 Asm->emitInt32(Holder.getRangeLists().size());
3049 Asm->OutStreamer->emitLabel(Holder.getRnglistsTableBaseSym());
3050
3051for (constRangeSpanList &List : Holder.getRangeLists())
3052 Asm->emitLabelDifference(List.Label, Holder.getRnglistsTableBaseSym(),
3053 Asm->getDwarfOffsetByteSize());
3054
3055return TableEnd;
3056}
3057
3058// Emit the header of a DWARF 5 locations list table. Returns the symbol that
3059// designates the end of the table for the caller to emit when the table is
3060// complete.
3061staticMCSymbol *emitLoclistsTableHeader(AsmPrinter *Asm,
3062constDwarfDebug &DD) {
3063MCSymbol *TableEnd =mcdwarf::emitListsTableHeaderStart(*Asm->OutStreamer);
3064
3065constauto &DebugLocs = DD.getDebugLocs();
3066
3067 Asm->OutStreamer->AddComment("Offset entry count");
3068 Asm->emitInt32(DebugLocs.getLists().size());
3069 Asm->OutStreamer->emitLabel(DebugLocs.getSym());
3070
3071for (constauto &List : DebugLocs.getLists())
3072 Asm->emitLabelDifference(List.Label, DebugLocs.getSym(),
3073 Asm->getDwarfOffsetByteSize());
3074
3075return TableEnd;
3076}
3077
3078template <typename Ranges,typename PayloadEmitter>
3079staticvoidemitRangeList(
3080DwarfDebug &DD,AsmPrinter *Asm,MCSymbol *Sym,const Ranges &R,
3081constDwarfCompileUnit &CU,unsigned BaseAddressx,unsigned OffsetPair,
3082unsigned StartxLength,unsignedEndOfList,
3083StringRef (*StringifyEnum)(unsigned),
3084bool ShouldUseBaseAddress,
3085 PayloadEmitter EmitPayload) {
3086
3087autoSize = Asm->MAI->getCodePointerSize();
3088bool UseDwarf5 = DD.getDwarfVersion() >= 5;
3089
3090// Emit our symbol so we can find the beginning of the range.
3091 Asm->OutStreamer->emitLabel(Sym);
3092
3093// Gather all the ranges that apply to the same section so they can share
3094// a base address entry.
3095SmallMapVector<constMCSection *, std::vector<decltype(&*R.begin())>, 16>
3096 SectionRanges;
3097
3098for (constauto &Range : R)
3099 SectionRanges[&Range.Begin->getSection()].push_back(&Range);
3100
3101constMCSymbol *CUBase =CU.getBaseAddress();
3102bool BaseIsSet =false;
3103for (constauto &P : SectionRanges) {
3104auto *Base = CUBase;
3105if ((Asm->TM.getTargetTriple().isNVPTX() && DD.tuneForGDB())) {
3106// PTX does not support subtracting labels from the code section in the
3107// debug_loc section. To work around this, the NVPTX backend needs the
3108// compile unit to have no low_pc in order to have a zero base_address
3109// when handling debug_loc in cuda-gdb. Additionally, cuda-gdb doesn't
3110// seem to handle setting a per-variable base to zero. To make cuda-gdb
3111// happy, just emit labels with no base while having no compile unit
3112// low_pc.
3113 BaseIsSet =false;
3114Base =nullptr;
3115 }elseif (!Base && ShouldUseBaseAddress) {
3116constMCSymbol *Begin =P.second.front()->Begin;
3117constMCSymbol *NewBase = DD.getSectionLabel(&Begin->getSection());
3118if (!UseDwarf5) {
3119Base = NewBase;
3120 BaseIsSet =true;
3121 Asm->OutStreamer->emitIntValue(-1,Size);
3122 Asm->OutStreamer->AddComment(" base address");
3123 Asm->OutStreamer->emitSymbolValue(Base,Size);
3124 }elseif (NewBase != Begin ||P.second.size() > 1) {
3125// Only use a base address if
3126// * the existing pool address doesn't match (NewBase != Begin)
3127// * or, there's more than one entry to share the base address
3128Base = NewBase;
3129 BaseIsSet =true;
3130 Asm->OutStreamer->AddComment(StringifyEnum(BaseAddressx));
3131 Asm->emitInt8(BaseAddressx);
3132 Asm->OutStreamer->AddComment(" base address index");
3133 Asm->emitULEB128(DD.getAddressPool().getIndex(Base));
3134 }
3135 }elseif (BaseIsSet && !UseDwarf5) {
3136 BaseIsSet =false;
3137assert(!Base);
3138 Asm->OutStreamer->emitIntValue(-1,Size);
3139 Asm->OutStreamer->emitIntValue(0,Size);
3140 }
3141
3142for (constauto *RS :P.second) {
3143constMCSymbol *Begin = RS->Begin;
3144constMCSymbol *End = RS->End;
3145assert(Begin &&"Range without a begin symbol?");
3146assert(End &&"Range without an end symbol?");
3147if (Base) {
3148if (UseDwarf5) {
3149// Emit offset_pair when we have a base.
3150 Asm->OutStreamer->AddComment(StringifyEnum(OffsetPair));
3151 Asm->emitInt8(OffsetPair);
3152 Asm->OutStreamer->AddComment(" starting offset");
3153 Asm->emitLabelDifferenceAsULEB128(Begin,Base);
3154 Asm->OutStreamer->AddComment(" ending offset");
3155 Asm->emitLabelDifferenceAsULEB128(End,Base);
3156 }else {
3157 Asm->emitLabelDifference(Begin,Base,Size);
3158 Asm->emitLabelDifference(End,Base,Size);
3159 }
3160 }elseif (UseDwarf5) {
3161 Asm->OutStreamer->AddComment(StringifyEnum(StartxLength));
3162 Asm->emitInt8(StartxLength);
3163 Asm->OutStreamer->AddComment(" start index");
3164 Asm->emitULEB128(DD.getAddressPool().getIndex(Begin));
3165 Asm->OutStreamer->AddComment(" length");
3166 Asm->emitLabelDifferenceAsULEB128(End, Begin);
3167 }else {
3168 Asm->OutStreamer->emitSymbolValue(Begin,Size);
3169 Asm->OutStreamer->emitSymbolValue(End,Size);
3170 }
3171 EmitPayload(*RS);
3172 }
3173 }
3174
3175if (UseDwarf5) {
3176 Asm->OutStreamer->AddComment(StringifyEnum(EndOfList));
3177 Asm->emitInt8(EndOfList);
3178 }else {
3179// Terminate the list with two 0 values.
3180 Asm->OutStreamer->emitIntValue(0,Size);
3181 Asm->OutStreamer->emitIntValue(0,Size);
3182 }
3183}
3184
3185// Handles emission of both debug_loclist / debug_loclist.dwo
3186staticvoidemitLocList(DwarfDebug &DD,AsmPrinter *Asm,constDebugLocStream::List &List) {
3187emitRangeList(DD, Asm,List.Label, DD.getDebugLocs().getEntries(List),
3188 *List.CU, dwarf::DW_LLE_base_addressx,
3189 dwarf::DW_LLE_offset_pair, dwarf::DW_LLE_startx_length,
3190 dwarf::DW_LLE_end_of_list,llvm::dwarf::LocListEncodingString,
3191/* ShouldUseBaseAddress */true,
3192 [&](constDebugLocStream::Entry &E) {
3193 DD.emitDebugLocEntryLocation(E, List.CU);
3194 });
3195}
3196
3197void DwarfDebug::emitDebugLocImpl(MCSection *Sec) {
3198if (DebugLocs.getLists().empty())
3199return;
3200
3201Asm->OutStreamer->switchSection(Sec);
3202
3203MCSymbol *TableEnd =nullptr;
3204if (getDwarfVersion() >= 5)
3205 TableEnd =emitLoclistsTableHeader(Asm, *this);
3206
3207for (constauto &List : DebugLocs.getLists())
3208emitLocList(*this,Asm,List);
3209
3210if (TableEnd)
3211Asm->OutStreamer->emitLabel(TableEnd);
3212}
3213
3214// Emit locations into the .debug_loc/.debug_loclists section.
3215void DwarfDebug::emitDebugLoc() {
3216 emitDebugLocImpl(
3217getDwarfVersion() >= 5
3218 ?Asm->getObjFileLowering().getDwarfLoclistsSection()
3219 :Asm->getObjFileLowering().getDwarfLocSection());
3220}
3221
3222// Emit locations into the .debug_loc.dwo/.debug_loclists.dwo section.
3223void DwarfDebug::emitDebugLocDWO() {
3224if (getDwarfVersion() >= 5) {
3225 emitDebugLocImpl(
3226Asm->getObjFileLowering().getDwarfLoclistsDWOSection());
3227
3228return;
3229 }
3230
3231for (constauto &List : DebugLocs.getLists()) {
3232Asm->OutStreamer->switchSection(
3233Asm->getObjFileLowering().getDwarfLocDWOSection());
3234Asm->OutStreamer->emitLabel(List.Label);
3235
3236for (constauto &Entry : DebugLocs.getEntries(List)) {
3237// GDB only supports startx_length in pre-standard split-DWARF.
3238// (in v5 standard loclists, it currently* /only/ supports base_address +
3239// offset_pair, so the implementations can't really share much since they
3240// need to use different representations)
3241// * as of October 2018, at least
3242//
3243// In v5 (see emitLocList), this uses SectionLabels to reuse existing
3244// addresses in the address pool to minimize object size/relocations.
3245Asm->emitInt8(dwarf::DW_LLE_startx_length);
3246unsigned idx = AddrPool.getIndex(Entry.Begin);
3247Asm->emitULEB128(idx);
3248// Also the pre-standard encoding is slightly different, emitting this as
3249// an address-length entry here, but its a ULEB128 in DWARFv5 loclists.
3250Asm->emitLabelDifference(Entry.End,Entry.Begin, 4);
3251emitDebugLocEntryLocation(Entry,List.CU);
3252 }
3253Asm->emitInt8(dwarf::DW_LLE_end_of_list);
3254 }
3255}
3256
3257structArangeSpan {
3258constMCSymbol *Start, *End;
3259};
3260
3261// Emit a debug aranges section, containing a CU lookup for any
3262// address we can tie back to a CU.
3263void DwarfDebug::emitDebugARanges() {
3264if (ArangeLabels.empty())
3265return;
3266
3267// Provides a unique id per text section.
3268MapVector<MCSection *, SmallVector<SymbolCU, 8>> SectionMap;
3269
3270// Filter labels by section.
3271for (constSymbolCU &SCU : ArangeLabels) {
3272if (SCU.Sym->isInSection()) {
3273// Make a note of this symbol and it's section.
3274MCSection *Section = &SCU.Sym->getSection();
3275 SectionMap[Section].push_back(SCU);
3276 }else {
3277// Some symbols (e.g. common/bss on mach-o) can have no section but still
3278// appear in the output. This sucks as we rely on sections to build
3279// arange spans. We can do it without, but it's icky.
3280 SectionMap[nullptr].push_back(SCU);
3281 }
3282 }
3283
3284DenseMap<DwarfCompileUnit *, std::vector<ArangeSpan>> Spans;
3285
3286for (auto &I : SectionMap) {
3287MCSection *Section =I.first;
3288SmallVector<SymbolCU, 8> &List =I.second;
3289assert(!List.empty());
3290
3291// If we have no section (e.g. common), just write out
3292// individual spans for each symbol.
3293if (!Section) {
3294for (constSymbolCU &Cur :List) {
3295ArangeSpan Span;
3296 Span.Start = Cur.Sym;
3297 Span.End =nullptr;
3298assert(Cur.CU);
3299 Spans[Cur.CU].push_back(Span);
3300 }
3301continue;
3302 }
3303
3304// Insert a final terminator.
3305List.push_back(SymbolCU(nullptr,Asm->OutStreamer->endSection(Section)));
3306
3307// Build spans between each label.
3308constMCSymbol *StartSym =List[0].Sym;
3309for (size_t n = 1, e =List.size(); n < e; n++) {
3310constSymbolCU &Prev =List[n - 1];
3311constSymbolCU &Cur =List[n];
3312
3313// Try and build the longest span we can within the same CU.
3314if (Cur.CU != Prev.CU) {
3315ArangeSpan Span;
3316 Span.Start = StartSym;
3317 Span.End = Cur.Sym;
3318assert(Prev.CU);
3319 Spans[Prev.CU].push_back(Span);
3320 StartSym = Cur.Sym;
3321 }
3322 }
3323 }
3324
3325// Start the dwarf aranges section.
3326Asm->OutStreamer->switchSection(
3327Asm->getObjFileLowering().getDwarfARangesSection());
3328
3329unsigned PtrSize =Asm->MAI->getCodePointerSize();
3330
3331// Build a list of CUs used.
3332 std::vector<DwarfCompileUnit *> CUs;
3333for (constauto &it : Spans) {
3334DwarfCompileUnit *CU = it.first;
3335 CUs.push_back(CU);
3336 }
3337
3338// Sort the CU list (again, to ensure consistent output order).
3339llvm::sort(CUs, [](constDwarfCompileUnit *A,constDwarfCompileUnit *B) {
3340returnA->getUniqueID() <B->getUniqueID();
3341 });
3342
3343// Emit an arange table for each CU we used.
3344for (DwarfCompileUnit *CU : CUs) {
3345 std::vector<ArangeSpan> &List = Spans[CU];
3346
3347// Describe the skeleton CU's offset and length, not the dwo file's.
3348if (auto *Skel =CU->getSkeleton())
3349CU = Skel;
3350
3351// Emit size of content not including length itself.
3352unsigned ContentSize =
3353sizeof(int16_t) +// DWARF ARange version number
3354Asm->getDwarfOffsetByteSize() +// Offset of CU in the .debug_info
3355// section
3356sizeof(int8_t) +// Pointer Size (in bytes)
3357sizeof(int8_t);// Segment Size (in bytes)
3358
3359unsigned TupleSize = PtrSize * 2;
3360
3361// 7.20 in the Dwarf specs requires the table to be aligned to a tuple.
3362unsignedPadding =offsetToAlignment(
3363Asm->getUnitLengthFieldByteSize() + ContentSize,Align(TupleSize));
3364
3365 ContentSize +=Padding;
3366 ContentSize += (List.size() + 1) * TupleSize;
3367
3368// For each compile unit, write the list of spans it covers.
3369Asm->emitDwarfUnitLength(ContentSize,"Length of ARange Set");
3370Asm->OutStreamer->AddComment("DWARF Arange version number");
3371Asm->emitInt16(dwarf::DW_ARANGES_VERSION);
3372Asm->OutStreamer->AddComment("Offset Into Debug Info Section");
3373 emitSectionReference(*CU);
3374Asm->OutStreamer->AddComment("Address Size (in bytes)");
3375Asm->emitInt8(PtrSize);
3376Asm->OutStreamer->AddComment("Segment Size (in bytes)");
3377Asm->emitInt8(0);
3378
3379Asm->OutStreamer->emitFill(Padding, 0xff);
3380
3381for (constArangeSpan &Span :List) {
3382Asm->emitLabelReference(Span.Start, PtrSize);
3383
3384// Calculate the size as being from the span start to its end.
3385//
3386// If the size is zero, then round it up to one byte. The DWARF
3387// specification requires that entries in this table have nonzero
3388// lengths.
3389auto SizeRef = SymSize.find(Span.Start);
3390if ((SizeRef == SymSize.end() || SizeRef->second != 0) && Span.End) {
3391Asm->emitLabelDifference(Span.End, Span.Start, PtrSize);
3392 }else {
3393// For symbols without an end marker (e.g. common), we
3394// write a single arange entry containing just that one symbol.
3395uint64_tSize;
3396if (SizeRef == SymSize.end() || SizeRef->second == 0)
3397Size = 1;
3398else
3399Size = SizeRef->second;
3400
3401Asm->OutStreamer->emitIntValue(Size, PtrSize);
3402 }
3403 }
3404
3405Asm->OutStreamer->AddComment("ARange terminator");
3406Asm->OutStreamer->emitIntValue(0, PtrSize);
3407Asm->OutStreamer->emitIntValue(0, PtrSize);
3408 }
3409}
3410
3411/// Emit a single range list. We handle both DWARF v5 and earlier.
3412staticvoidemitRangeList(DwarfDebug &DD,AsmPrinter *Asm,
3413constRangeSpanList &List) {
3414emitRangeList(DD, Asm,List.Label,List.Ranges, *List.CU,
3415 dwarf::DW_RLE_base_addressx, dwarf::DW_RLE_offset_pair,
3416 dwarf::DW_RLE_startx_length, dwarf::DW_RLE_end_of_list,
3417llvm::dwarf::RangeListEncodingString,
3418List.CU->getCUNode()->getRangesBaseAddress() ||
3419 DD.getDwarfVersion() >= 5,
3420 [](auto) {});
3421}
3422
3423void DwarfDebug::emitDebugRangesImpl(constDwarfFile &Holder,MCSection *Section) {
3424if (Holder.getRangeLists().empty())
3425return;
3426
3427assert(useRangesSection());
3428assert(!CUMap.empty());
3429assert(llvm::any_of(CUMap, [](constdecltype(CUMap)::value_type &Pair) {
3430return !Pair.second->getCUNode()->isDebugDirectivesOnly();
3431 }));
3432
3433Asm->OutStreamer->switchSection(Section);
3434
3435MCSymbol *TableEnd =nullptr;
3436if (getDwarfVersion() >= 5)
3437 TableEnd =emitRnglistsTableHeader(Asm, Holder);
3438
3439for (constRangeSpanList &List : Holder.getRangeLists())
3440emitRangeList(*this,Asm,List);
3441
3442if (TableEnd)
3443Asm->OutStreamer->emitLabel(TableEnd);
3444}
3445
3446/// Emit address ranges into the .debug_ranges section or into the DWARF v5
3447/// .debug_rnglists section.
3448void DwarfDebug::emitDebugRanges() {
3449constauto &Holder =useSplitDwarf() ? SkeletonHolder : InfoHolder;
3450
3451 emitDebugRangesImpl(Holder,
3452getDwarfVersion() >= 5
3453 ?Asm->getObjFileLowering().getDwarfRnglistsSection()
3454 :Asm->getObjFileLowering().getDwarfRangesSection());
3455}
3456
3457void DwarfDebug::emitDebugRangesDWO() {
3458 emitDebugRangesImpl(InfoHolder,
3459Asm->getObjFileLowering().getDwarfRnglistsDWOSection());
3460}
3461
3462/// Emit the header of a DWARF 5 macro section, or the GNU extension for
3463/// DWARF 4.
3464staticvoidemitMacroHeader(AsmPrinter *Asm,constDwarfDebug &DD,
3465constDwarfCompileUnit &CU,uint16_t DwarfVersion) {
3466enum HeaderFlagMask {
3467#define HANDLE_MACRO_FLAG(ID, NAME) MACRO_FLAG_##NAME = ID,
3468#include "llvm/BinaryFormat/Dwarf.def"
3469 };
3470 Asm->OutStreamer->AddComment("Macro information version");
3471 Asm->emitInt16(DwarfVersion >= 5 ? DwarfVersion : 4);
3472// We emit the line offset flag unconditionally here, since line offset should
3473// be mostly present.
3474if (Asm->isDwarf64()) {
3475 Asm->OutStreamer->AddComment("Flags: 64 bit, debug_line_offset present");
3476 Asm->emitInt8(MACRO_FLAG_OFFSET_SIZE | MACRO_FLAG_DEBUG_LINE_OFFSET);
3477 }else {
3478 Asm->OutStreamer->AddComment("Flags: 32 bit, debug_line_offset present");
3479 Asm->emitInt8(MACRO_FLAG_DEBUG_LINE_OFFSET);
3480 }
3481 Asm->OutStreamer->AddComment("debug_line_offset");
3482if (DD.useSplitDwarf())
3483 Asm->emitDwarfLengthOrOffset(0);
3484else
3485 Asm->emitDwarfSymbolReference(CU.getLineTableStartSym());
3486}
3487
3488void DwarfDebug::handleMacroNodes(DIMacroNodeArray Nodes,DwarfCompileUnit &U) {
3489for (auto *MN : Nodes) {
3490if (auto *M = dyn_cast<DIMacro>(MN))
3491 emitMacro(*M);
3492elseif (auto *F = dyn_cast<DIMacroFile>(MN))
3493 emitMacroFile(*F, U);
3494else
3495llvm_unreachable("Unexpected DI type!");
3496 }
3497}
3498
3499void DwarfDebug::emitMacro(DIMacro &M) {
3500StringRefName =M.getName();
3501StringRefValue =M.getValue();
3502
3503// There should be one space between the macro name and the macro value in
3504// define entries. In undef entries, only the macro name is emitted.
3505 std::string Str =Value.empty() ?Name.str() : (Name +" " +Value).str();
3506
3507if (UseDebugMacroSection) {
3508if (getDwarfVersion() >= 5) {
3509unsignedType =M.getMacinfoType() ==dwarf::DW_MACINFO_define
3510 ? dwarf::DW_MACRO_define_strx
3511 : dwarf::DW_MACRO_undef_strx;
3512Asm->OutStreamer->AddComment(dwarf::MacroString(Type));
3513Asm->emitULEB128(Type);
3514Asm->OutStreamer->AddComment("Line Number");
3515Asm->emitULEB128(M.getLine());
3516Asm->OutStreamer->AddComment("Macro String");
3517Asm->emitULEB128(
3518 InfoHolder.getStringPool().getIndexedEntry(*Asm, Str).getIndex());
3519 }else {
3520unsignedType =M.getMacinfoType() ==dwarf::DW_MACINFO_define
3521 ? dwarf::DW_MACRO_GNU_define_indirect
3522 : dwarf::DW_MACRO_GNU_undef_indirect;
3523Asm->OutStreamer->AddComment(dwarf::GnuMacroString(Type));
3524Asm->emitULEB128(Type);
3525Asm->OutStreamer->AddComment("Line Number");
3526Asm->emitULEB128(M.getLine());
3527Asm->OutStreamer->AddComment("Macro String");
3528Asm->emitDwarfSymbolReference(
3529 InfoHolder.getStringPool().getEntry(*Asm, Str).getSymbol());
3530 }
3531 }else {
3532Asm->OutStreamer->AddComment(dwarf::MacinfoString(M.getMacinfoType()));
3533Asm->emitULEB128(M.getMacinfoType());
3534Asm->OutStreamer->AddComment("Line Number");
3535Asm->emitULEB128(M.getLine());
3536Asm->OutStreamer->AddComment("Macro String");
3537Asm->OutStreamer->emitBytes(Str);
3538Asm->emitInt8('\0');
3539 }
3540}
3541
3542void DwarfDebug::emitMacroFileImpl(
3543DIMacroFile &MF,DwarfCompileUnit &U,unsigned StartFile,unsigned EndFile,
3544StringRef (*MacroFormToString)(unsigned Form)) {
3545
3546Asm->OutStreamer->AddComment(MacroFormToString(StartFile));
3547Asm->emitULEB128(StartFile);
3548Asm->OutStreamer->AddComment("Line Number");
3549Asm->emitULEB128(MF.getLine());
3550Asm->OutStreamer->AddComment("File Number");
3551DIFile &F = *MF.getFile();
3552if (useSplitDwarf())
3553Asm->emitULEB128(getDwoLineTable(U)->getFile(
3554F.getDirectory(),F.getFilename(),getMD5AsBytes(&F),
3555Asm->OutContext.getDwarfVersion(),F.getSource()));
3556else
3557Asm->emitULEB128(U.getOrCreateSourceID(&F));
3558 handleMacroNodes(MF.getElements(), U);
3559Asm->OutStreamer->AddComment(MacroFormToString(EndFile));
3560Asm->emitULEB128(EndFile);
3561}
3562
3563void DwarfDebug::emitMacroFile(DIMacroFile &F,DwarfCompileUnit &U) {
3564// DWARFv5 macro and DWARFv4 macinfo share some common encodings,
3565// so for readibility/uniformity, We are explicitly emitting those.
3566assert(F.getMacinfoType() ==dwarf::DW_MACINFO_start_file);
3567if (UseDebugMacroSection)
3568 emitMacroFileImpl(
3569F, U, dwarf::DW_MACRO_start_file, dwarf::DW_MACRO_end_file,
3570 (getDwarfVersion() >= 5) ?dwarf::MacroString :dwarf::GnuMacroString);
3571else
3572 emitMacroFileImpl(F, U,dwarf::DW_MACINFO_start_file,
3573dwarf::DW_MACINFO_end_file,dwarf::MacinfoString);
3574}
3575
3576void DwarfDebug::emitDebugMacinfoImpl(MCSection *Section) {
3577for (constauto &P : CUMap) {
3578auto &TheCU = *P.second;
3579auto *SkCU = TheCU.getSkeleton();
3580DwarfCompileUnit &U = SkCU ? *SkCU : TheCU;
3581auto *CUNode = cast<DICompileUnit>(P.first);
3582 DIMacroNodeArray Macros = CUNode->getMacros();
3583if (Macros.empty())
3584continue;
3585Asm->OutStreamer->switchSection(Section);
3586Asm->OutStreamer->emitLabel(U.getMacroLabelBegin());
3587if (UseDebugMacroSection)
3588emitMacroHeader(Asm, *this, U,getDwarfVersion());
3589 handleMacroNodes(Macros, U);
3590Asm->OutStreamer->AddComment("End Of Macro List Mark");
3591Asm->emitInt8(0);
3592 }
3593}
3594
3595/// Emit macros into a debug macinfo/macro section.
3596void DwarfDebug::emitDebugMacinfo() {
3597auto &ObjLower =Asm->getObjFileLowering();
3598 emitDebugMacinfoImpl(UseDebugMacroSection
3599 ? ObjLower.getDwarfMacroSection()
3600 : ObjLower.getDwarfMacinfoSection());
3601}
3602
3603void DwarfDebug::emitDebugMacinfoDWO() {
3604auto &ObjLower =Asm->getObjFileLowering();
3605 emitDebugMacinfoImpl(UseDebugMacroSection
3606 ? ObjLower.getDwarfMacroDWOSection()
3607 : ObjLower.getDwarfMacinfoDWOSection());
3608}
3609
3610// DWARF5 Experimental Separate Dwarf emitters.
3611
3612void DwarfDebug::initSkeletonUnit(constDwarfUnit &U,DIE &Die,
3613 std::unique_ptr<DwarfCompileUnit> NewU) {
3614
3615if (!CompilationDir.empty())
3616 NewU->addString(Die, dwarf::DW_AT_comp_dir, CompilationDir);
3617 addGnuPubAttributes(*NewU, Die);
3618
3619 SkeletonHolder.addUnit(std::move(NewU));
3620}
3621
3622DwarfCompileUnit &DwarfDebug::constructSkeletonCU(constDwarfCompileUnit &CU) {
3623
3624auto OwnedUnit = std::make_unique<DwarfCompileUnit>(
3625CU.getUniqueID(),CU.getCUNode(),Asm,this, &SkeletonHolder,
3626UnitKind::Skeleton);
3627DwarfCompileUnit &NewCU = *OwnedUnit;
3628 NewCU.setSection(Asm->getObjFileLowering().getDwarfInfoSection());
3629
3630 NewCU.initStmtList();
3631
3632if (useSegmentedStringOffsetsTable())
3633 NewCU.addStringOffsetsStart();
3634
3635 initSkeletonUnit(CU, NewCU.getUnitDie(), std::move(OwnedUnit));
3636
3637return NewCU;
3638}
3639
3640// Emit the .debug_info.dwo section for separated dwarf. This contains the
3641// compile units that would normally be in debug_info.
3642void DwarfDebug::emitDebugInfoDWO() {
3643assert(useSplitDwarf() &&"No split dwarf debug info?");
3644// Don't emit relocations into the dwo file.
3645 InfoHolder.emitUnits(/* UseOffsets */true);
3646}
3647
3648// Emit the .debug_abbrev.dwo section for separated dwarf. This contains the
3649// abbreviations for the .debug_info.dwo section.
3650void DwarfDebug::emitDebugAbbrevDWO() {
3651assert(useSplitDwarf() &&"No split dwarf?");
3652 InfoHolder.emitAbbrevs(Asm->getObjFileLowering().getDwarfAbbrevDWOSection());
3653}
3654
3655void DwarfDebug::emitDebugLineDWO() {
3656assert(useSplitDwarf() &&"No split dwarf?");
3657 SplitTypeUnitFileTable.Emit(
3658 *Asm->OutStreamer,MCDwarfLineTableParams(),
3659Asm->getObjFileLowering().getDwarfLineDWOSection());
3660}
3661
3662void DwarfDebug::emitStringOffsetsTableHeaderDWO() {
3663assert(useSplitDwarf() &&"No split dwarf?");
3664 InfoHolder.getStringPool().emitStringOffsetsTableHeader(
3665 *Asm,Asm->getObjFileLowering().getDwarfStrOffDWOSection(),
3666 InfoHolder.getStringOffsetsStartSym());
3667}
3668
3669// Emit the .debug_str.dwo section for separated dwarf. This contains the
3670// string section and is identical in format to traditional .debug_str
3671// sections.
3672void DwarfDebug::emitDebugStrDWO() {
3673if (useSegmentedStringOffsetsTable())
3674 emitStringOffsetsTableHeaderDWO();
3675assert(useSplitDwarf() &&"No split dwarf?");
3676MCSection *OffSec =Asm->getObjFileLowering().getDwarfStrOffDWOSection();
3677 InfoHolder.emitStrings(Asm->getObjFileLowering().getDwarfStrDWOSection(),
3678 OffSec,/* UseRelativeOffsets = */false);
3679}
3680
3681// Emit address pool.
3682void DwarfDebug::emitDebugAddr() {
3683 AddrPool.emit(*Asm,Asm->getObjFileLowering().getDwarfAddrSection());
3684}
3685
3686MCDwarfDwoLineTable *DwarfDebug::getDwoLineTable(constDwarfCompileUnit &CU) {
3687if (!useSplitDwarf())
3688returnnullptr;
3689constDICompileUnit *DIUnit =CU.getCUNode();
3690 SplitTypeUnitFileTable.maybeSetRootFile(
3691 DIUnit->getDirectory(), DIUnit->getFilename(),
3692getMD5AsBytes(DIUnit->getFile()), DIUnit->getSource());
3693return &SplitTypeUnitFileTable;
3694}
3695
3696uint64_tDwarfDebug::makeTypeSignature(StringRef Identifier) {
3697MD5 Hash;
3698 Hash.update(Identifier);
3699// ... take the least significant 8 bytes and return those. Our MD5
3700// implementation always returns its results in little endian, so we actually
3701// need the "high" word.
3702MD5::MD5Result Result;
3703 Hash.final(Result);
3704return Result.high();
3705}
3706
3707voidDwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
3708StringRef Identifier,DIE &RefDie,
3709constDICompositeType *CTy) {
3710// Fast path if we're building some type units and one has already used the
3711// address pool we know we're going to throw away all this work anyway, so
3712// don't bother building dependent types.
3713if (!TypeUnitsUnderConstruction.empty() && AddrPool.hasBeenUsed())
3714return;
3715
3716auto Ins = TypeSignatures.insert(std::make_pair(CTy, 0));
3717if (!Ins.second) {
3718CU.addDIETypeSignature(RefDie, Ins.first->second);
3719return;
3720 }
3721
3722setCurrentDWARF5AccelTable(DWARF5AccelTableKind::TU);
3723bool TopLevelType = TypeUnitsUnderConstruction.empty();
3724 AddrPool.resetUsedFlag();
3725
3726auto OwnedUnit = std::make_unique<DwarfTypeUnit>(
3727CU,Asm,this, &InfoHolder, NumTypeUnitsCreated++, getDwoLineTable(CU));
3728DwarfTypeUnit &NewTU = *OwnedUnit;
3729DIE &UnitDie = NewTU.getUnitDie();
3730 TypeUnitsUnderConstruction.emplace_back(std::move(OwnedUnit), CTy);
3731
3732 NewTU.addUInt(UnitDie, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
3733CU.getLanguage());
3734
3735uint64_t Signature =makeTypeSignature(Identifier);
3736 NewTU.setTypeSignature(Signature);
3737 Ins.first->second = Signature;
3738
3739if (useSplitDwarf()) {
3740// Although multiple type units can have the same signature, they are not
3741// guranteed to be bit identical. When LLDB uses .debug_names it needs to
3742// know from which CU a type unit came from. These two attrbutes help it to
3743// figure that out.
3744if (getDwarfVersion() >= 5) {
3745if (!CompilationDir.empty())
3746 NewTU.addString(UnitDie, dwarf::DW_AT_comp_dir, CompilationDir);
3747 NewTU.addString(UnitDie, dwarf::DW_AT_dwo_name,
3748Asm->TM.Options.MCOptions.SplitDwarfFile);
3749 }
3750MCSection *Section =
3751getDwarfVersion() <= 4
3752 ?Asm->getObjFileLowering().getDwarfTypesDWOSection()
3753 :Asm->getObjFileLowering().getDwarfInfoDWOSection();
3754 NewTU.setSection(Section);
3755 }else {
3756MCSection *Section =
3757getDwarfVersion() <= 4
3758 ?Asm->getObjFileLowering().getDwarfTypesSection(Signature)
3759 :Asm->getObjFileLowering().getDwarfInfoSection(Signature);
3760 NewTU.setSection(Section);
3761// Non-split type units reuse the compile unit's line table.
3762CU.applyStmtList(UnitDie);
3763 }
3764
3765// Add DW_AT_str_offsets_base to the type unit DIE, but not for split type
3766// units.
3767if (useSegmentedStringOffsetsTable() && !useSplitDwarf())
3768 NewTU.addStringOffsetsStart();
3769
3770 NewTU.setType(NewTU.createTypeDIE(CTy));
3771
3772if (TopLevelType) {
3773auto TypeUnitsToAdd = std::move(TypeUnitsUnderConstruction);
3774 TypeUnitsUnderConstruction.clear();
3775
3776// Types referencing entries in the address table cannot be placed in type
3777// units.
3778if (AddrPool.hasBeenUsed()) {
3779 AccelTypeUnitsDebugNames.clear();
3780// Remove all the types built while building this type.
3781// This is pessimistic as some of these types might not be dependent on
3782// the type that used an address.
3783for (constauto &TU : TypeUnitsToAdd)
3784 TypeSignatures.erase(TU.second);
3785
3786// Construct this type in the CU directly.
3787// This is inefficient because all the dependent types will be rebuilt
3788// from scratch, including building them in type units, discovering that
3789// they depend on addresses, throwing them out and rebuilding them.
3790setCurrentDWARF5AccelTable(DWARF5AccelTableKind::CU);
3791CU.constructTypeDIE(RefDie, cast<DICompositeType>(CTy));
3792CU.updateAcceleratorTables(CTy->getScope(), CTy, RefDie);
3793return;
3794 }
3795
3796// If the type wasn't dependent on fission addresses, finish adding the type
3797// and all its dependent types.
3798for (auto &TU : TypeUnitsToAdd) {
3799 InfoHolder.computeSizeAndOffsetsForUnit(TU.first.get());
3800 InfoHolder.emitUnit(TU.first.get(),useSplitDwarf());
3801if (getDwarfVersion() >= 5 &&
3802getAccelTableKind() ==AccelTableKind::Dwarf) {
3803if (useSplitDwarf())
3804 AccelDebugNames.addTypeUnitSignature(*TU.first);
3805else
3806 AccelDebugNames.addTypeUnitSymbol(*TU.first);
3807 }
3808 }
3809 AccelTypeUnitsDebugNames.convertDieToOffset();
3810 AccelDebugNames.addTypeEntries(AccelTypeUnitsDebugNames);
3811 AccelTypeUnitsDebugNames.clear();
3812setCurrentDWARF5AccelTable(DWARF5AccelTableKind::CU);
3813 }
3814CU.addDIETypeSignature(RefDie, Signature);
3815}
3816
3817// Add the Name along with its companion DIE to the appropriate accelerator
3818// table (for AccelTableKind::Dwarf it's always AccelDebugNames, for
3819// AccelTableKind::Apple, we use the table we got as an argument). If
3820// accelerator tables are disabled, this function does nothing.
3821template <typename DataT>
3822void DwarfDebug::addAccelNameImpl(
3823constDwarfUnit &Unit,
3824constDICompileUnit::DebugNameTableKind NameTableKind,
3825AccelTable<DataT> &AppleAccel,StringRefName,constDIE &Die) {
3826if (getAccelTableKind() ==AccelTableKind::None ||
3827 Unit.getUnitDie().getTag() == dwarf::DW_TAG_skeleton_unit ||Name.empty())
3828return;
3829
3830if (getAccelTableKind() !=AccelTableKind::Apple &&
3831 NameTableKind !=DICompileUnit::DebugNameTableKind::Apple &&
3832 NameTableKind !=DICompileUnit::DebugNameTableKind::Default)
3833return;
3834
3835DwarfFile &Holder =useSplitDwarf() ? SkeletonHolder : InfoHolder;
3836DwarfStringPoolEntryRefRef = Holder.getStringPool().getEntry(*Asm,Name);
3837
3838switch (getAccelTableKind()) {
3839caseAccelTableKind::Apple:
3840 AppleAccel.addName(Ref, Die);
3841break;
3842caseAccelTableKind::Dwarf: {
3843DWARF5AccelTable &Current =getCurrentDWARF5AccelTable();
3844assert(((&Current == &AccelTypeUnitsDebugNames) ||
3845 ((&Current == &AccelDebugNames) &&
3846 (Unit.getUnitDie().getTag() != dwarf::DW_TAG_type_unit))) &&
3847"Kind is CU but TU is being processed.");
3848assert(((&Current == &AccelDebugNames) ||
3849 ((&Current == &AccelTypeUnitsDebugNames) &&
3850 (Unit.getUnitDie().getTag() == dwarf::DW_TAG_type_unit))) &&
3851"Kind is TU but CU is being processed.");
3852// The type unit can be discarded, so need to add references to final
3853// acceleration table once we know it's complete and we emit it.
3854 Current.addName(Ref, Die, Unit.getUniqueID(),
3855 Unit.getUnitDie().getTag() == dwarf::DW_TAG_type_unit);
3856break;
3857 }
3858caseAccelTableKind::Default:
3859llvm_unreachable("Default should have already been resolved.");
3860caseAccelTableKind::None:
3861llvm_unreachable("None handled above");
3862 }
3863}
3864
3865voidDwarfDebug::addAccelName(
3866constDwarfUnit &Unit,
3867constDICompileUnit::DebugNameTableKind NameTableKind,StringRefName,
3868constDIE &Die) {
3869 addAccelNameImpl(Unit, NameTableKind, AccelNames,Name, Die);
3870}
3871
3872voidDwarfDebug::addAccelObjC(
3873constDwarfUnit &Unit,
3874constDICompileUnit::DebugNameTableKind NameTableKind,StringRefName,
3875constDIE &Die) {
3876// ObjC names go only into the Apple accelerator tables.
3877if (getAccelTableKind() ==AccelTableKind::Apple)
3878 addAccelNameImpl(Unit, NameTableKind, AccelObjC,Name, Die);
3879}
3880
3881voidDwarfDebug::addAccelNamespace(
3882constDwarfUnit &Unit,
3883constDICompileUnit::DebugNameTableKind NameTableKind,StringRefName,
3884constDIE &Die) {
3885 addAccelNameImpl(Unit, NameTableKind, AccelNamespace,Name, Die);
3886}
3887
3888voidDwarfDebug::addAccelType(
3889constDwarfUnit &Unit,
3890constDICompileUnit::DebugNameTableKind NameTableKind,StringRefName,
3891constDIE &Die,char Flags) {
3892 addAccelNameImpl(Unit, NameTableKind, AccelTypes,Name, Die);
3893}
3894
3895uint16_tDwarfDebug::getDwarfVersion() const{
3896returnAsm->OutStreamer->getContext().getDwarfVersion();
3897}
3898
3899dwarf::FormDwarfDebug::getDwarfSectionOffsetForm() const{
3900if (Asm->getDwarfVersion() >= 4)
3901return dwarf::Form::DW_FORM_sec_offset;
3902assert((!Asm->isDwarf64() || (Asm->getDwarfVersion() == 3)) &&
3903"DWARF64 is not defined prior DWARFv3");
3904returnAsm->isDwarf64() ? dwarf::Form::DW_FORM_data8
3905 : dwarf::Form::DW_FORM_data4;
3906}
3907
3908constMCSymbol *DwarfDebug::getSectionLabel(constMCSection *S) {
3909return SectionLabels.lookup(S);
3910}
3911
3912voidDwarfDebug::insertSectionLabel(constMCSymbol *S) {
3913if (SectionLabels.insert(std::make_pair(&S->getSection(), S)).second)
3914if (useSplitDwarf() ||getDwarfVersion() >= 5)
3915 AddrPool.getIndex(S);
3916}
3917
3918std::optional<MD5::MD5Result>
3919DwarfDebug::getMD5AsBytes(constDIFile *File) const{
3920assert(File);
3921if (getDwarfVersion() < 5)
3922return std::nullopt;
3923 std::optional<DIFile::ChecksumInfo<StringRef>> Checksum = File->getChecksum();
3924if (!Checksum || Checksum->Kind !=DIFile::CSK_MD5)
3925return std::nullopt;
3926
3927// Convert the string checksum to an MD5Result for the streamer.
3928// The verifier validates the checksum so we assume it's okay.
3929// An MD5 checksum is 16 bytes.
3930 std::string ChecksumString = fromHex(Checksum->Value);
3931MD5::MD5Result CKMem;
3932 std::copy(ChecksumString.begin(), ChecksumString.end(), CKMem.data());
3933return CKMem;
3934}
3935
3936boolDwarfDebug::alwaysUseRanges(constDwarfCompileUnit &CU) const{
3937if (MinimizeAddr ==MinimizeAddrInV5::Ranges)
3938returntrue;
3939if (MinimizeAddr !=MinimizeAddrInV5::Default)
3940returnfalse;
3941if (useSplitDwarf())
3942returntrue;
3943returnfalse;
3944}
3945
3946voidDwarfDebug::beginCodeAlignment(constMachineBasicBlock &MBB) {
3947if (MBB.getAlignment() ==Align(1))
3948return;
3949
3950auto *SP =MBB.getParent()->getFunction().getSubprogram();
3951bool NoDebug =
3952 !SP || SP->getUnit()->getEmissionKind() ==DICompileUnit::NoDebug;
3953
3954if (NoDebug)
3955return;
3956
3957auto PrevLoc =Asm->OutStreamer->getContext().getCurrentDwarfLoc();
3958if (PrevLoc.getLine()) {
3959Asm->OutStreamer->emitDwarfLocDirective(
3960 PrevLoc.getFileNum(), 0, PrevLoc.getColumn(), 0, 0, 0,StringRef());
3961MCDwarfLineEntry::make(Asm->OutStreamer.get(),
3962Asm->OutStreamer->getCurrentSectionOnly());
3963 }
3964}
SelectTypeKind::FP
@ FP
APInt.h
This file implements a class to represent arbitrary precision integral constant values and operations...
MBB
MachineBasicBlock & MBB
Definition:ARMSLSHardening.cpp:71
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
AsmPrinter.h
true
basic Basic Alias true
Definition:BasicAliasAnalysis.cpp:1981
BT
BitTracker BT
Definition:BitTracker.cpp:73
hasObjCCategory
static Expected< bool > hasObjCCategory(BitstreamCursor &Stream)
Definition:BitcodeReader.cpp:323
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
ByteStreamer.h
Casting.h
CommandLine.h
clEnumValN
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition:CommandLine.h:686
clEnumVal
#define clEnumVal(ENUMVAL, DESC)
Definition:CommandLine.h:684
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
DIEHash.h
DIE.h
DWARFDataExtractor.h
DWARFExpression.h
Idx
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Definition:DeadArgumentElimination.cpp:353
DebugInfoMetadata.h
Debug.h
LLVM_DEBUG
#define LLVM_DEBUG(...)
Definition:Debug.h:106
DwarfCompileUnit.h
isObjCClass
static bool isObjCClass(StringRef Name)
Definition:DwarfDebug.cpp:449
NoDwarfRangesSection
static cl::opt< bool > NoDwarfRangesSection("no-dwarf-ranges-section", cl::Hidden, cl::desc("Disable emission .debug_ranges section."), cl::init(false))
finishCallSiteParams
static void finishCallSiteParams(ValT Val, const DIExpression *Expr, ArrayRef< FwdRegParamInfo > DescribedParams, ParamSet &Params)
Emit call site parameter entries that are described by the given value and debug expression.
Definition:DwarfDebug.cpp:599
UseGNUDebugMacro
static cl::opt< bool > UseGNUDebugMacro("use-gnu-debug-macro", cl::Hidden, cl::desc("Emit the GNU .debug_macro format with DWARF <5"), cl::init(false))
DwarfInlinedStrings
static cl::opt< DefaultOnOff > DwarfInlinedStrings("dwarf-inlined-strings", cl::Hidden, cl::desc("Use inlined strings rather than string section."), cl::values(clEnumVal(Default, "Default for platform"), clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), cl::init(Default))
validThroughout
static bool validThroughout(LexicalScopes &LScopes, const MachineInstr *DbgValue, const MachineInstr *RangeEnd, const InstructionOrdering &Ordering)
Determine whether a singular DBG_VALUE is valid for the entirety of its enclosing lexical scope.
Definition:DwarfDebug.cpp:1596
GenerateARangeSection
static cl::opt< bool > GenerateARangeSection("generate-arange-section", cl::Hidden, cl::desc("Generate dwarf aranges"), cl::init(false))
DwarfLinkageNames
static cl::opt< LinkageNameOption > DwarfLinkageNames("dwarf-linkage-names", cl::Hidden, cl::desc("Which DWARF linkage-name attributes to emit."), cl::values(clEnumValN(DefaultLinkageNames, "Default", "Default for platform"), clEnumValN(AllLinkageNames, "All", "All"), clEnumValN(AbstractLinkageNames, "Abstract", "Abstract subprograms")), cl::init(DefaultLinkageNames))
addToFwdRegWorklist
static void addToFwdRegWorklist(FwdRegWorklist &Worklist, unsigned Reg, const DIExpression *Expr, ArrayRef< FwdRegParamInfo > ParamsToAdd)
Add Reg to the worklist, if it's not already present, and mark that the given parameter registers' va...
Definition:DwarfDebug.cpp:630
GenerateDwarfTypeUnits
static cl::opt< bool > GenerateDwarfTypeUnits("generate-type-units", cl::Hidden, cl::desc("Generate DWARF4 type units."), cl::init(false))
sortGlobalExprs
static SmallVectorImpl< DwarfCompileUnit::GlobalExpr > & sortGlobalExprs(SmallVectorImpl< DwarfCompileUnit::GlobalExpr > &GVEs)
Sort and unique GVEs by comparing their fragment offset.
Definition:DwarfDebug.cpp:1117
LinkageNameOption
LinkageNameOption
Definition:DwarfDebug.cpp:137
DefaultLinkageNames
@ DefaultLinkageNames
Definition:DwarfDebug.cpp:138
AbstractLinkageNames
@ AbstractLinkageNames
Definition:DwarfDebug.cpp:140
AllLinkageNames
@ AllLinkageNames
Definition:DwarfDebug.cpp:139
computeIndexValue
static dwarf::PubIndexEntryDescriptor computeIndexValue(DwarfUnit *CU, const DIE *Die)
computeIndexValue - Compute the gdb index value for the DIE and CU.
Definition:DwarfDebug.cpp:2708
getFragmentOffsetInBits
static uint64_t getFragmentOffsetInBits(const DIExpression &Expr)
Definition:DwarfDebug.cpp:268
DwarfOpConvert
static cl::opt< DefaultOnOff > DwarfOpConvert("dwarf-op-convert", cl::Hidden, cl::desc("Enable use of the DWARFv5 DW_OP_convert operator"), cl::values(clEnumVal(Default, "Default for platform"), clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), cl::init(Default))
findPrologueEndLoc
static std::pair< const MachineInstr *, bool > findPrologueEndLoc(const MachineFunction *MF)
Definition:DwarfDebug.cpp:2148
collectCallSiteParameters
static void collectCallSiteParameters(const MachineInstr *CallMI, ParamSet &Params)
Try to interpret values loaded into registers that forward parameters for CallMI.
Definition:DwarfDebug.cpp:797
emitRnglistsTableHeader
static MCSymbol * emitRnglistsTableHeader(AsmPrinter *Asm, const DwarfFile &Holder)
Definition:DwarfDebug.cpp:3043
recordSourceLine
static void recordSourceLine(AsmPrinter &Asm, unsigned Line, unsigned Col, const MDNode *S, unsigned Flags, unsigned CUID, uint16_t DwarfVersion, ArrayRef< std::unique_ptr< DwarfCompileUnit > > DCUs)
Register a source line with debug info.
Definition:DwarfDebug.cpp:2272
SplitDwarfCrossCuReferences
static cl::opt< bool > SplitDwarfCrossCuReferences("split-dwarf-cross-cu-references", cl::Hidden, cl::desc("Enable cross-cu references in DWO files"), cl::init(false))
UseDwarfRangesBaseAddressSpecifier
static cl::opt< bool > UseDwarfRangesBaseAddressSpecifier("use-dwarf-ranges-base-address-specifier", cl::Hidden, cl::desc("Use base address specifiers in debug_ranges"), cl::init(false))
interpretValues
static void interpretValues(const MachineInstr *CurMI, FwdRegWorklist &ForwardedRegWorklist, ParamSet &Params, ClobberedRegSet &ClobberedRegUnits)
Interpret values loaded into registers by CurMI.
Definition:DwarfDebug.cpp:651
interpretNextInstr
static bool interpretNextInstr(const MachineInstr *CurMI, FwdRegWorklist &ForwardedRegWorklist, ParamSet &Params, ClobberedRegSet &ClobberedRegUnits)
Definition:DwarfDebug.cpp:769
emitLocList
static void emitLocList(DwarfDebug &DD, AsmPrinter *Asm, const DebugLocStream::List &List)
Definition:DwarfDebug.cpp:3186
ULEB128PadSize
static constexpr unsigned ULEB128PadSize
Definition:DwarfDebug.cpp:173
DwarfSectionsAsReferences
static cl::opt< DefaultOnOff > DwarfSectionsAsReferences("dwarf-sections-as-references", cl::Hidden, cl::desc("Use sections+offset as references rather than labels."), cl::values(clEnumVal(Default, "Default for platform"), clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")), cl::init(Default))
DefaultOnOff
DefaultOnOff
Definition:DwarfDebug.cpp:87
Default
@ Default
Definition:DwarfDebug.cpp:87
Enable
@ Enable
Definition:DwarfDebug.cpp:87
Disable
@ Disable
Definition:DwarfDebug.cpp:87
computeAccelTableKind
static AccelTableKind computeAccelTableKind(unsigned DwarfVersion, bool GenerateTypeUnits, DebuggerKind Tuning, const Triple &TT)
Definition:DwarfDebug.cpp:306
forBothCUs
static void forBothCUs(DwarfCompileUnit &CU, Func F)
Definition:DwarfDebug.cpp:531
emitLoclistsTableHeader
static MCSymbol * emitLoclistsTableHeader(AsmPrinter *Asm, const DwarfDebug &DD)
Definition:DwarfDebug.cpp:3061
getRetainedNodeScope
static const DILocalScope * getRetainedNodeScope(const MDNode *N)
Definition:DwarfDebug.cpp:1515
combineDIExpressions
static const DIExpression * combineDIExpressions(const DIExpression *Original, const DIExpression *Addition)
Append the expression Addition to Original and return the result.
Definition:DwarfDebug.cpp:585
UnknownLocations
static cl::opt< DefaultOnOff > UnknownLocations("use-unknown-locations", cl::Hidden, cl::desc("Make an absence of debug location information explicit."), cl::values(clEnumVal(Default, "At top of block or after label"), clEnumVal(Enable, "In all cases"), clEnumVal(Disable, "Never")), cl::init(Default))
emitMacroHeader
static void emitMacroHeader(AsmPrinter *Asm, const DwarfDebug &DD, const DwarfCompileUnit &CU, uint16_t DwarfVersion)
Emit the header of a DWARF 5 macro section, or the GNU extension for DWARF 4.
Definition:DwarfDebug.cpp:3464
AccelTables
static cl::opt< AccelTableKind > AccelTables("accel-tables", cl::Hidden, cl::desc("Output dwarf accelerator tables."), cl::values(clEnumValN(AccelTableKind::Default, "Default", "Default for platform"), clEnumValN(AccelTableKind::None, "Disable", "Disabled."), clEnumValN(AccelTableKind::Apple, "Apple", "Apple"), clEnumValN(AccelTableKind::Dwarf, "Dwarf", "DWARF")), cl::init(AccelTableKind::Default))
MinimizeAddrInV5Option
static cl::opt< DwarfDebug::MinimizeAddrInV5 > MinimizeAddrInV5Option("minimize-addr-in-v5", cl::Hidden, cl::desc("Always use DW_AT_ranges in DWARFv5 whenever it could allow more " "address pool entry sharing to reduce relocations/object size"), cl::values(clEnumValN(DwarfDebug::MinimizeAddrInV5::Default, "Default", "Default address minimization strategy"), clEnumValN(DwarfDebug::MinimizeAddrInV5::Ranges, "Ranges", "Use rnglists for contiguous ranges if that allows " "using a pre-existing base address"), clEnumValN(DwarfDebug::MinimizeAddrInV5::Expressions, "Expressions", "Use exprloc addrx+offset expressions for any " "address with a prior base address"), clEnumValN(DwarfDebug::MinimizeAddrInV5::Form, "Form", "Use addrx+offset extension form for any address " "with a prior base address"), clEnumValN(DwarfDebug::MinimizeAddrInV5::Disabled, "Disabled", "Stuff")), cl::init(DwarfDebug::MinimizeAddrInV5::Default))
getObjCMethodName
static StringRef getObjCMethodName(StringRef In)
Definition:DwarfDebug.cpp:472
emitRangeList
static void emitRangeList(DwarfDebug &DD, AsmPrinter *Asm, MCSymbol *Sym, const Ranges &R, const DwarfCompileUnit &CU, unsigned BaseAddressx, unsigned OffsetPair, unsigned StartxLength, unsigned EndOfList, StringRef(*StringifyEnum)(unsigned), bool ShouldUseBaseAddress, PayloadEmitter EmitPayload)
Definition:DwarfDebug.cpp:3079
getDebugLocValue
static DbgValueLoc getDebugLocValue(const MachineInstr *MI)
Get .debug_loc entry for the instruction range starting at MI.
Definition:DwarfDebug.cpp:235
getObjCClassCategory
static void getObjCClassCategory(StringRef In, StringRef &Class, StringRef &Category)
Definition:DwarfDebug.cpp:460
DwarfDebug.h
DwarfExpression.h
DwarfUnit.h
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Size
uint64_t Size
Definition:ELFObjHandler.cpp:81
End
bool End
Definition:ELF_riscv.cpp:480
Sym
Symbol * Sym
Definition:ELF_riscv.cpp:479
EndOfList
@ EndOfList
Definition:FunctionInfo.cpp:23
GlobalVariable.h
TII
const HexagonInstrInfo * TII
Definition:HexagonCopyToCombine.cpp:125
MI
IRTranslator LLVM IR MI
Definition:IRTranslator.cpp:112
Function.h
Module.h
Module.h This file contains the declarations for the Module class.
LexicalScopes.h
MCAsmInfo.h
MCContext.h
DWARF2_FLAG_IS_STMT
#define DWARF2_FLAG_IS_STMT
Definition:MCDwarf.h:117
DWARF2_FLAG_PROLOGUE_END
#define DWARF2_FLAG_PROLOGUE_END
Definition:MCDwarf.h:119
DWARF2_FLAG_EPILOGUE_BEGIN
#define DWARF2_FLAG_EPILOGUE_BEGIN
Definition:MCDwarf.h:120
MCSection.h
MCStreamer.h
MCSymbol.h
MCTargetOptions.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
MD5.h
MachineBasicBlock.h
MachineFunction.h
MachineLocation.h
MachineModuleInfo.h
MachineOperand.h
TRI
unsigned const TargetRegisterInfo * TRI
Definition:MachineSink.cpp:2029
Range
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
P
#define P(N)
if
if(PassOpts->AAPipeline)
Definition:PassBuilderBindings.cpp:64
TBB
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
Definition:RISCVRedundantCopyElimination.cpp:76
Cond
const SmallVectorImpl< MachineOperand > & Cond
Definition:RISCVRedundantCopyElimination.cpp:75
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Statistic.h
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
STATISTIC
#define STATISTIC(VARNAME, DESC)
Definition:Statistic.h:166
StringExtras.h
This file contains some functions that are useful when dealing with strings.
TargetInstrInfo.h
TargetLoweringObjectFile.h
TargetLowering.h
This file describes how to lower LLVM code to machine code.
TargetRegisterInfo.h
TargetSubtargetInfo.h
isCopy
static bool isCopy(MachineInstr *MI)
Definition:Thumb2ITBlockPass.cpp:120
Triple.h
Twine.h
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
IV
static const uint32_t IV[8]
Definition:blake3_impl.h:78
LiveDebugValues::DbgValue
Class recording the (high level) value of a variable.
Definition:InstrRefBasedImpl.h:512
Node
Definition:ItaniumDemangle.h:163
ValT
llvm::APByteStreamer
Definition:ByteStreamer.h:39
llvm::AccelTable
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
Definition:AccelTable.h:202
llvm::AccelTable::clear
void clear()
Definition:AccelTable.h:208
llvm::AccelTable::addName
void addName(DwarfStringPoolEntryRef Name, Types &&... Args)
Definition:AccelTable.h:215
llvm::AddressPool::getIndex
unsigned getIndex(const MCSymbol *Sym, bool TLS=false)
Returns the index into the address pool with the given label/symbol.
Definition:AddressPool.cpp:19
llvm::AddressPool::isEmpty
bool isEmpty()
Definition:AddressPool.h:47
llvm::AddressPool::emit
void emit(AsmPrinter &Asm, MCSection *AddrSection)
Definition:AddressPool.cpp:42
llvm::AddressPool::setLabel
void setLabel(MCSymbol *Sym)
Definition:AddressPool.h:54
llvm::AddressPool::hasBeenUsed
bool hasBeenUsed() const
Definition:AddressPool.h:49
llvm::AddressPool::resetUsedFlag
void resetUsedFlag(bool HasBeenUsed=false)
Definition:AddressPool.h:51
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayRef::vec
std::vector< T > vec() const
Definition:ArrayRef.h:283
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition:ArrayRef.h:168
llvm::ArrayRef::data
const T * data() const
Definition:ArrayRef.h:165
llvm::AsmPrinter
This class is intended to be used as a driving class for all asm writers.
Definition:AsmPrinter.h:87
llvm::AsmPrinter::getObjFileLowering
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Definition:AsmPrinter.cpp:408
llvm::AsmPrinter::emitULEB128
void emitULEB128(uint64_t Value, const char *Desc=nullptr, unsigned PadTo=0) const
Emit the specified unsigned leb128 value.
Definition:AsmPrinter.cpp:3283
llvm::AsmPrinter::emitDwarfSymbolReference
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
Definition:AsmPrinterDwarf.cpp:131
llvm::AsmPrinter::MBBSectionRanges
MapVector< MBBSectionID, MBBSectionRange > MBBSectionRanges
Definition:AsmPrinter.h:141
llvm::AsmPrinter::isDwarf64
bool isDwarf64() const
Definition:AsmPrinter.cpp:4609
llvm::AsmPrinter::getDwarfDebug
DwarfDebug * getDwarfDebug()
Definition:AsmPrinter.h:240
llvm::AsmPrinter::emitDwarfLengthOrOffset
void emitDwarfLengthOrOffset(uint64_t Value) const
Emit 32- or 64-bit value depending on the DWARF format.
Definition:AsmPrinterDwarf.cpp:169
llvm::AsmPrinter::getUnitLengthFieldByteSize
unsigned int getUnitLengthFieldByteSize() const
Returns 4 for DWARF32 and 12 for DWARF64.
Definition:AsmPrinter.cpp:4624
llvm::AsmPrinter::TM
TargetMachine & TM
Target machine description.
Definition:AsmPrinter.h:90
llvm::AsmPrinter::getFunctionBegin
MCSymbol * getFunctionBegin() const
Definition:AsmPrinter.h:269
llvm::AsmPrinter::emitLabelDifference
void emitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
Emit something like ".long Hi-Lo" where the size in bytes of the directive is specified by Size and H...
Definition:AsmPrinter.cpp:3299
llvm::AsmPrinter::MAI
const MCAsmInfo * MAI
Target Asm Printer information.
Definition:AsmPrinter.h:93
llvm::AsmPrinter::MF
MachineFunction * MF
The current machine function.
Definition:AsmPrinter.h:105
llvm::AsmPrinter::emitDwarfOffset
void emitDwarfOffset(const MCSymbol *Label, uint64_t Offset) const
Emit something like ".long Label + Offset" or ".quad Label + Offset" depending on the DWARF format.
Definition:AsmPrinterDwarf.cpp:165
llvm::AsmPrinter::emitInt8
void emitInt8(int Value) const
Emit a byte directive and value.
Definition:AsmPrinter.cpp:3267
llvm::AsmPrinter::hasDebugInfo
bool hasDebugInfo() const
Returns true if valid debug info is present.
Definition:AsmPrinter.h:440
llvm::AsmPrinter::emitDwarfUnitLength
void emitDwarfUnitLength(uint64_t Length, const Twine &Comment) const
Emit a unit length field.
Definition:AsmPrinterDwarf.cpp:174
llvm::AsmPrinter::OutContext
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition:AsmPrinter.h:97
llvm::AsmPrinter::createTempSymbol
MCSymbol * createTempSymbol(const Twine &Name) const
Definition:AsmPrinter.cpp:4075
llvm::AsmPrinter::OutStreamer
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition:AsmPrinter.h:102
llvm::AsmPrinter::emitLabelReference
void emitLabelReference(const MCSymbol *Label, unsigned Size, bool IsSectionRelative=false) const
Emit something like ".long Label" where the size in bytes of the directive is specified by Size and L...
Definition:AsmPrinter.h:693
llvm::AsmPrinter::getDwarfOffsetByteSize
unsigned int getDwarfOffsetByteSize() const
Returns 4 for DWARF32 and 8 for DWARF64.
Definition:AsmPrinter.cpp:4613
llvm::AsmPrinter::getFunctionEnd
MCSymbol * getFunctionEnd() const
Definition:AsmPrinter.h:270
llvm::AsmPrinter::emitInt16
void emitInt16(int Value) const
Emit a short directive and value.
Definition:AsmPrinter.cpp:3270
llvm::AsmPrinter::getDataLayout
const DataLayout & getDataLayout() const
Return information about data layout.
Definition:AsmPrinter.cpp:412
llvm::AsmPrinter::getDwarfVersion
uint16_t getDwarfVersion() const
Definition:AsmPrinter.cpp:4601
llvm::BufferByteStreamer
Definition:ByteStreamer.h:90
llvm::BufferByteStreamer::emitInt8
void emitInt8(uint8_t Byte, const Twine &Comment) override
Definition:ByteStreamer.h:105
llvm::BufferByteStreamer::GenerateComments
const bool GenerateComments
Only verbose textual output needs comments.
Definition:ByteStreamer.h:99
llvm::ByteStreamer
Definition:ByteStreamer.h:24
llvm::ByteStreamer::emitULEB128
virtual void emitULEB128(uint64_t DWord, const Twine &Comment="", unsigned PadTo=0)=0
llvm::ByteStreamer::emitSLEB128
virtual void emitSLEB128(uint64_t DWord, const Twine &Comment="")=0
llvm::ByteStreamer::emitInt8
virtual void emitInt8(uint8_t Byte, const Twine &Comment="")=0
llvm::ByteStreamer::emitDIERef
virtual unsigned emitDIERef(const DIE &D)=0
llvm::DIBasicType
Basic type, like 'int' or 'float'.
Definition:DebugInfoMetadata.h:823
llvm::DICompileUnit
Compile unit.
Definition:DebugInfoMetadata.h:1469
llvm::DICompileUnit::getDebugInfoForProfiling
bool getDebugInfoForProfiling() const
Definition:DebugInfoMetadata.h:1601
llvm::DICompileUnit::isDebugDirectivesOnly
bool isDebugDirectivesOnly() const
Definition:DebugInfoMetadata.h:1598
llvm::DICompileUnit::getFlags
StringRef getFlags() const
Definition:DebugInfoMetadata.h:1607
llvm::DICompileUnit::DebugNameTableKind
DebugNameTableKind
Definition:DebugInfoMetadata.h:1482
llvm::DICompileUnit::DebugNameTableKind::None
@ None
llvm::DICompileUnit::DebugNameTableKind::Default
@ Default
llvm::DICompileUnit::DebugNameTableKind::Apple
@ Apple
llvm::DICompileUnit::DebugNameTableKind::GNU
@ GNU
llvm::DICompileUnit::getSDK
StringRef getSDK() const
Definition:DebugInfoMetadata.h:1631
llvm::DICompileUnit::getNameTableKind
static std::optional< DebugNameTableKind > getNameTableKind(StringRef Str)
Definition:DebugInfoMetadata.cpp:990
llvm::DICompileUnit::getRuntimeVersion
unsigned getRuntimeVersion() const
Definition:DebugInfoMetadata.h:1594
llvm::DICompileUnit::getSplitDebugInlining
bool getSplitDebugInlining() const
Definition:DebugInfoMetadata.h:1626
llvm::DICompileUnit::getSysRoot
StringRef getSysRoot() const
Definition:DebugInfoMetadata.h:1630
llvm::DICompileUnit::getProducer
StringRef getProducer() const
Definition:DebugInfoMetadata.h:1606
llvm::DICompileUnit::LineTablesOnly
@ LineTablesOnly
Definition:DebugInfoMetadata.h:1477
llvm::DICompileUnit::FullDebug
@ FullDebug
Definition:DebugInfoMetadata.h:1476
llvm::DICompileUnit::NoDebug
@ NoDebug
Definition:DebugInfoMetadata.h:1475
llvm::DICompileUnit::getSourceLanguage
unsigned getSourceLanguage() const
Definition:DebugInfoMetadata.h:1592
llvm::DICompileUnit::getDWOId
uint64_t getDWOId() const
Definition:DebugInfoMetadata.h:1624
llvm::DICompileUnit::getSplitDebugFilename
StringRef getSplitDebugFilename() const
Definition:DebugInfoMetadata.h:1608
llvm::DICompileUnit::getEmissionKind
static std::optional< DebugEmissionKind > getEmissionKind(StringRef Str)
Definition:DebugInfoMetadata.cpp:980
llvm::DICompileUnit::isOptimized
bool isOptimized() const
Definition:DebugInfoMetadata.h:1593
llvm::DICompositeType
Composite types.
Definition:DebugInfoMetadata.h:1174
llvm::DIEHash
An object containing the capability of hashing and adding hash attributes onto a DIE.
Definition:DIEHash.h:26
llvm::DIEHash::computeCUSignature
uint64_t computeCUSignature(StringRef DWOName, const DIE &Die)
Computes the CU signature.
Definition:DIEHash.cpp:399
llvm::DIEUnit::setSection
void setSection(MCSection *Section)
Set the section that this DIEUnit will be emitted into.
Definition:DIE.h:984
llvm::DIEUnit::getUnitDie
DIE & getUnitDie()
Definition:DIE.h:999
llvm::DIEValue
Definition:DIE.h:374
llvm::DIE
A structured debug information entry.
Definition:DIE.h:819
llvm::DIE::findAttribute
DIEValue findAttribute(dwarf::Attribute Attribute) const
Find a value in the DIE with the attribute given.
Definition:DIE.cpp:210
llvm::DIE::getUnitDie
const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to.
Definition:DIE.cpp:191
llvm::DIE::getTag
dwarf::Tag getTag() const
Definition:DIE.h:855
llvm::DIExpressionCursor
Holds a DIExpression and keeps track of how many operands have been consumed so far.
Definition:DebugInfoMetadata.h:3236
llvm::DIExpression
DWARF expression.
Definition:DebugInfoMetadata.h:2763
llvm::DIExpression::isEntryValue
bool isEntryValue() const
Check if the expression consists of exactly one entry value operand.
Definition:DebugInfoMetadata.cpp:1375
llvm::DIExpression::append
static DIExpression * append(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Append the opcodes Ops to DIExpr.
Definition:DebugInfoMetadata.cpp:1948
llvm::DIExpression::getNumElements
unsigned getNumElements() const
Definition:DebugInfoMetadata.h:2789
llvm::DIExpression::isImplicit
bool isImplicit() const
Return whether this is an implicit location description.
Definition:DebugInfoMetadata.cpp:1521
llvm::DIExpression::getFragmentInfo
static std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
Definition:DebugInfoMetadata.cpp:1677
llvm::DIExpression::convertToNonVariadicExpression
static std::optional< const DIExpression * > convertToNonVariadicExpression(const DIExpression *Expr)
If Expr is a valid single-location expression, i.e.
Definition:DebugInfoMetadata.cpp:1624
llvm::DIExpression::getElements
ArrayRef< uint64_t > getElements() const
Definition:DebugInfoMetadata.h:2787
llvm::DIExpression::isValid
bool isValid() const
Definition:DebugInfoMetadata.cpp:1429
llvm::DIFile
File.
Definition:DebugInfoMetadata.h:573
llvm::DIFile::CSK_MD5
@ CSK_MD5
Definition:DebugInfoMetadata.h:587
llvm::DIGlobalVariable
Global variables.
Definition:DebugInfoMetadata.h:3315
llvm::DILabel
Label.
Definition:DebugInfoMetadata.h:3551
llvm::DILocalScope
A scope for locals.
Definition:DebugInfoMetadata.h:1675
llvm::DILocalVariable
Local variable.
Definition:DebugInfoMetadata.h:3460
llvm::DILocation
Debug location.
Definition:DebugInfoMetadata.h:1988
llvm::DIMacroFile
Macro file.
Definition:DebugInfoMetadata.h:3910
llvm::DIMacroFile::getFile
DIFile * getFile() const
Definition:DebugInfoMetadata.h:3960
llvm::DIMacroFile::getLine
unsigned getLine() const
Definition:DebugInfoMetadata.h:3959
llvm::DIMacroFile::getElements
DIMacroNodeArray getElements() const
Definition:DebugInfoMetadata.h:3962
llvm::DIMacro
Macro.
Definition:DebugInfoMetadata.h:3856
llvm::DINode
Tagged DWARF-like metadata node.
Definition:DebugInfoMetadata.h:135
llvm::DIScope
Base class for scope-like contexts.
Definition:DebugInfoMetadata.h:519
llvm::DIScope::getFilename
StringRef getFilename() const
Definition:DebugInfoMetadata.h:685
llvm::DIScope::getName
StringRef getName() const
Definition:DebugInfoMetadata.cpp:368
llvm::DIScope::getFile
DIFile * getFile() const
Definition:DebugInfoMetadata.h:527
llvm::DIScope::getDirectory
StringRef getDirectory() const
Definition:DebugInfoMetadata.h:691
llvm::DIScope::getSource
std::optional< StringRef > getSource() const
Definition:DebugInfoMetadata.h:697
llvm::DIScope::getScope
DIScope * getScope() const
Definition:DebugInfoMetadata.cpp:344
llvm::DISubprogram
Subprogram description.
Definition:DebugInfoMetadata.h:1710
llvm::DIType
Base class for types.
Definition:DebugInfoMetadata.h:710
llvm::DIType::getScope
DIScope * getScope() const
Definition:DebugInfoMetadata.h:762
llvm::DIVariable::getType
DIType * getType() const
Definition:DebugInfoMetadata.h:2711
llvm::DWARF5AccelTable
Definition:AccelTable.h:400
llvm::DWARF5AccelTable::addTypeUnitSignature
void addTypeUnitSignature(DwarfTypeUnit &U)
Add a type unit Signature.
Definition:AccelTable.cpp:706
llvm::DWARF5AccelTable::convertDieToOffset
void convertDieToOffset()
Convert DIE entries to explicit offset.
Definition:AccelTable.h:417
llvm::DWARF5AccelTable::addTypeUnitSymbol
void addTypeUnitSymbol(DwarfTypeUnit &U)
Add a type unit start symbol.
Definition:AccelTable.cpp:702
llvm::DWARF5AccelTable::addTypeEntries
void addTypeEntries(DWARF5AccelTable &Table)
Definition:AccelTable.h:429
llvm::DWARFDataExtractor
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
Definition:DWARFDataExtractor.h:21
llvm::DWARFExpression::Operation
This class represents an Operation in the Expression.
Definition:DWARFExpression.h:32
llvm::DWARFExpression::Operation::getSubCode
std::optional< unsigned > getSubCode() const
Definition:DWARFExpression.cpp:296
llvm::DWARFExpression::Operation::getCode
uint8_t getCode() const
Definition:DWARFExpression.h:88
llvm::DWARFExpression::Operation::getEndOffset
uint64_t getEndOffset() const
Definition:DWARFExpression.h:99
llvm::DWARFExpression::Operation::Encoding
Encoding
Size and signedness of expression operations' operands.
Definition:DWARFExpression.h:35
llvm::DWARFExpression::Operation::getDescription
const Description & getDescription() const
Definition:DWARFExpression.h:87
llvm::DWARFExpression::Operation::getOperandEndOffset
uint64_t getOperandEndOffset(unsigned Idx) const
Definition:DWARFExpression.h:96
llvm::DWARFExpression::Operation::getRawOperand
uint64_t getRawOperand(unsigned Idx) const
Definition:DWARFExpression.h:92
llvm::DWARFExpression
Definition:DWARFExpression.h:23
llvm::DataLayout::isLittleEndian
bool isLittleEndian() const
Layout endianness...
Definition:DataLayout.h:197
llvm::DbgCallSiteParam
Used for tracking debug info about call site parameters.
Definition:DwarfDebug.h:316
llvm::DbgEntity
This class is defined as the common parent of DbgVariable and DbgLabel such that it could levarage po...
Definition:DwarfDebug.h:65
llvm::DbgValueHistoryMap::hasNonEmptyLocation
bool hasNonEmptyLocation(const Entries &Entries) const
Test whether a vector of entries features any non-empty locations.
Definition:DbgEntityHistoryCalculator.cpp:266
llvm::DbgValueLocEntry
A single location or constant within a variable location description, with either a single entry (wit...
Definition:DebugLocEntry.h:40
llvm::DbgValueLoc
The location of a single variable, composed of an expression and 0 or more DbgValueLocEntries.
Definition:DebugLocEntry.h:111
llvm::DbgVariable
This class is used to track local variable information.
Definition:DwarfDebug.h:214
llvm::DbgVariable::getVariable
const DILocalVariable * getVariable() const
Definition:DwarfDebug.h:246
llvm::DbgVariable::getType
const DIType * getType() const
Definition:DwarfDebug.cpp:230
llvm::DebugHandlerBase
Base class for debug information backends.
Definition:DebugHandlerBase.h:53
llvm::DebugHandlerBase::CurMI
const MachineInstr * CurMI
If nonnull, stores the current machine instruction we're processing.
Definition:DebugHandlerBase.h:79
llvm::DebugHandlerBase::Asm
AsmPrinter * Asm
Target of debug info emission.
Definition:DebugHandlerBase.h:58
llvm::DebugHandlerBase::getLabelBeforeInsn
MCSymbol * getLabelBeforeInsn(const MachineInstr *MI)
Return Label preceding the instruction.
Definition:DebugHandlerBase.cpp:137
llvm::DebugHandlerBase::MMI
MachineModuleInfo * MMI
Collected machine module information.
Definition:DebugHandlerBase.h:61
llvm::DebugHandlerBase::PrevLabel
MCSymbol * PrevLabel
Definition:DebugHandlerBase.h:68
llvm::DebugHandlerBase::PrevInstLoc
DebugLoc PrevInstLoc
Previous instruction's location information.
Definition:DebugHandlerBase.h:67
llvm::DebugHandlerBase::getLabelAfterInsn
MCSymbol * getLabelAfterInsn(const MachineInstr *MI)
Return Label immediately following the instruction.
Definition:DebugHandlerBase.cpp:144
llvm::DebugHandlerBase::beginInstruction
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
Definition:DebugHandlerBase.cpp:353
llvm::DebugHandlerBase::PrevInstBB
const MachineBasicBlock * PrevInstBB
Definition:DebugHandlerBase.h:69
llvm::DebugHandlerBase::requestLabelAfterInsn
void requestLabelAfterInsn(const MachineInstr *MI)
Ensure that a label will be emitted after MI.
Definition:DebugHandlerBase.h:108
llvm::DebugHandlerBase::DbgValues
DbgValueHistoryMap DbgValues
History of DBG_VALUE and clobber instructions for each user variable.
Definition:DebugHandlerBase.h:85
llvm::DebugHandlerBase::DbgLabels
DbgLabelInstrMap DbgLabels
Mapping of inlined labels and DBG_LABEL machine instruction.
Definition:DebugHandlerBase.h:88
llvm::DebugHandlerBase::beginModule
void beginModule(Module *M) override
Definition:DebugHandlerBase.cpp:105
llvm::DebugHandlerBase::getInstOrdering
const InstructionOrdering & getInstOrdering() const
Definition:DebugHandlerBase.h:146
llvm::DebugHandlerBase::requestLabelBeforeInsn
void requestLabelBeforeInsn(const MachineInstr *MI)
Ensure that a label will be emitted before MI.
Definition:DebugHandlerBase.h:103
llvm::DebugHandlerBase::EpilogBeginBlock
const MachineBasicBlock * EpilogBeginBlock
This block includes epilogue instructions.
Definition:DebugHandlerBase.h:76
llvm::DebugHandlerBase::LScopes
LexicalScopes LScopes
Definition:DebugHandlerBase.h:81
llvm::DebugHandlerBase::PrologEndLoc
const MachineInstr * PrologEndLoc
This location indicates end of function prologue and beginning of function body.
Definition:DebugHandlerBase.h:73
llvm::DebugLocDwarfExpression
DwarfExpression implementation for .debug_loc entries.
Definition:DwarfExpression.h:306
llvm::DebugLocEntry::finalize
void finalize(const AsmPrinter &AP, DebugLocStream::ListBuilder &List, const DIBasicType *BT, DwarfCompileUnit &TheCU)
Lower this entry into a DWARF expression.
Definition:DwarfDebug.cpp:2991
llvm::DebugLocStream::EntryBuilder
Builder for DebugLocStream entries.
Definition:DebugLocStream.h:181
llvm::DebugLocStream::ListBuilder
Builder for DebugLocStream lists.
Definition:DebugLocStream.h:154
llvm::DebugLocStream::getComments
ArrayRef< std::string > getComments(const Entry &E) const
Definition:DebugLocStream.h:119
llvm::DebugLocStream::getEntries
ArrayRef< Entry > getEntries(const List &L) const
Definition:DebugLocStream.h:109
llvm::DebugLocStream::getBytes
ArrayRef< char > getBytes(const Entry &E) const
Definition:DebugLocStream.h:114
llvm::DebugLocStream::getSym
MCSymbol * getSym() const
Definition:DebugLocStream.h:62
llvm::DebugLocStream::setSym
void setSym(MCSymbol *Sym)
Definition:DebugLocStream.h:65
llvm::DebugLocStream::getLists
ArrayRef< List > getLists() const
Definition:DebugLocStream.h:61
llvm::DebugLoc
A debug info location.
Definition:DebugLoc.h:33
llvm::DebugLoc::getLine
unsigned getLine() const
Definition:DebugLoc.cpp:24
llvm::DebugLoc::getScope
MDNode * getScope() const
Definition:DebugLoc.cpp:34
llvm::DebugLoc::getCol
unsigned getCol() const
Definition:DebugLoc.cpp:29
llvm::DenseMapBase::lookup
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition:DenseMap.h:194
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition:DenseMap.h:156
llvm::DenseMapBase::erase
bool erase(const KeyT &Val)
Definition:DenseMap.h:321
llvm::DenseMapBase::end
iterator end()
Definition:DenseMap.h:84
llvm::DenseMapBase::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition:DenseMap.h:211
llvm::DenseMap
Definition:DenseMap.h:727
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition:DenseSet.h:278
llvm::DwarfCompileUnit
Definition:DwarfCompileUnit.h:45
llvm::DwarfCompileUnit::constructAbstractSubprogramScopeDIE
void constructAbstractSubprogramScopeDIE(LexicalScope *Scope)
Definition:DwarfCompileUnit.cpp:1188
llvm::DwarfCompileUnit::addRange
void addRange(RangeSpan Range)
addRange - Add an address range to the list of ranges for this unit.
Definition:DwarfCompileUnit.cpp:420
llvm::DwarfCompileUnit::initStmtList
void initStmtList()
Definition:DwarfCompileUnit.cpp:443
llvm::DwarfCompileUnit::getLength
unsigned getLength()
Definition:DwarfCompileUnit.h:318
llvm::DwarfCompileUnit::createAbstractEntity
void createAbstractEntity(const DINode *Node, LexicalScope *Scope)
Definition:DwarfCompileUnit.cpp:1492
llvm::DwarfCompileUnit::constructSubprogramScopeDIE
DIE & constructSubprogramScopeDIE(const DISubprogram *Sub, LexicalScope *Scope, MCSymbol *LineTableSym)
Construct a DIE for this subprogram scope.
Definition:DwarfCompileUnit.cpp:1111
llvm::DwarfCompileUnit::getSkeleton
DwarfCompileUnit * getSkeleton() const
Definition:DwarfCompileUnit.h:149
llvm::DwarfCompileUnit::setSkeleton
void setSkeleton(DwarfCompileUnit &Skel)
Set the skeleton unit associated with this unit.
Definition:DwarfCompileUnit.h:309
llvm::DwarfCompileUnit::getGlobalNames
const StringMap< const DIE * > & getGlobalNames() const
Definition:DwarfCompileUnit.h:346
llvm::DwarfCompileUnit::getExistingAbstractEntity
DbgEntity * getExistingAbstractEntity(const DINode *Node)
Definition:DwarfCompileUnit.cpp:1484
llvm::DwarfCompileUnit::getGlobalTypes
const StringMap< const DIE * > & getGlobalTypes() const
Definition:DwarfCompileUnit.h:347
llvm::DwarfCompileUnit::hasDwarfPubSections
bool hasDwarfPubSections() const
Definition:DwarfCompileUnit.cpp:1522
llvm::DwarfDebug
Collects and handles dwarf debug information.
Definition:DwarfDebug.h:351
llvm::DwarfDebug::useSegmentedStringOffsetsTable
bool useSegmentedStringOffsetsTable() const
Returns whether to generate a string offsets table with (possibly shared) contributions from each CU ...
Definition:DwarfDebug.h:823
llvm::DwarfDebug::DWARF5AccelTableKind::CU
@ CU
llvm::DwarfDebug::DWARF5AccelTableKind::TU
@ TU
llvm::DwarfDebug::getMD5AsBytes
std::optional< MD5::MD5Result > getMD5AsBytes(const DIFile *File) const
If the File has an MD5 checksum, return it as an MD5Result allocated in the MCContext.
Definition:DwarfDebug.cpp:3919
llvm::DwarfDebug::emitDebugEntryValues
bool emitDebugEntryValues() const
Definition:DwarfDebug.h:827
llvm::DwarfDebug::getDwarfVersion
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
Definition:DwarfDebug.cpp:3895
llvm::DwarfDebug::emitDebugLocEntry
void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
Emit an entry for the debug loc section.
Definition:DwarfDebug.cpp:2852
llvm::DwarfDebug::addAccelNamespace
void addAccelNamespace(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
Definition:DwarfDebug.cpp:3881
llvm::DwarfDebug::setCurrentDWARF5AccelTable
void setCurrentDWARF5AccelTable(const DWARF5AccelTableKind Kind)
Sets the current DWARF5AccelTable to use.
Definition:DwarfDebug.h:936
llvm::DwarfDebug::alwaysUseRanges
bool alwaysUseRanges(const DwarfCompileUnit &) const
Returns whether range encodings should be used for single entry range lists.
Definition:DwarfDebug.cpp:3936
llvm::DwarfDebug::beginModule
void beginModule(Module *M) override
Emit all Dwarf sections that should come prior to the content.
Definition:DwarfDebug.cpp:1145
llvm::DwarfDebug::addSubprogramNames
void addSubprogramNames(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, const DISubprogram *SP, DIE &Die)
Definition:DwarfDebug.cpp:477
llvm::DwarfDebug::useAllLinkageNames
bool useAllLinkageNames() const
Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
Definition:DwarfDebug.h:761
llvm::DwarfDebug::insertSectionLabel
void insertSectionLabel(const MCSymbol *S)
Definition:DwarfDebug.cpp:3912
llvm::DwarfDebug::addAccelObjC
void addAccelObjC(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
Definition:DwarfDebug.cpp:3872
llvm::DwarfDebug::getDwarfSectionOffsetForm
dwarf::Form getDwarfSectionOffsetForm() const
Returns a suitable DWARF form to represent a section offset, i.e.
Definition:DwarfDebug.cpp:3899
llvm::DwarfDebug::useAppleExtensionAttributes
bool useAppleExtensionAttributes() const
Definition:DwarfDebug.h:809
llvm::DwarfDebug::MinimizeAddrInV5::Default
@ Default
llvm::DwarfDebug::MinimizeAddrInV5::Ranges
@ Ranges
llvm::DwarfDebug::skippedNonDebugFunction
void skippedNonDebugFunction() override
Definition:DwarfDebug.cpp:2513
llvm::DwarfDebug::addArangeLabel
void addArangeLabel(SymbolCU SCU)
Add a label so that arange data can be generated for it.
Definition:DwarfDebug.h:751
llvm::DwarfDebug::beginInstruction
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
Definition:DwarfDebug.cpp:2000
llvm::DwarfDebug::getAddressPool
AddressPool & getAddressPool()
Definition:DwarfDebug.h:870
llvm::DwarfDebug::getCurrentDWARF5AccelTable
DWARF5AccelTable & getCurrentDWARF5AccelTable()
Returns either CU or TU DWARF5AccelTable.
Definition:DwarfDebug.h:946
llvm::DwarfDebug::useSectionsAsReferences
bool useSectionsAsReferences() const
Returns whether to use sections as labels rather than temp symbols.
Definition:DwarfDebug.h:794
llvm::DwarfDebug::getDebugLocs
const DebugLocStream & getDebugLocs() const
Returns the entries for the .debug_loc section.
Definition:DwarfDebug.h:854
llvm::DwarfDebug::shareAcrossDWOCUs
bool shareAcrossDWOCUs() const
Definition:DwarfDebug.cpp:538
llvm::DwarfDebug::terminateLineTable
void terminateLineTable(const DwarfCompileUnit *CU)
Terminate the line table by adding the last range label.
Definition:DwarfDebug.cpp:2504
llvm::DwarfDebug::~DwarfDebug
~DwarfDebug() override
llvm::DwarfDebug::endFunctionImpl
void endFunctionImpl(const MachineFunction *MF) override
Gather and emit post-function debug information.
Definition:DwarfDebug.cpp:2525
llvm::DwarfDebug::emitDebugLocEntryLocation
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
Emit the location for a debug loc entry, including the size header.
Definition:DwarfDebug.cpp:3021
llvm::DwarfDebug::getSectionLabel
const MCSymbol * getSectionLabel(const MCSection *S)
Definition:DwarfDebug.cpp:3908
llvm::DwarfDebug::emitDebugLocValue
static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, const DbgValueLoc &Value, DwarfExpression &DwarfExpr)
Definition:DwarfDebug.cpp:2896
llvm::DwarfDebug::useSplitDwarf
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support.
Definition:DwarfDebug.h:815
llvm::DwarfDebug::getDwarfCompileUnitIDForLineTable
unsigned getDwarfCompileUnitIDForLineTable(const DwarfCompileUnit &CU)
Get Dwarf compile unit ID for line table.
Definition:DwarfDebug.cpp:2493
llvm::DwarfDebug::emitInitialLocDirective
const MachineInstr * emitInitialLocDirective(const MachineFunction &MF, unsigned CUID)
Emits inital debug location directive.
Definition:DwarfDebug.cpp:2293
llvm::DwarfDebug::useRangesSection
bool useRangesSection() const
Returns whether ranges section should be emitted.
Definition:DwarfDebug.h:775
llvm::DwarfDebug::addAccelName
void addAccelName(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
Definition:DwarfDebug.cpp:3865
llvm::DwarfDebug::isLexicalScopeDIENull
bool isLexicalScopeDIENull(LexicalScope *Scope)
A helper function to check whether the DIE for a given Scope is going to be null.
Definition:DwarfDebug.cpp:514
llvm::DwarfDebug::addDwarfTypeUnitType
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, DIE &Die, const DICompositeType *CTy)
Add a DIE to the set of types that we're going to pull into type units.
Definition:DwarfDebug.cpp:3707
llvm::DwarfDebug::endModule
void endModule() override
Emit all Dwarf sections that should come after the content.
Definition:DwarfDebug.cpp:1405
llvm::DwarfDebug::addAccelType
void addAccelType(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die, char Flags)
Definition:DwarfDebug.cpp:3888
llvm::DwarfDebug::beginCodeAlignment
void beginCodeAlignment(const MachineBasicBlock &MBB) override
Process beginning of code alignment.
Definition:DwarfDebug.cpp:3946
llvm::DwarfDebug::DwarfDebug
DwarfDebug(AsmPrinter *A)
Definition:DwarfDebug.cpp:330
llvm::DwarfDebug::beginFunctionImpl
void beginFunctionImpl(const MachineFunction *MF) override
Gather pre-function debug information.
Definition:DwarfDebug.cpp:2469
llvm::DwarfDebug::getAccelTableKind
AccelTableKind getAccelTableKind() const
Returns what kind (if any) of accelerator tables to emit.
Definition:DwarfDebug.h:804
llvm::DwarfDebug::makeTypeSignature
static uint64_t makeTypeSignature(StringRef Identifier)
Perform an MD5 checksum of Identifier and return the lower 64 bits.
Definition:DwarfDebug.cpp:3696
llvm::DwarfExpression
Base class containing the logic for constructing DWARF expressions independently of whether they are ...
Definition:DwarfExpression.h:44
llvm::DwarfExpression::setLocation
void setLocation(const MachineLocation &Loc, const DIExpression *DIExpr)
Set the location (Loc) and DIExpression (DIExpr) to describe.
Definition:DwarfExpression.cpp:404
llvm::DwarfExpression::finalize
void finalize()
This needs to be called last to commit any pending changes.
Definition:DwarfExpression.cpp:711
llvm::DwarfExpression::addFragmentOffset
void addFragmentOffset(const DIExpression *Expr)
If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to the fragment described by Ex...
Definition:DwarfExpression.cpp:722
llvm::DwarfExpression::setMemoryLocationKind
void setMemoryLocationKind()
Lock this down to become a memory location description.
Definition:DwarfExpression.h:245
llvm::DwarfExpression::TagOffset
std::optional< uint8_t > TagOffset
Definition:DwarfExpression.h:111
llvm::DwarfExpression::addConstantFP
void addConstantFP(const APFloat &Value, const AsmPrinter &AP)
Emit an floating point constant.
Definition:DwarfExpression.cpp:230
llvm::DwarfExpression::addMachineRegExpression
bool addMachineRegExpression(const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, llvm::Register MachineReg, unsigned FragmentOffsetInBits=0)
Emit a machine register location.
Definition:DwarfExpression.cpp:257
llvm::DwarfExpression::addUnsignedConstant
void addUnsignedConstant(uint64_t Value)
Emit an unsigned constant.
Definition:DwarfExpression.cpp:204
llvm::DwarfExpression::addExpression
void addExpression(DIExpressionCursor &&Expr)
Emit all remaining operations in the DIExpressionCursor.
Definition:DwarfExpression.cpp:491
llvm::DwarfExpression::addSignedConstant
void addSignedConstant(int64_t Value)
Emit a signed constant.
Definition:DwarfExpression.cpp:197
llvm::DwarfExpression::addWasmLocation
void addWasmLocation(unsigned Index, uint64_t Offset)
Emit location information expressed via WebAssembly location + offset The Index is an identifier for ...
Definition:DwarfExpression.cpp:772
llvm::DwarfExpression::beginEntryValueExpression
void beginEntryValueExpression(DIExpressionCursor &ExprCursor)
Begin emission of an entry value dwarf operation.
Definition:DwarfExpression.cpp:413
llvm::DwarfFile
Definition:DwarfFile.h:54
llvm::DwarfFile::addScopeLabel
void addScopeLabel(LexicalScope *LS, DbgLabel *Label)
Definition:DwarfFile.cpp:117
llvm::DwarfFile::addUnit
void addUnit(std::unique_ptr< DwarfCompileUnit > U)
Add a unit to the list of CUs.
Definition:DwarfFile.cpp:23
llvm::DwarfFile::computeSizeAndOffsets
void computeSizeAndOffsets()
Compute the size and offset of all the DIEs.
Definition:DwarfFile.cpp:57
llvm::DwarfFile::setRnglistsTableBaseSym
void setRnglistsTableBaseSym(MCSymbol *Sym)
Definition:DwarfFile.h:155
llvm::DwarfFile::getScopeVariables
DenseMap< LexicalScope *, ScopeVars > & getScopeVariables()
Definition:DwarfFile.h:161
llvm::DwarfFile::computeSizeAndOffsetsForUnit
unsigned computeSizeAndOffsetsForUnit(DwarfUnit *TheU)
Compute the size and offset of all the DIEs in the given unit.
Definition:DwarfFile.cpp:80
llvm::DwarfFile::emitUnits
void emitUnits(bool UseOffsets)
Emit all of the units to the section listed with the given abbreviation section.
Definition:DwarfFile.cpp:29
llvm::DwarfFile::emitUnit
void emitUnit(DwarfUnit *TheU, bool UseOffsets)
Emit the given unit to its section.
Definition:DwarfFile.cpp:34
llvm::DwarfFile::getRangeLists
const SmallVectorImpl< RangeSpanList > & getRangeLists() const
getRangeLists - Get the vector of range lists.
Definition:DwarfFile.h:114
llvm::DwarfFile::getStringOffsetsStartSym
MCSymbol * getStringOffsetsStartSym() const
Definition:DwarfFile.h:151
llvm::DwarfFile::getRnglistsTableBaseSym
MCSymbol * getRnglistsTableBaseSym() const
Definition:DwarfFile.h:154
llvm::DwarfFile::getStringPool
DwarfStringPool & getStringPool()
Returns the string pool.
Definition:DwarfFile.h:149
llvm::DwarfFile::emitAbbrevs
void emitAbbrevs(MCSection *)
Emit a set of abbreviations to the specific section.
Definition:DwarfFile.cpp:97
llvm::DwarfFile::emitStrings
void emitStrings(MCSection *StrSection, MCSection *OffsetSection=nullptr, bool UseRelativeOffsets=false)
Emit all of the strings to the section given.
Definition:DwarfFile.cpp:100
llvm::DwarfFile::getScopeLabels
DenseMap< LexicalScope *, LabelList > & getScopeLabels()
Definition:DwarfFile.h:165
llvm::DwarfFile::addScopeVariable
void addScopeVariable(LexicalScope *LS, DbgVariable *Var)
Definition:DwarfFile.cpp:105
llvm::DwarfFile::getAbstractScopeDIEs
DenseMap< const DILocalScope *, DIE * > & getAbstractScopeDIEs()
Definition:DwarfFile.h:169
llvm::DwarfFile::getUnits
const SmallVectorImpl< std::unique_ptr< DwarfCompileUnit > > & getUnits()
Definition:DwarfFile.h:106
llvm::DwarfStringPoolEntryRef
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
Definition:DwarfStringPoolEntry.h:49
llvm::DwarfStringPoolEntryRef::getIndex
unsigned getIndex() const
Definition:DwarfStringPoolEntry.h:84
llvm::DwarfStringPoolEntryRef::getSymbol
MCSymbol * getSymbol() const
Definition:DwarfStringPoolEntry.h:75
llvm::DwarfStringPool::getEntry
EntryRef getEntry(AsmPrinter &Asm, StringRef Str)
Get a reference to an entry in the string pool.
Definition:DwarfStringPool.cpp:39
llvm::DwarfStringPool::getIndexedEntry
EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str)
Same as getEntry, except that you can use EntryRef::getIndex to obtain a unique ID of this entry (e....
Definition:DwarfStringPool.cpp:45
llvm::DwarfStringPool::emitStringOffsetsTableHeader
void emitStringOffsetsTableHeader(AsmPrinter &Asm, MCSection *OffsetSection, MCSymbol *StartSym)
Definition:DwarfStringPool.cpp:53
llvm::DwarfTypeUnit
Definition:DwarfUnit.h:375
llvm::DwarfTypeUnit::setTypeSignature
void setTypeSignature(uint64_t Signature)
Definition:DwarfUnit.h:391
llvm::DwarfTypeUnit::setType
void setType(const DIE *Ty)
Definition:DwarfUnit.h:394
llvm::DwarfUnit
This dwarf writer support class manages information associated with a source file.
Definition:DwarfUnit.h:35
llvm::DwarfUnit::addStringOffsetsStart
void addStringOffsetsStart()
Add the DW_AT_str_offsets_base attribute to the unit DIE.
Definition:DwarfUnit.cpp:1912
llvm::DwarfUnit::addUInt
void addUInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, uint64_t Integer)
Add an unsigned integer attribute data and value.
Definition:DwarfUnit.cpp:221
llvm::DwarfUnit::addString
void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str)
Add a string attribute data and value.
Definition:DwarfUnit.cpp:247
llvm::DwarfUnit::createTypeDIE
DIE * createTypeDIE(const DIScope *Context, DIE &ContextDIE, const DIType *Ty)
Creates type DIE with specific context.
Definition:DwarfUnit.cpp:576
llvm::DwarfUnit::getCUNode
const DICompileUnit * getCUNode() const
Definition:DwarfUnit.h:111
llvm::DwarfUnit::addFlag
void addFlag(DIE &Die, dwarf::Attribute Attribute)
Add a flag that is true to the DIE.
Definition:DwarfUnit.cpp:214
llvm::DwarfUnit::getUniqueID
unsigned getUniqueID() const
Gets Unique ID for this unit.
Definition:DwarfUnit.h:101
llvm::Function
Definition:Function.h:63
llvm::Function::getSubprogram
DISubprogram * getSubprogram() const
Get the attached subprogram.
Definition:Metadata.cpp:1874
llvm::Function::getContext
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition:Function.cpp:369
llvm::GlobalVariable
Definition:GlobalVariable.h:39
llvm::HexagonInstrInfo::analyzeBranch
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e....
Definition:HexagonInstrInfo.cpp:434
llvm::HexagonInstrInfo::isTailCall
bool isTailCall(const MachineInstr &MI) const override
Definition:HexagonInstrInfo.cpp:2658
llvm::InstructionOrdering
Record instruction ordering so we can query their relative positions within a function.
Definition:DbgEntityHistoryCalculator.h:30
llvm::LexicalScope
LexicalScope - This class is used to track scope information.
Definition:LexicalScopes.h:44
llvm::LexicalScope::getRanges
SmallVectorImpl< InsnRange > & getRanges()
Definition:LexicalScopes.h:66
llvm::LexicalScope::getScopeNode
const DILocalScope * getScopeNode() const
Definition:LexicalScopes.h:63
llvm::LexicalScopes
LexicalScopes - This class provides interface to collect and use lexical scoping information from mac...
Definition:LexicalScopes.h:141
llvm::LexicalScopes::getOrCreateAbstractScope
LexicalScope * getOrCreateAbstractScope(const DILocalScope *Scope)
getOrCreateAbstractScope - Find or create an abstract lexical scope.
Definition:LexicalScopes.cpp:212
llvm::LexicalScopes::findLexicalScope
LexicalScope * findLexicalScope(const DILocation *DL)
findLexicalScope - Find lexical scope, either regular or inlined, for the given DebugLoc.
Definition:LexicalScopes.cpp:124
llvm::LexicalScopes::getAbstractScopesList
ArrayRef< LexicalScope * > getAbstractScopesList() const
getAbstractScopesList - Return a reference to list of abstract scopes.
Definition:LexicalScopes.h:175
llvm::LexicalScopes::findInlinedScope
LexicalScope * findInlinedScope(const DILocalScope *N, const DILocation *IA)
findInlinedScope - Find an inlined scope for the given scope/inlined-at.
Definition:LexicalScopes.h:186
llvm::LexicalScopes::findAbstractScope
LexicalScope * findAbstractScope(const DILocalScope *N)
findAbstractScope - Find an abstract scope or return null.
Definition:LexicalScopes.h:180
llvm::LexicalScopes::empty
bool empty()
empty - Return true if there is any lexical scope information available.
Definition:LexicalScopes.h:153
llvm::LexicalScopes::getCurrentFunctionScope
LexicalScope * getCurrentFunctionScope() const
getCurrentFunctionScope - Return lexical scope for the current function.
Definition:LexicalScopes.h:156
llvm::Loc::Single
Single value location description.
Definition:DwarfDebug.h:131
llvm::Loc::Single::Single
Single(DbgValueLoc ValueLoc)
Definition:DwarfDebug.cpp:282
llvm::MCAsmInfo::getCodePointerSize
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
Definition:MCAsmInfo.h:449
llvm::MCContext::getDwarfVersion
uint16_t getDwarfVersion() const
Definition:MCContext.h:802
llvm::MCContext::getDwarfFormat
dwarf::DwarfFormat getDwarfFormat() const
Definition:MCContext.h:799
llvm::MCDwarfDwoLineTable
Definition:MCDwarf.h:338
llvm::MCDwarfDwoLineTable::maybeSetRootFile
void maybeSetRootFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, std::optional< StringRef > Source)
Definition:MCDwarf.h:343
llvm::MCDwarfDwoLineTable::Emit
void Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params, MCSection *Section) const
Definition:MCDwarf.cpp:313
llvm::MCDwarfLineEntry::make
static void make(MCStreamer *MCOS, MCSection *Section)
Definition:MCDwarf.cpp:91
llvm::MCObjectFileInfo::getDwarfLoclistsSection
MCSection * getDwarfLoclistsSection() const
Definition:MCObjectFileInfo.h:302
llvm::MCObjectFileInfo::getDwarfAccelTypesSection
MCSection * getDwarfAccelTypesSection() const
Definition:MCObjectFileInfo.h:316
llvm::MCObjectFileInfo::getDwarfGnuPubNamesSection
MCSection * getDwarfGnuPubNamesSection() const
Definition:MCObjectFileInfo.h:288
llvm::MCObjectFileInfo::getDwarfStrOffDWOSection
MCSection * getDwarfStrOffDWOSection() const
Definition:MCObjectFileInfo.h:328
llvm::MCObjectFileInfo::getDwarfRangesSection
MCSection * getDwarfRangesSection() const
Definition:MCObjectFileInfo.h:300
llvm::MCObjectFileInfo::getDwarfAccelNamespaceSection
MCSection * getDwarfAccelNamespaceSection() const
Definition:MCObjectFileInfo.h:313
llvm::MCObjectFileInfo::getDwarfLineDWOSection
MCSection * getDwarfLineDWOSection() const
Definition:MCObjectFileInfo.h:326
llvm::MCObjectFileInfo::getDwarfStrOffSection
MCSection * getDwarfStrOffSection() const
Definition:MCObjectFileInfo.h:329
llvm::MCObjectFileInfo::getDwarfInfoDWOSection
MCSection * getDwarfInfoDWOSection() const
Definition:MCObjectFileInfo.h:319
llvm::MCObjectFileInfo::getDwarfTypesDWOSection
MCSection * getDwarfTypesDWOSection() const
Definition:MCObjectFileInfo.h:323
llvm::MCObjectFileInfo::getDwarfPubNamesSection
MCSection * getDwarfPubNamesSection() const
Definition:MCObjectFileInfo.h:286
llvm::MCObjectFileInfo::getDwarfMacroSection
MCSection * getDwarfMacroSection() const
Definition:MCObjectFileInfo.h:304
llvm::MCObjectFileInfo::getDwarfStrSection
MCSection * getDwarfStrSection() const
Definition:MCObjectFileInfo.h:297
llvm::MCObjectFileInfo::getDwarfLoclistsDWOSection
MCSection * getDwarfLoclistsDWOSection() const
Definition:MCObjectFileInfo.h:334
llvm::MCObjectFileInfo::getDwarfMacinfoDWOSection
MCSection * getDwarfMacinfoDWOSection() const
Definition:MCObjectFileInfo.h:338
llvm::MCObjectFileInfo::getDwarfRnglistsSection
MCSection * getDwarfRnglistsSection() const
Definition:MCObjectFileInfo.h:301
llvm::MCObjectFileInfo::getDwarfAddrSection
MCSection * getDwarfAddrSection() const
Definition:MCObjectFileInfo.h:330
llvm::MCObjectFileInfo::getDwarfInfoSection
MCSection * getDwarfInfoSection() const
Definition:MCObjectFileInfo.h:279
llvm::MCObjectFileInfo::getDwarfPubTypesSection
MCSection * getDwarfPubTypesSection() const
Definition:MCObjectFileInfo.h:287
llvm::MCObjectFileInfo::getDwarfTypesSection
MCSection * getDwarfTypesSection(uint64_t Hash) const
Definition:MCObjectFileInfo.h:320
llvm::MCObjectFileInfo::getDwarfGnuPubTypesSection
MCSection * getDwarfGnuPubTypesSection() const
Definition:MCObjectFileInfo.h:291
llvm::MCObjectFileInfo::getDwarfStrDWOSection
MCSection * getDwarfStrDWOSection() const
Definition:MCObjectFileInfo.h:325
llvm::MCObjectFileInfo::getDwarfAccelNamesSection
MCSection * getDwarfAccelNamesSection() const
Definition:MCObjectFileInfo.h:309
llvm::MCObjectFileInfo::getDwarfAbbrevDWOSection
MCSection * getDwarfAbbrevDWOSection() const
Definition:MCObjectFileInfo.h:324
llvm::MCObjectFileInfo::getDwarfRnglistsDWOSection
MCSection * getDwarfRnglistsDWOSection() const
Definition:MCObjectFileInfo.h:331
llvm::MCObjectFileInfo::getDwarfAbbrevSection
MCSection * getDwarfAbbrevSection() const
Definition:MCObjectFileInfo.h:278
llvm::MCObjectFileInfo::getDwarfMacinfoSection
MCSection * getDwarfMacinfoSection() const
Definition:MCObjectFileInfo.h:303
llvm::MCObjectFileInfo::getDwarfLocDWOSection
MCSection * getDwarfLocDWOSection() const
Definition:MCObjectFileInfo.h:327
llvm::MCObjectFileInfo::getDwarfARangesSection
MCSection * getDwarfARangesSection() const
Definition:MCObjectFileInfo.h:299
llvm::MCObjectFileInfo::getDwarfAccelObjCSection
MCSection * getDwarfAccelObjCSection() const
Definition:MCObjectFileInfo.h:312
llvm::MCObjectFileInfo::getDwarfLocSection
MCSection * getDwarfLocSection() const
Definition:MCObjectFileInfo.h:298
llvm::MCObjectFileInfo::getDwarfMacroDWOSection
MCSection * getDwarfMacroDWOSection() const
Definition:MCObjectFileInfo.h:337
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition:MCSection.h:36
llvm::MCSection::getBeginSymbol
MCSymbol * getBeginSymbol()
Definition:MCSection.h:135
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition:MCSymbol.h:41
llvm::MCSymbol::getSection
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Definition:MCSymbol.h:269
llvm::MCTargetOptions::DwarfVersion
int DwarfVersion
Definition:MCTargetOptions.h:79
llvm::MCTargetOptions::Dwarf64
bool Dwarf64
Definition:MCTargetOptions.h:62
llvm::MCTargetOptions::SplitDwarfFile
std::string SplitDwarfFile
Definition:MCTargetOptions.h:97
llvm::MD5
Definition:MD5.h:41
llvm::MD5::update
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
Definition:MD5.cpp:189
llvm::MD5::final
void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
Definition:MD5.cpp:234
llvm::MDNode
Metadata node.
Definition:Metadata.h:1073
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition:Metadata.h:1549
llvm::MachineBasicBlock
Definition:MachineBasicBlock.h:125
llvm::MachineBasicBlock::empty
bool empty() const
Definition:MachineBasicBlock.h:327
llvm::MachineBasicBlock::rend
reverse_iterator rend()
Definition:MachineBasicBlock.h:365
llvm::MachineBasicBlock::succ_end
succ_iterator succ_end()
Definition:MachineBasicBlock.h:423
llvm::MachineBasicBlock::instrs
instr_range instrs()
Definition:MachineBasicBlock.h:350
llvm::MachineBasicBlock::succ_begin
succ_iterator succ_begin()
Definition:MachineBasicBlock.h:421
llvm::MachineBasicBlock::pred_empty
bool pred_empty() const
Definition:MachineBasicBlock.h:420
llvm::MachineBasicBlock::getSectionID
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
Definition:MachineBasicBlock.h:684
llvm::MachineBasicBlock::back
MachineInstr & back()
Definition:MachineBasicBlock.h:335
llvm::MachineBasicBlock::getParent
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Definition:MachineBasicBlock.h:311
llvm::MachineBasicBlock::successors
iterator_range< succ_iterator > successors()
Definition:MachineBasicBlock.h:444
llvm::MachineBasicBlock::rbegin
reverse_iterator rbegin()
Definition:MachineBasicBlock.h:359
llvm::MachineBasicBlock::predecessors
iterator_range< pred_iterator > predecessors()
Definition:MachineBasicBlock.h:438
llvm::MachineBasicBlock::getAlignment
Align getAlignment() const
Return alignment of the basic block.
Definition:MachineBasicBlock.h:614
llvm::MachineFunction
Definition:MachineFunction.h:267
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition:MachineFunction.h:733
llvm::MachineFunction::getCallSitesInfo
const CallSiteInfoMap & getCallSitesInfo() const
Definition:MachineFunction.h:1405
llvm::MachineFunction::hasBBSections
bool hasBBSections() const
Returns true if this function has basic block sections enabled.
Definition:MachineFunction.h:716
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition:MachineFunction.h:704
llvm::MachineFunction::end
iterator end()
Definition:MachineFunction.h:949
llvm::MachineFunction::back
const MachineBasicBlock & back() const
Definition:MachineFunction.h:961
llvm::MachineFunction::begin
iterator begin()
Definition:MachineFunction.h:947
llvm::MachineFunction::getVariableDbgInfo
VariableDbgInfoMapTy & getVariableDbgInfo()
Definition:MachineFunction.h:1367
llvm::MachineFunction::front
const MachineBasicBlock & front() const
Definition:MachineFunction.h:959
llvm::MachineInstrBundleIterator
MachineBasicBlock iterator that automatically skips over MIs that are inside bundles (i....
Definition:MachineInstrBundleIterator.h:108
llvm::MachineInstr
Representation of each machine instruction.
Definition:MachineInstr.h:71
llvm::MachineInstr::getParent
const MachineBasicBlock * getParent() const
Definition:MachineInstr.h:349
llvm::MachineInstr::AnyInBundle
@ AnyInBundle
Definition:MachineInstr.h:896
llvm::MachineInstr::isCall
bool isCall(QueryType Type=AnyInBundle) const
Definition:MachineInstr.h:958
llvm::MachineInstr::uses
iterator_range< mop_iterator > uses()
Returns a range that includes all operands which may be register uses.
Definition:MachineInstr.h:741
llvm::MachineInstr::isBundle
bool isBundle() const
Definition:MachineInstr.h:1436
llvm::MachineInstr::getNumOperands
unsigned getNumOperands() const
Retuns the total number of operands.
Definition:MachineInstr.h:580
llvm::MachineInstr::hasDelaySlot
bool hasDelaySlot(QueryType Type=AnyInBundle) const
Returns true if the specified instruction has a delay slot which must be filled by the code generator...
Definition:MachineInstr.h:1079
llvm::MachineInstr::FrameDestroy
@ FrameDestroy
Definition:MachineInstr.h:89
llvm::MachineInstr::FrameSetup
@ FrameSetup
Definition:MachineInstr.h:87
llvm::MachineInstr::getMF
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
Definition:MachineInstr.cpp:753
llvm::MachineInstr::getDebugLoc
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Definition:MachineInstr.h:501
llvm::MachineInstr::isDebugValue
bool isDebugValue() const
Definition:MachineInstr.h:1362
llvm::MachineLocation
Definition:MachineLocation.h:22
llvm::MachineModuleInfo::getModule
const Module * getModule() const
Definition:MachineModuleInfo.h:132
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition:MachineOperand.h:48
llvm::MachineOperand::getGlobal
const GlobalValue * getGlobal() const
Definition:MachineOperand.h:582
llvm::MachineOperand::isReg
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Definition:MachineOperand.h:329
llvm::MachineOperand::isGlobal
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
Definition:MachineOperand.h:347
llvm::MachineOperand::getReg
Register getReg() const
getReg - Returns the register number.
Definition:MachineOperand.h:369
llvm::MapVector
This class implements a map that also provides access to all stored values in a deterministic order.
Definition:MapVector.h:36
llvm::MapVector::erase
VectorType::iterator erase(typename VectorType::iterator Iterator)
Remove the element given by Iterator.
Definition:MapVector.h:193
llvm::MapVector::empty
bool empty() const
Definition:MapVector.h:79
llvm::MapVector::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition:MapVector.h:141
llvm::MapVector::clear
void clear()
Definition:MapVector.h:88
llvm::Metadata
Root of the metadata hierarchy.
Definition:Metadata.h:62
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::Module::debug_compile_units
iterator_range< debug_compile_units_iterator > debug_compile_units() const
Return an iterator for all DICompileUnits listed in this Module's llvm.dbg.cu named metadata node and...
Definition:Module.h:870
llvm::Module::getDwarfVersion
unsigned getDwarfVersion() const
Returns the Dwarf Version by checking module flags.
Definition:Module.cpp:585
llvm::Module::isDwarf64
bool isDwarf64() const
Returns the DWARF format by checking module flags.
Definition:Module.cpp:592
llvm::Register
Wrapper class representing virtual and physical registers.
Definition:Register.h:19
llvm::Register::isPhysical
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Definition:Register.h:95
llvm::SetVector::empty
bool empty() const
Determine if the SetVector is empty or not.
Definition:SetVector.h:93
llvm::SmallDenseMap
Definition:DenseMap.h:883
llvm::SmallDenseSet
Implements a dense probed hash-table based set with some number of buckets stored inline.
Definition:DenseSet.h:298
llvm::SmallSetVector
A SetVector that performs no allocations if smaller than a certain size.
Definition:SetVector.h:370
llvm::SmallSet
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition:SmallSet.h:132
llvm::SmallSet::begin
const_iterator begin() const
Definition:SmallSet.h:209
llvm::SmallSet::end
const_iterator end() const
Definition:SmallSet.h:215
llvm::SmallSet::insert
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Definition:SmallSet.h:181
llvm::SmallVectorBase::empty
bool empty() const
Definition:SmallVector.h:81
llvm::SmallVectorBase::size
size_t size() const
Definition:SmallVector.h:78
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:SmallVector.h:573
llvm::SmallVectorImpl::assign
void assign(size_type NumElts, ValueParamT Elt)
Definition:SmallVector.h:704
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition:SmallVector.h:937
llvm::SmallVectorImpl::erase
iterator erase(const_iterator CI)
Definition:SmallVector.h:737
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVectorTemplateCommon::end
iterator end()
Definition:SmallVector.h:269
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition:StringMap.h:128
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition:StringRef.h:147
llvm::TargetInstrInfo
TargetInstrInfo - Interface to description of machine instruction set.
Definition:TargetInstrInfo.h:112
llvm::TargetLoweringObjectFile
Definition:TargetLoweringObjectFile.h:45
llvm::TargetMachine::getTargetTriple
const Triple & getTargetTriple() const
Definition:TargetMachine.h:126
llvm::TargetMachine::Options
TargetOptions Options
Definition:TargetMachine.h:118
llvm::TargetOptions::MCOptions
MCTargetOptions MCOptions
Machine level options.
Definition:TargetOptions.h:463
llvm::TargetOptions::DebuggerTuning
DebuggerKind DebuggerTuning
Which debugger to tune for.
Definition:TargetOptions.h:430
llvm::TargetOptions::ShouldEmitDebugEntryValues
bool ShouldEmitDebugEntryValues() const
NOTE: There are targets that still do not support the debug entry values production.
Definition:TargetOptionsImpl.cpp:62
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition:TargetRegisterInfo.h:235
llvm::TargetSubtargetInfo::getRegisterInfo
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
Definition:TargetSubtargetInfo.h:129
llvm::TargetSubtargetInfo::getInstrInfo
virtual const TargetInstrInfo * getInstrInfo() const
Definition:TargetSubtargetInfo.h:97
llvm::TargetSubtargetInfo::getTargetLowering
virtual const TargetLowering * getTargetLowering() const
Definition:TargetSubtargetInfo.h:101
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition:Triple.h:44
llvm::Triple::isNVPTX
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition:Triple.h:878
llvm::Triple::isWasm
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition:Triple.h:1061
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition:Twine.h:81
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition:Value.cpp:309
llvm::Value::dump
void dump() const
Support for debugging, callable in GDB: V->dump()
Definition:AsmWriter.cpp:5304
llvm::cl::opt
Definition:CommandLine.h:1423
llvm::detail::DenseSetImpl::insert
std::pair< iterator, bool > insert(const ValueT &V)
Definition:DenseSet.h:213
llvm::detail::DenseSetImpl::count
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
Definition:DenseSet.h:95
llvm::ilist_node_impl::getReverseIterator
reverse_self_iterator getReverseIterator()
Definition:ilist_node.h:135
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition:ilist_node.h:132
uint16_t
uint64_t
uint8_t
unsigned
llvm::DwarfDebug::tuneForSCE
bool tuneForSCE() const
Definition:DwarfDebug.h:916
llvm::DwarfDebug::tuneForDBX
bool tuneForDBX() const
Definition:DwarfDebug.h:917
llvm::DwarfDebug::tuneForGDB
bool tuneForGDB() const
Definition:DwarfDebug.h:914
llvm::DwarfDebug::tuneForLLDB
bool tuneForLLDB() const
Definition:DwarfDebug.h:915
llvm::dwarf::RangeListEncodingString
StringRef RangeListEncodingString(unsigned Encoding)
Definition:Dwarf.cpp:591
llvm::dwarf::GDBIndexEntryLinkageString
StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage)
Definition:Dwarf.cpp:706
llvm::dwarf::MacroString
StringRef MacroString(unsigned Encoding)
Definition:Dwarf.cpp:563
llvm::dwarf::LocListEncodingString
StringRef LocListEncodingString(unsigned Encoding)
Definition:Dwarf.cpp:602
llvm::dwarf::GnuMacroString
StringRef GnuMacroString(unsigned Encoding)
Definition:Dwarf.cpp:574
llvm::dwarf::MacinfoString
StringRef MacinfoString(unsigned Encoding)
Definition:Dwarf.cpp:534
llvm::dwarf::OperationEncodingString
StringRef OperationEncodingString(unsigned Encoding)
Definition:Dwarf.cpp:138
llvm::dwarf::GDBIndexEntryKindString
StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind)
Definition:Dwarf.cpp:683
ErrorHandling.h
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
TargetMachine.h
CU
Definition:AArch64AsmBackend.cpp:549
llvm::AArch64CC::LS
@ LS
Definition:AArch64BaseInfo.h:264
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition:ARMBuildAttributes.h:82
llvm::ARM::ProfileKind::M
@ M
llvm::COFF::Entry
@ Entry
Definition:COFF.h:844
llvm::M68k::MemAddrModeKind::U
@ U
llvm::RISCVFenceField::R
@ R
Definition:RISCVBaseInfo.h:373
llvm::SIEncodingFamily::VI
@ VI
Definition:SIDefines.h:37
llvm::cl::Hidden
@ Hidden
Definition:CommandLine.h:137
llvm::cl::values
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition:CommandLine.h:711
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:CommandLine.h:443
llvm::codeview::SimpleTypeKind::Byte
@ Byte
llvm::dwarf::Attribute
Attribute
Attributes.
Definition:Dwarf.h:123
llvm::dwarf::Index
Index
Definition:Dwarf.h:882
llvm::dwarf::Form
Form
Definition:Dwarf.h:130
llvm::dwarf::SourceLanguage
SourceLanguage
Definition:Dwarf.h:207
llvm::dwarf::DWARF64
@ DWARF64
Definition:Dwarf.h:91
llvm::dwarf::DWARF32
@ DWARF32
Definition:Dwarf.h:91
llvm::dwarf::DW_MACINFO_start_file
@ DW_MACINFO_start_file
Definition:Dwarf.h:798
llvm::dwarf::DW_MACINFO_end_file
@ DW_MACINFO_end_file
Definition:Dwarf.h:799
llvm::dwarf::DW_MACINFO_define
@ DW_MACINFO_define
Definition:Dwarf.h:796
llvm::dwarf::GIEK_NONE
@ GIEK_NONE
Definition:Dwarf.h:951
llvm::dwarf::GIEK_TYPE
@ GIEK_TYPE
Definition:Dwarf.h:952
llvm::dwarf::GIEK_FUNCTION
@ GIEK_FUNCTION
Definition:Dwarf.h:954
llvm::dwarf::GIEK_VARIABLE
@ GIEK_VARIABLE
Definition:Dwarf.h:953
llvm::dwarf::isCPlusPlus
bool isCPlusPlus(SourceLanguage S)
Definition:Dwarf.h:497
llvm::dwarf::DW_ARANGES_VERSION
@ DW_ARANGES_VERSION
Section version number for .debug_aranges.
Definition:Dwarf.h:64
llvm::dwarf::DW_PUBNAMES_VERSION
@ DW_PUBNAMES_VERSION
Section version number for .debug_pubnames.
Definition:Dwarf.h:63
llvm::dwarf::DWARF_VERSION
@ DWARF_VERSION
Other constants.
Definition:Dwarf.h:61
llvm::dwarf::GDBIndexEntryLinkage
GDBIndexEntryLinkage
Definition:Dwarf.h:961
llvm::dwarf::GIEL_EXTERNAL
@ GIEL_EXTERNAL
Definition:Dwarf.h:961
llvm::dwarf::GIEL_STATIC
@ GIEL_STATIC
Definition:Dwarf.h:961
llvm::jitlink::Scope
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
Definition:JITLink.h:412
llvm::lltok::LocalVar
@ LocalVar
Definition:LLToken.h:484
llvm::logicalview::LVAttributeKind::Producer
@ Producer
llvm::mcdwarf::emitListsTableHeaderStart
MCSymbol * emitListsTableHeaderStart(MCStreamer &S)
Definition:MCDwarf.cpp:44
llvm::omp::RTLDependInfoFields::Flags
@ Flags
llvm::pdb::PDB_SymType::Label
@ Label
llvm::pdb::PDB_ColorItem::Comment
@ Comment
llvm::pdb::PDB_ColorItem::Padding
@ Padding
llvm::rdf::Instr
NodeAddr< InstrNode * > Instr
Definition:RDFGraph.h:389
llvm::sampleprof::Base
@ Base
Definition:Discriminator.h:58
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::Offset
@ Offset
Definition:DWP.cpp:480
llvm::Length
@ Length
Definition:DWP.cpp:480
llvm::operator<
bool operator<(int64_t V1, const APSInt &V2)
Definition:APSInt.h:361
llvm::getBundleStart
MachineBasicBlock::instr_iterator getBundleStart(MachineBasicBlock::instr_iterator I)
Returns an iterator to the first instruction in the bundle containing I.
Definition:MachineInstrBundle.h:44
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1739
llvm::enumerate
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
Definition:STLExtras.h:2448
llvm::unique
auto unique(Range &&R, Predicate P)
Definition:STLExtras.h:2055
llvm::erase
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
Definition:STLExtras.h:2107
llvm::any_of
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1746
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition:STLExtras.h:1664
llvm::AccelTableKind
AccelTableKind
The kind of accelerator tables we should emit.
Definition:DwarfDebug.h:343
llvm::AccelTableKind::None
@ None
None.
llvm::AccelTableKind::Default
@ Default
Platform default.
llvm::AccelTableKind::Apple
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
llvm::AccelTableKind::Dwarf
@ Dwarf
DWARF v5 .debug_names.
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::none_of
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1753
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition:Error.cpp:167
llvm::getBundleEnd
MachineBasicBlock::instr_iterator getBundleEnd(MachineBasicBlock::instr_iterator I)
Returns an iterator pointing beyond the bundle containing I.
Definition:MachineInstrBundle.h:60
llvm::is_sorted
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
Definition:STLExtras.h:1926
llvm::offsetToAlignment
uint64_t offsetToAlignment(uint64_t Value, Align Alignment)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
Definition:Alignment.h:197
llvm::AsanDtorKind::Global
@ Global
Append to llvm.global_dtors.
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
llvm::emitAppleAccelTable
void emitAppleAccelTable(AsmPrinter *Asm, AccelTable< DataT > &Contents, StringRef Prefix, const MCSymbol *SecBegin)
Emit an Apple Accelerator Table consisting of entries in the specified AccelTable.
Definition:AccelTable.h:448
llvm::emitDWARF5AccelTable
void emitDWARF5AccelTable(AsmPrinter *Asm, DWARF5AccelTable &Contents, const DwarfDebug &DD, ArrayRef< std::unique_ptr< DwarfCompileUnit > > CUs)
Definition:AccelTable.cpp:642
llvm::erase_if
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
Definition:STLExtras.h:2099
llvm::BasicBlockSection::List
@ List
llvm::UnitKind::Skeleton
@ Skeleton
llvm::DebuggerKind
DebuggerKind
Identify a debugger for "tuning" the debug info.
Definition:TargetOptions.h:94
llvm::DebuggerKind::SCE
@ SCE
Tune debug info for SCE targets (e.g. PS4).
llvm::DebuggerKind::DBX
@ DBX
Tune debug info for dbx.
llvm::DebuggerKind::Default
@ Default
No specific tuning requested.
llvm::DebuggerKind::GDB
@ GDB
Tune debug info for gdb.
llvm::DebuggerKind::LLDB
@ LLDB
Tune debug info for lldb.
llvm::Data
@ Data
Definition:SIMachineScheduler.h:55
llvm::ColorMode::Enable
@ Enable
Enable colors.
llvm::ColorMode::Disable
@ Disable
Disable colors.
std
Implement std::hash so that hash_code can be used in STL containers.
Definition:BitVector.h:858
raw_ostream.h
N
#define N
ArangeSpan
Definition:DwarfDebug.cpp:3257
ArangeSpan::Start
const MCSymbol * Start
Definition:DwarfDebug.cpp:3258
ArangeSpan::End
const MCSymbol * End
Definition:DwarfDebug.cpp:3258
FwdRegParamInfo
Represents a parameter whose call site value can be described by applying a debug expression to a reg...
Definition:DwarfDebug.cpp:569
FwdRegParamInfo::ParamReg
uint64_t ParamReg
The described parameter register.
Definition:DwarfDebug.cpp:571
FwdRegParamInfo::Expr
const DIExpression * Expr
Debug expression that has been built up when walking through the instruction chain that produces the ...
Definition:DwarfDebug.cpp:575
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition:Alignment.h:39
llvm::BitTracker
Definition:BitTracker.h:35
llvm::DWARFExpression::Operation::Description
Description of the encoding of one expression Op.
Definition:DWARFExpression.h:66
llvm::DWARFExpression::Operation::Description::Op
SmallVector< Encoding > Op
Encoding for Op operands.
Definition:DWARFExpression.h:68
llvm::DebugLocStream::Entry
Definition:DebugLocStream.h:39
llvm::DebugLocStream::List
Definition:DebugLocStream.h:32
llvm::DwarfCompileUnit::GlobalExpr
A pair of GlobalVariable and DIExpression.
Definition:DwarfCompileUnit.h:166
llvm::EntryValueInfo
Represents an entry-value location, or a fragment of one.
Definition:DwarfDebug.h:120
llvm::FrameIndexExpr
Proxy for one MMI entry.
Definition:DwarfDebug.h:111
llvm::Loc::EntryValue
Single location defined by (potentially multiple) EntryValueInfo.
Definition:DwarfDebug.h:172
llvm::Loc::MMI
Single location defined by (potentially multiple) MMI entries.
Definition:DwarfDebug.h:159
llvm::Loc::MMI::addFrameIndexExpr
void addFrameIndexExpr(const DIExpression *Expr, int FI)
Definition:DwarfDebug.cpp:296
llvm::Loc::MMI::getFrameIndexExprs
const std::set< FrameIndexExpr > & getFrameIndexExprs() const
Get the FI entries, sorted by fragment offset.
Definition:DwarfDebug.cpp:292
llvm::MCDwarfLineTableParams
Definition:MCDwarf.h:260
llvm::MD5::MD5Result
Definition:MD5.h:43
llvm::RangeSpanList
Definition:DwarfFile.h:46
llvm::SmallMapVector
A MapVector that performs no allocations if smaller than a certain size.
Definition:MapVector.h:254
llvm::SymbolCU
Helper used to pair up a symbol and its DWARF compile unit.
Definition:DwarfDebug.h:335
llvm::SymbolCU::Sym
const MCSymbol * Sym
Definition:DwarfDebug.h:338
llvm::SymbolCU::CU
DwarfCompileUnit * CU
Definition:DwarfDebug.h:339
llvm::TargetIndexLocation
This struct describes target specific location.
Definition:DebugLocEntry.h:24
llvm::TargetIndexLocation::Index
int Index
Definition:DebugLocEntry.h:25
llvm::TargetIndexLocation::Offset
int Offset
Definition:DebugLocEntry.h:26
llvm::cl::desc
Definition:CommandLine.h:409
llvm::dwarf::PubIndexEntryDescriptor
Describes an entry of the various gnu_pub* debug sections.
Definition:Dwarf.h:1155

Generated on Fri Jul 18 2025 10:27:56 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp