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