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