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