LLVM  14.0.0git
DebugInfo.cpp
Go to the documentation of this file.
1 //===- DebugInfo.cpp - Debug Information Helper Classes -------------------===//
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 implements the helper classes used to build and interpret debug
10 // information in LLVM IR form.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm-c/DebugInfo.h"
15 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/ADT/DenseSet.h"
17 #include "llvm/ADT/None.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/SmallPtrSet.h"
20 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/IR/BasicBlock.h"
23 #include "llvm/IR/Constants.h"
25 #include "llvm/IR/DebugLoc.h"
26 #include "llvm/IR/DebugInfo.h"
27 #include "llvm/IR/DIBuilder.h"
28 #include "llvm/IR/Function.h"
29 #include "llvm/IR/GVMaterializer.h"
30 #include "llvm/IR/Instruction.h"
31 #include "llvm/IR/IntrinsicInst.h"
32 #include "llvm/IR/LLVMContext.h"
33 #include "llvm/IR/Metadata.h"
34 #include "llvm/IR/Module.h"
35 #include "llvm/Support/Casting.h"
36 #include <algorithm>
37 #include <cassert>
38 #include <utility>
39 
40 using namespace llvm;
41 using namespace llvm::dwarf;
42 
43 /// Finds all intrinsics declaring local variables as living in the memory that
44 /// 'V' points to. This may include a mix of dbg.declare and
45 /// dbg.addr intrinsics.
47  // This function is hot. Check whether the value has any metadata to avoid a
48  // DenseMap lookup.
49  if (!V->isUsedByMetadata())
50  return {};
51  auto *L = LocalAsMetadata::getIfExists(V);
52  if (!L)
53  return {};
54  auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L);
55  if (!MDV)
56  return {};
57 
59  for (User *U : MDV->users()) {
60  if (auto *DII = dyn_cast<DbgVariableIntrinsic>(U))
61  if (DII->isAddressOfVariable())
62  Declares.push_back(DII);
63  }
64 
65  return Declares;
66 }
67 
71  if (auto *DDI = dyn_cast<DbgDeclareInst>(DVI))
72  DDIs.push_back(DDI);
73  return DDIs;
74 }
75 
77  // This function is hot. Check whether the value has any metadata to avoid a
78  // DenseMap lookup.
79  if (!V->isUsedByMetadata())
80  return;
81  // TODO: If this value appears multiple times in a DIArgList, we should still
82  // only add the owning DbgValueInst once; use this set to track ArgListUsers.
83  // This behaviour can be removed when we can automatically remove duplicates.
84  SmallPtrSet<DbgValueInst *, 4> EncounteredDbgValues;
85  if (auto *L = LocalAsMetadata::getIfExists(V)) {
86  if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L)) {
87  for (User *U : MDV->users())
88  if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(U))
89  DbgValues.push_back(DVI);
90  }
91  for (Metadata *AL : L->getAllArgListUsers()) {
92  if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), AL)) {
93  for (User *U : MDV->users())
94  if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(U))
95  if (EncounteredDbgValues.insert(DVI).second)
96  DbgValues.push_back(DVI);
97  }
98  }
99  }
100 }
101 
103  Value *V) {
104  // This function is hot. Check whether the value has any metadata to avoid a
105  // DenseMap lookup.
106  if (!V->isUsedByMetadata())
107  return;
108  // TODO: If this value appears multiple times in a DIArgList, we should still
109  // only add the owning DbgValueInst once; use this set to track ArgListUsers.
110  // This behaviour can be removed when we can automatically remove duplicates.
111  SmallPtrSet<DbgVariableIntrinsic *, 4> EncounteredDbgValues;
112  if (auto *L = LocalAsMetadata::getIfExists(V)) {
113  if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L)) {
114  for (User *U : MDV->users())
115  if (DbgVariableIntrinsic *DII = dyn_cast<DbgVariableIntrinsic>(U))
116  DbgUsers.push_back(DII);
117  }
118  for (Metadata *AL : L->getAllArgListUsers()) {
119  if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), AL)) {
120  for (User *U : MDV->users())
121  if (DbgVariableIntrinsic *DII = dyn_cast<DbgVariableIntrinsic>(U))
122  if (EncounteredDbgValues.insert(DII).second)
123  DbgUsers.push_back(DII);
124  }
125  }
126  }
127 }
128 
130  if (auto *LocalScope = dyn_cast_or_null<DILocalScope>(Scope))
131  return LocalScope->getSubprogram();
132  return nullptr;
133 }
134 
135 //===----------------------------------------------------------------------===//
136 // DebugInfoFinder implementations.
137 //===----------------------------------------------------------------------===//
138 
140  CUs.clear();
141  SPs.clear();
142  GVs.clear();
143  TYs.clear();
144  Scopes.clear();
145  NodesSeen.clear();
146 }
147 
149  for (auto *CU : M.debug_compile_units())
150  processCompileUnit(CU);
151  for (auto &F : M.functions()) {
152  if (auto *SP = cast_or_null<DISubprogram>(F.getSubprogram()))
153  processSubprogram(SP);
154  // There could be subprograms from inlined functions referenced from
155  // instructions only. Walk the function to find them.
156  for (const BasicBlock &BB : F)
157  for (const Instruction &I : BB)
158  processInstruction(M, I);
159  }
160 }
161 
162 void DebugInfoFinder::processCompileUnit(DICompileUnit *CU) {
163  if (!addCompileUnit(CU))
164  return;
165  for (auto DIG : CU->getGlobalVariables()) {
166  if (!addGlobalVariable(DIG))
167  continue;
168  auto *GV = DIG->getVariable();
169  processScope(GV->getScope());
170  processType(GV->getType());
171  }
172  for (auto *ET : CU->getEnumTypes())
173  processType(ET);
174  for (auto *RT : CU->getRetainedTypes())
175  if (auto *T = dyn_cast<DIType>(RT))
176  processType(T);
177  else
178  processSubprogram(cast<DISubprogram>(RT));
179  for (auto *Import : CU->getImportedEntities()) {
180  auto *Entity = Import->getEntity();
181  if (auto *T = dyn_cast<DIType>(Entity))
182  processType(T);
183  else if (auto *SP = dyn_cast<DISubprogram>(Entity))
184  processSubprogram(SP);
185  else if (auto *NS = dyn_cast<DINamespace>(Entity))
186  processScope(NS->getScope());
187  else if (auto *M = dyn_cast<DIModule>(Entity))
188  processScope(M->getScope());
189  }
190 }
191 
193  const Instruction &I) {
194  if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&I))
195  processVariable(M, *DVI);
196 
197  if (auto DbgLoc = I.getDebugLoc())
198  processLocation(M, DbgLoc.get());
199 }
200 
202  if (!Loc)
203  return;
204  processScope(Loc->getScope());
205  processLocation(M, Loc->getInlinedAt());
206 }
207 
208 void DebugInfoFinder::processType(DIType *DT) {
209  if (!addType(DT))
210  return;
211  processScope(DT->getScope());
212  if (auto *ST = dyn_cast<DISubroutineType>(DT)) {
213  for (DIType *Ref : ST->getTypeArray())
214  processType(Ref);
215  return;
216  }
217  if (auto *DCT = dyn_cast<DICompositeType>(DT)) {
218  processType(DCT->getBaseType());
219  for (Metadata *D : DCT->getElements()) {
220  if (auto *T = dyn_cast<DIType>(D))
221  processType(T);
222  else if (auto *SP = dyn_cast<DISubprogram>(D))
223  processSubprogram(SP);
224  }
225  return;
226  }
227  if (auto *DDT = dyn_cast<DIDerivedType>(DT)) {
228  processType(DDT->getBaseType());
229  }
230 }
231 
232 void DebugInfoFinder::processScope(DIScope *Scope) {
233  if (!Scope)
234  return;
235  if (auto *Ty = dyn_cast<DIType>(Scope)) {
236  processType(Ty);
237  return;
238  }
239  if (auto *CU = dyn_cast<DICompileUnit>(Scope)) {
240  addCompileUnit(CU);
241  return;
242  }
243  if (auto *SP = dyn_cast<DISubprogram>(Scope)) {
244  processSubprogram(SP);
245  return;
246  }
247  if (!addScope(Scope))
248  return;
249  if (auto *LB = dyn_cast<DILexicalBlockBase>(Scope)) {
250  processScope(LB->getScope());
251  } else if (auto *NS = dyn_cast<DINamespace>(Scope)) {
252  processScope(NS->getScope());
253  } else if (auto *M = dyn_cast<DIModule>(Scope)) {
254  processScope(M->getScope());
255  }
256 }
257 
259  if (!addSubprogram(SP))
260  return;
261  processScope(SP->getScope());
262  // Some of the users, e.g. CloneFunctionInto / CloneModule, need to set up a
263  // ValueMap containing identity mappings for all of the DICompileUnit's, not
264  // just DISubprogram's, referenced from anywhere within the Function being
265  // cloned prior to calling MapMetadata / RemapInstruction to avoid their
266  // duplication later as DICompileUnit's are also directly referenced by
267  // llvm.dbg.cu list. Thefore we need to collect DICompileUnit's here as well.
268  // Also, DICompileUnit's may reference DISubprogram's too and therefore need
269  // to be at least looked through.
270  processCompileUnit(SP->getUnit());
271  processType(SP->getType());
272  for (auto *Element : SP->getTemplateParams()) {
273  if (auto *TType = dyn_cast<DITemplateTypeParameter>(Element)) {
274  processType(TType->getType());
275  } else if (auto *TVal = dyn_cast<DITemplateValueParameter>(Element)) {
276  processType(TVal->getType());
277  }
278  }
279 }
280 
282  const DbgVariableIntrinsic &DVI) {
283  auto *N = dyn_cast<MDNode>(DVI.getVariable());
284  if (!N)
285  return;
286 
287  auto *DV = dyn_cast<DILocalVariable>(N);
288  if (!DV)
289  return;
290 
291  if (!NodesSeen.insert(DV).second)
292  return;
293  processScope(DV->getScope());
294  processType(DV->getType());
295 }
296 
297 bool DebugInfoFinder::addType(DIType *DT) {
298  if (!DT)
299  return false;
300 
301  if (!NodesSeen.insert(DT).second)
302  return false;
303 
304  TYs.push_back(const_cast<DIType *>(DT));
305  return true;
306 }
307 
308 bool DebugInfoFinder::addCompileUnit(DICompileUnit *CU) {
309  if (!CU)
310  return false;
311  if (!NodesSeen.insert(CU).second)
312  return false;
313 
314  CUs.push_back(CU);
315  return true;
316 }
317 
318 bool DebugInfoFinder::addGlobalVariable(DIGlobalVariableExpression *DIG) {
319  if (!NodesSeen.insert(DIG).second)
320  return false;
321 
322  GVs.push_back(DIG);
323  return true;
324 }
325 
326 bool DebugInfoFinder::addSubprogram(DISubprogram *SP) {
327  if (!SP)
328  return false;
329 
330  if (!NodesSeen.insert(SP).second)
331  return false;
332 
333  SPs.push_back(SP);
334  return true;
335 }
336 
337 bool DebugInfoFinder::addScope(DIScope *Scope) {
338  if (!Scope)
339  return false;
340  // FIXME: Ocaml binding generates a scope with no content, we treat it
341  // as null for now.
342  if (Scope->getNumOperands() == 0)
343  return false;
344  if (!NodesSeen.insert(Scope).second)
345  return false;
346  Scopes.push_back(Scope);
347  return true;
348 }
349 
351  MDNode *OrigLoopID, function_ref<Metadata *(Metadata *)> Updater) {
352  assert(OrigLoopID && OrigLoopID->getNumOperands() > 0 &&
353  "Loop ID needs at least one operand");
354  assert(OrigLoopID && OrigLoopID->getOperand(0).get() == OrigLoopID &&
355  "Loop ID should refer to itself");
356 
357  // Save space for the self-referential LoopID.
358  SmallVector<Metadata *, 4> MDs = {nullptr};
359 
360  for (unsigned i = 1; i < OrigLoopID->getNumOperands(); ++i) {
361  Metadata *MD = OrigLoopID->getOperand(i);
362  if (!MD)
363  MDs.push_back(nullptr);
364  else if (Metadata *NewMD = Updater(MD))
365  MDs.push_back(NewMD);
366  }
367 
368  MDNode *NewLoopID = MDNode::getDistinct(OrigLoopID->getContext(), MDs);
369  // Insert the self-referential LoopID.
370  NewLoopID->replaceOperandWith(0, NewLoopID);
371  return NewLoopID;
372 }
373 
375  Instruction &I, function_ref<Metadata *(Metadata *)> Updater) {
376  MDNode *OrigLoopID = I.getMetadata(LLVMContext::MD_loop);
377  if (!OrigLoopID)
378  return;
379  MDNode *NewLoopID = updateLoopMetadataDebugLocationsImpl(OrigLoopID, Updater);
380  I.setMetadata(LLVMContext::MD_loop, NewLoopID);
381 }
382 
383 /// Return true if a node is a DILocation or if a DILocation is
384 /// indirectly referenced by one of the node's children.
386  SmallPtrSetImpl<Metadata *> &Reachable,
387  Metadata *MD) {
388  MDNode *N = dyn_cast_or_null<MDNode>(MD);
389  if (!N)
390  return false;
391  if (isa<DILocation>(N) || Reachable.count(N))
392  return true;
393  if (!Visited.insert(N).second)
394  return false;
395  for (auto &OpIt : N->operands()) {
396  Metadata *Op = OpIt.get();
397  if (isDILocationReachable(Visited, Reachable, Op)) {
398  Reachable.insert(N);
399  return true;
400  }
401  }
402  return false;
403 }
404 
406  assert(!N->operands().empty() && "Missing self reference?");
407  SmallPtrSet<Metadata *, 8> Visited, DILocationReachable;
408  // If we already visited N, there is nothing to do.
409  if (!Visited.insert(N).second)
410  return N;
411 
412  // If there is no debug location, we do not have to rewrite this
413  // MDNode. This loop also initializes DILocationReachable, later
414  // needed by updateLoopMetadataDebugLocationsImpl; the use of
415  // count_if avoids an early exit.
416  if (!std::count_if(N->op_begin() + 1, N->op_end(),
417  [&Visited, &DILocationReachable](const MDOperand &Op) {
418  return isDILocationReachable(
419  Visited, DILocationReachable, Op.get());
420  }))
421  return N;
422 
423  // If there is only the debug location without any actual loop metadata, we
424  // can remove the metadata.
425  if (std::all_of(
426  N->op_begin() + 1, N->op_end(),
427  [&Visited, &DILocationReachable](const MDOperand &Op) {
428  return isDILocationReachable(Visited, DILocationReachable,
429  Op.get());
430  }))
431  return nullptr;
432 
434  N, [&DILocationReachable](Metadata *MD) -> Metadata * {
435  if (isa<DILocation>(MD) || DILocationReachable.count(MD))
436  return nullptr;
437  return MD;
438  });
439 }
440 
442  bool Changed = false;
443  if (F.hasMetadata(LLVMContext::MD_dbg)) {
444  Changed = true;
445  F.setSubprogram(nullptr);
446  }
447 
448  DenseMap<MDNode *, MDNode *> LoopIDsMap;
449  for (BasicBlock &BB : F) {
450  for (auto II = BB.begin(), End = BB.end(); II != End;) {
451  Instruction &I = *II++; // We may delete the instruction, increment now.
452  if (isa<DbgInfoIntrinsic>(&I)) {
453  I.eraseFromParent();
454  Changed = true;
455  continue;
456  }
457  if (I.getDebugLoc()) {
458  Changed = true;
459  I.setDebugLoc(DebugLoc());
460  }
461  if (auto *LoopID = I.getMetadata(LLVMContext::MD_loop)) {
462  auto *NewLoopID = LoopIDsMap.lookup(LoopID);
463  if (!NewLoopID)
464  NewLoopID = LoopIDsMap[LoopID] = stripDebugLocFromLoopID(LoopID);
465  if (NewLoopID != LoopID)
466  I.setMetadata(LLVMContext::MD_loop, NewLoopID);
467  }
468  // Strip heapallocsite attachments, they point into the DIType system.
469  if (I.hasMetadataOtherThanDebugLoc())
470  I.setMetadata("heapallocsite", nullptr);
471  }
472  }
473  return Changed;
474 }
475 
477  bool Changed = false;
478 
479  for (NamedMDNode &NMD : llvm::make_early_inc_range(M.named_metadata())) {
480  // We're stripping debug info, and without them, coverage information
481  // doesn't quite make sense.
482  if (NMD.getName().startswith("llvm.dbg.") ||
483  NMD.getName() == "llvm.gcov") {
484  NMD.eraseFromParent();
485  Changed = true;
486  }
487  }
488 
489  for (Function &F : M)
490  Changed |= stripDebugInfo(F);
491 
492  for (auto &GV : M.globals()) {
493  Changed |= GV.eraseMetadata(LLVMContext::MD_dbg);
494  }
495 
496  if (GVMaterializer *Materializer = M.getMaterializer())
497  Materializer->setStripDebugInfo();
498 
499  return Changed;
500 }
501 
502 namespace {
503 
504 /// Helper class to downgrade -g metadata to -gline-tables-only metadata.
505 class DebugTypeInfoRemoval {
507 
508 public:
509  /// The (void)() type.
510  MDNode *EmptySubroutineType;
511 
512 private:
513  /// Remember what linkage name we originally had before stripping. If we end
514  /// up making two subprograms identical who originally had different linkage
515  /// names, then we need to make one of them distinct, to avoid them getting
516  /// uniqued. Maps the new node to the old linkage name.
517  DenseMap<DISubprogram *, StringRef> NewToLinkageName;
518 
519  // TODO: Remember the distinct subprogram we created for a given linkage name,
520  // so that we can continue to unique whenever possible. Map <newly created
521  // node, old linkage name> to the first (possibly distinct) mdsubprogram
522  // created for that combination. This is not strictly needed for correctness,
523  // but can cut down on the number of MDNodes and let us diff cleanly with the
524  // output of -gline-tables-only.
525 
526 public:
527  DebugTypeInfoRemoval(LLVMContext &C)
528  : EmptySubroutineType(DISubroutineType::get(C, DINode::FlagZero, 0,
529  MDNode::get(C, {}))) {}
530 
531  Metadata *map(Metadata *M) {
532  if (!M)
533  return nullptr;
534  auto Replacement = Replacements.find(M);
535  if (Replacement != Replacements.end())
536  return Replacement->second;
537 
538  return M;
539  }
540  MDNode *mapNode(Metadata *N) { return dyn_cast_or_null<MDNode>(map(N)); }
541 
542  /// Recursively remap N and all its referenced children. Does a DF post-order
543  /// traversal, so as to remap bottoms up.
544  void traverseAndRemap(MDNode *N) { traverse(N); }
545 
546 private:
547  // Create a new DISubprogram, to replace the one given.
548  DISubprogram *getReplacementSubprogram(DISubprogram *MDS) {
549  auto *FileAndScope = cast_or_null<DIFile>(map(MDS->getFile()));
550  StringRef LinkageName = MDS->getName().empty() ? MDS->getLinkageName() : "";
551  DISubprogram *Declaration = nullptr;
552  auto *Type = cast_or_null<DISubroutineType>(map(MDS->getType()));
553  DIType *ContainingType =
554  cast_or_null<DIType>(map(MDS->getContainingType()));
555  auto *Unit = cast_or_null<DICompileUnit>(map(MDS->getUnit()));
556  auto Variables = nullptr;
557  auto TemplateParams = nullptr;
558 
559  // Make a distinct DISubprogram, for situations that warrent it.
560  auto distinctMDSubprogram = [&]() {
562  MDS->getContext(), FileAndScope, MDS->getName(), LinkageName,
563  FileAndScope, MDS->getLine(), Type, MDS->getScopeLine(),
564  ContainingType, MDS->getVirtualIndex(), MDS->getThisAdjustment(),
565  MDS->getFlags(), MDS->getSPFlags(), Unit, TemplateParams, Declaration,
566  Variables);
567  };
568 
569  if (MDS->isDistinct())
570  return distinctMDSubprogram();
571 
572  auto *NewMDS = DISubprogram::get(
573  MDS->getContext(), FileAndScope, MDS->getName(), LinkageName,
574  FileAndScope, MDS->getLine(), Type, MDS->getScopeLine(), ContainingType,
575  MDS->getVirtualIndex(), MDS->getThisAdjustment(), MDS->getFlags(),
576  MDS->getSPFlags(), Unit, TemplateParams, Declaration, Variables);
577 
578  StringRef OldLinkageName = MDS->getLinkageName();
579 
580  // See if we need to make a distinct one.
581  auto OrigLinkage = NewToLinkageName.find(NewMDS);
582  if (OrigLinkage != NewToLinkageName.end()) {
583  if (OrigLinkage->second == OldLinkageName)
584  // We're good.
585  return NewMDS;
586 
587  // Otherwise, need to make a distinct one.
588  // TODO: Query the map to see if we already have one.
589  return distinctMDSubprogram();
590  }
591 
592  NewToLinkageName.insert({NewMDS, MDS->getLinkageName()});
593  return NewMDS;
594  }
595 
596  /// Create a new compile unit, to replace the one given
597  DICompileUnit *getReplacementCU(DICompileUnit *CU) {
598  // Drop skeleton CUs.
599  if (CU->getDWOId())
600  return nullptr;
601 
602  auto *File = cast_or_null<DIFile>(map(CU->getFile()));
603  MDTuple *EnumTypes = nullptr;
604  MDTuple *RetainedTypes = nullptr;
605  MDTuple *GlobalVariables = nullptr;
606  MDTuple *ImportedEntities = nullptr;
608  CU->getContext(), CU->getSourceLanguage(), File, CU->getProducer(),
609  CU->isOptimized(), CU->getFlags(), CU->getRuntimeVersion(),
610  CU->getSplitDebugFilename(), DICompileUnit::LineTablesOnly, EnumTypes,
611  RetainedTypes, GlobalVariables, ImportedEntities, CU->getMacros(),
612  CU->getDWOId(), CU->getSplitDebugInlining(),
613  CU->getDebugInfoForProfiling(), CU->getNameTableKind(),
614  CU->getRangesBaseAddress(), CU->getSysRoot(), CU->getSDK());
615  }
616 
617  DILocation *getReplacementMDLocation(DILocation *MLD) {
618  auto *Scope = map(MLD->getScope());
619  auto *InlinedAt = map(MLD->getInlinedAt());
620  if (MLD->isDistinct())
621  return DILocation::getDistinct(MLD->getContext(), MLD->getLine(),
622  MLD->getColumn(), Scope, InlinedAt);
623  return DILocation::get(MLD->getContext(), MLD->getLine(), MLD->getColumn(),
624  Scope, InlinedAt);
625  }
626 
627  /// Create a new generic MDNode, to replace the one given
628  MDNode *getReplacementMDNode(MDNode *N) {
630  Ops.reserve(N->getNumOperands());
631  for (auto &I : N->operands())
632  if (I)
633  Ops.push_back(map(I));
634  auto *Ret = MDNode::get(N->getContext(), Ops);
635  return Ret;
636  }
637 
638  /// Attempt to re-map N to a newly created node.
639  void remap(MDNode *N) {
640  if (Replacements.count(N))
641  return;
642 
643  auto doRemap = [&](MDNode *N) -> MDNode * {
644  if (!N)
645  return nullptr;
646  if (auto *MDSub = dyn_cast<DISubprogram>(N)) {
647  remap(MDSub->getUnit());
648  return getReplacementSubprogram(MDSub);
649  }
650  if (isa<DISubroutineType>(N))
651  return EmptySubroutineType;
652  if (auto *CU = dyn_cast<DICompileUnit>(N))
653  return getReplacementCU(CU);
654  if (isa<DIFile>(N))
655  return N;
656  if (auto *MDLB = dyn_cast<DILexicalBlockBase>(N))
657  // Remap to our referenced scope (recursively).
658  return mapNode(MDLB->getScope());
659  if (auto *MLD = dyn_cast<DILocation>(N))
660  return getReplacementMDLocation(MLD);
661 
662  // Otherwise, if we see these, just drop them now. Not strictly necessary,
663  // but this speeds things up a little.
664  if (isa<DINode>(N))
665  return nullptr;
666 
667  return getReplacementMDNode(N);
668  };
669  Replacements[N] = doRemap(N);
670  }
671 
672  /// Do the remapping traversal.
673  void traverse(MDNode *);
674 };
675 
676 } // end anonymous namespace
677 
678 void DebugTypeInfoRemoval::traverse(MDNode *N) {
679  if (!N || Replacements.count(N))
680  return;
681 
682  // To avoid cycles, as well as for efficiency sake, we will sometimes prune
683  // parts of the graph.
684  auto prune = [](MDNode *Parent, MDNode *Child) {
685  if (auto *MDS = dyn_cast<DISubprogram>(Parent))
686  return Child == MDS->getRetainedNodes().get();
687  return false;
688  };
689 
691  DenseSet<MDNode *> Opened;
692 
693  // Visit each node starting at N in post order, and map them.
694  ToVisit.push_back(N);
695  while (!ToVisit.empty()) {
696  auto *N = ToVisit.back();
697  if (!Opened.insert(N).second) {
698  // Close it.
699  remap(N);
700  ToVisit.pop_back();
701  continue;
702  }
703  for (auto &I : N->operands())
704  if (auto *MDN = dyn_cast_or_null<MDNode>(I))
705  if (!Opened.count(MDN) && !Replacements.count(MDN) && !prune(N, MDN) &&
706  !isa<DICompileUnit>(MDN))
707  ToVisit.push_back(MDN);
708  }
709 }
710 
712  bool Changed = false;
713 
714  // First off, delete the debug intrinsics.
715  auto RemoveUses = [&](StringRef Name) {
716  if (auto *DbgVal = M.getFunction(Name)) {
717  while (!DbgVal->use_empty())
718  cast<Instruction>(DbgVal->user_back())->eraseFromParent();
719  DbgVal->eraseFromParent();
720  Changed = true;
721  }
722  };
723  RemoveUses("llvm.dbg.addr");
724  RemoveUses("llvm.dbg.declare");
725  RemoveUses("llvm.dbg.label");
726  RemoveUses("llvm.dbg.value");
727 
728  // Delete non-CU debug info named metadata nodes.
729  for (auto NMI = M.named_metadata_begin(), NME = M.named_metadata_end();
730  NMI != NME;) {
731  NamedMDNode *NMD = &*NMI;
732  ++NMI;
733  // Specifically keep dbg.cu around.
734  if (NMD->getName() == "llvm.dbg.cu")
735  continue;
736  }
737 
738  // Drop all dbg attachments from global variables.
739  for (auto &GV : M.globals())
740  GV.eraseMetadata(LLVMContext::MD_dbg);
741 
742  DebugTypeInfoRemoval Mapper(M.getContext());
743  auto remap = [&](MDNode *Node) -> MDNode * {
744  if (!Node)
745  return nullptr;
746  Mapper.traverseAndRemap(Node);
747  auto *NewNode = Mapper.mapNode(Node);
748  Changed |= Node != NewNode;
749  Node = NewNode;
750  return NewNode;
751  };
752 
753  // Rewrite the DebugLocs to be equivalent to what
754  // -gline-tables-only would have created.
755  for (auto &F : M) {
756  if (auto *SP = F.getSubprogram()) {
757  Mapper.traverseAndRemap(SP);
758  auto *NewSP = cast<DISubprogram>(Mapper.mapNode(SP));
759  Changed |= SP != NewSP;
760  F.setSubprogram(NewSP);
761  }
762  for (auto &BB : F) {
763  for (auto &I : BB) {
764  auto remapDebugLoc = [&](const DebugLoc &DL) -> DebugLoc {
765  auto *Scope = DL.getScope();
766  MDNode *InlinedAt = DL.getInlinedAt();
767  Scope = remap(Scope);
768  InlinedAt = remap(InlinedAt);
769  return DILocation::get(M.getContext(), DL.getLine(), DL.getCol(),
770  Scope, InlinedAt);
771  };
772 
773  if (I.getDebugLoc() != DebugLoc())
774  I.setDebugLoc(remapDebugLoc(I.getDebugLoc()));
775 
776  // Remap DILocations in llvm.loop attachments.
778  if (auto *Loc = dyn_cast_or_null<DILocation>(MD))
779  return remapDebugLoc(Loc).get();
780  return MD;
781  });
782 
783  // Strip heapallocsite attachments, they point into the DIType system.
784  if (I.hasMetadataOtherThanDebugLoc())
785  I.setMetadata("heapallocsite", nullptr);
786  }
787  }
788  }
789 
790  // Create a new llvm.dbg.cu, which is equivalent to the one
791  // -gline-tables-only would have created.
792  for (auto &NMD : M.getNamedMDList()) {
794  for (MDNode *Op : NMD.operands())
795  Ops.push_back(remap(Op));
796 
797  if (!Changed)
798  continue;
799 
800  NMD.clearOperands();
801  for (auto *Op : Ops)
802  if (Op)
803  NMD.addOperand(Op);
804  }
805  return Changed;
806 }
807 
809  if (auto *Val = mdconst::dyn_extract_or_null<ConstantInt>(
810  M.getModuleFlag("Debug Info Version")))
811  return Val->getZExtValue();
812  return 0;
813 }
814 
816  const DILocation *LocB) {
817  setDebugLoc(DILocation::getMergedLocation(LocA, LocB));
818 }
819 
820 void Instruction::updateLocationAfterHoist() { dropLocation(); }
821 
823  const DebugLoc &DL = getDebugLoc();
824  if (!DL)
825  return;
826 
827  // If this isn't a call, drop the location to allow a location from a
828  // preceding instruction to propagate.
829  if (!isa<CallBase>(this)) {
830  setDebugLoc(DebugLoc());
831  return;
832  }
833 
834  // Set a line 0 location for calls to preserve scope information in case
835  // inlining occurs.
837  if (SP)
838  // If a function scope is available, set it on the line 0 location. When
839  // hoisting a call to a predecessor block, using the function scope avoids
840  // making it look like the callee was reached earlier than it should be.
841  setDebugLoc(DILocation::get(getContext(), 0, 0, SP));
842  else
843  // The parent function has no scope. Go ahead and drop the location. If
844  // the parent function is inlined, and the callee has a subprogram, the
845  // inliner will attach a location to the call.
846  //
847  // One alternative is to set a line 0 location with the existing scope and
848  // inlinedAt info. The location might be sensitive to when inlining occurs.
849  setDebugLoc(DebugLoc());
850 }
851 
852 //===----------------------------------------------------------------------===//
853 // LLVM C API implementations.
854 //===----------------------------------------------------------------------===//
855 
857  switch (lang) {
858 #define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
859  case LLVMDWARFSourceLanguage##NAME: \
860  return ID;
861 #include "llvm/BinaryFormat/Dwarf.def"
862 #undef HANDLE_DW_LANG
863  }
864  llvm_unreachable("Unhandled Tag");
865 }
866 
867 template <typename DIT> DIT *unwrapDI(LLVMMetadataRef Ref) {
868  return (DIT *)(Ref ? unwrap<MDNode>(Ref) : nullptr);
869 }
870 
872  return static_cast<DINode::DIFlags>(Flags);
873 }
874 
876  return static_cast<LLVMDIFlags>(Flags);
877 }
878 
880 pack_into_DISPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized) {
881  return DISubprogram::toSPFlags(IsLocalToUnit, IsDefinition, IsOptimized);
882 }
883 
885  return DEBUG_METADATA_VERSION;
886 }
887 
889  return wrap(new DIBuilder(*unwrap(M), false));
890 }
891 
893  return wrap(new DIBuilder(*unwrap(M)));
894 }
895 
898 }
899 
901  return StripDebugInfo(*unwrap(M));
902 }
903 
905  delete unwrap(Builder);
906 }
907 
909  unwrap(Builder)->finalize();
910 }
911 
913  LLVMMetadataRef subprogram) {
914  unwrap(Builder)->finalizeSubprogram(unwrapDI<DISubprogram>(subprogram));
915 }
916 
919  LLVMMetadataRef FileRef, const char *Producer, size_t ProducerLen,
920  LLVMBool isOptimized, const char *Flags, size_t FlagsLen,
921  unsigned RuntimeVer, const char *SplitName, size_t SplitNameLen,
922  LLVMDWARFEmissionKind Kind, unsigned DWOId, LLVMBool SplitDebugInlining,
923  LLVMBool DebugInfoForProfiling, const char *SysRoot, size_t SysRootLen,
924  const char *SDK, size_t SDKLen) {
925  auto File = unwrapDI<DIFile>(FileRef);
926 
927  return wrap(unwrap(Builder)->createCompileUnit(
929  StringRef(Producer, ProducerLen), isOptimized, StringRef(Flags, FlagsLen),
930  RuntimeVer, StringRef(SplitName, SplitNameLen),
931  static_cast<DICompileUnit::DebugEmissionKind>(Kind), DWOId,
932  SplitDebugInlining, DebugInfoForProfiling,
934  StringRef(SysRoot, SysRootLen), StringRef(SDK, SDKLen)));
935 }
936 
939  size_t FilenameLen, const char *Directory,
940  size_t DirectoryLen) {
941  return wrap(unwrap(Builder)->createFile(StringRef(Filename, FilenameLen),
942  StringRef(Directory, DirectoryLen)));
943 }
944 
947  const char *Name, size_t NameLen,
948  const char *ConfigMacros, size_t ConfigMacrosLen,
949  const char *IncludePath, size_t IncludePathLen,
950  const char *APINotesFile, size_t APINotesFileLen) {
951  return wrap(unwrap(Builder)->createModule(
952  unwrapDI<DIScope>(ParentScope), StringRef(Name, NameLen),
953  StringRef(ConfigMacros, ConfigMacrosLen),
954  StringRef(IncludePath, IncludePathLen),
955  StringRef(APINotesFile, APINotesFileLen)));
956 }
957 
959  LLVMMetadataRef ParentScope,
960  const char *Name, size_t NameLen,
961  LLVMBool ExportSymbols) {
962  return wrap(unwrap(Builder)->createNameSpace(
963  unwrapDI<DIScope>(ParentScope), StringRef(Name, NameLen), ExportSymbols));
964 }
965 
968  size_t NameLen, const char *LinkageName, size_t LinkageNameLen,
969  LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty,
970  LLVMBool IsLocalToUnit, LLVMBool IsDefinition,
971  unsigned ScopeLine, LLVMDIFlags Flags, LLVMBool IsOptimized) {
972  return wrap(unwrap(Builder)->createFunction(
973  unwrapDI<DIScope>(Scope), {Name, NameLen}, {LinkageName, LinkageNameLen},
974  unwrapDI<DIFile>(File), LineNo, unwrapDI<DISubroutineType>(Ty), ScopeLine,
975  map_from_llvmDIFlags(Flags),
976  pack_into_DISPFlags(IsLocalToUnit, IsDefinition, IsOptimized), nullptr,
977  nullptr, nullptr));
978 }
979 
980 
983  LLVMMetadataRef File, unsigned Line, unsigned Col) {
984  return wrap(unwrap(Builder)->createLexicalBlock(unwrapDI<DIScope>(Scope),
985  unwrapDI<DIFile>(File),
986  Line, Col));
987 }
988 
993  unsigned Discriminator) {
994  return wrap(unwrap(Builder)->createLexicalBlockFile(unwrapDI<DIScope>(Scope),
995  unwrapDI<DIFile>(File),
996  Discriminator));
997 }
998 
1002  LLVMMetadataRef NS,
1004  unsigned Line) {
1005  return wrap(unwrap(Builder)->createImportedModule(unwrapDI<DIScope>(Scope),
1006  unwrapDI<DINamespace>(NS),
1007  unwrapDI<DIFile>(File),
1008  Line));
1009 }
1010 
1013  LLVMMetadataRef ImportedEntity, LLVMMetadataRef File, unsigned Line,
1014  LLVMMetadataRef *Elements, unsigned NumElements) {
1015  auto Elts =
1016  (NumElements > 0)
1017  ? unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements})
1018  : nullptr;
1020  unwrapDI<DIScope>(Scope), unwrapDI<DIImportedEntity>(ImportedEntity),
1021  unwrapDI<DIFile>(File), Line, Elts));
1022 }
1023 
1026  LLVMMetadataRef File, unsigned Line, LLVMMetadataRef *Elements,
1027  unsigned NumElements) {
1028  auto Elts =
1029  (NumElements > 0)
1030  ? unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements})
1031  : nullptr;
1033  unwrapDI<DIScope>(Scope), unwrapDI<DIModule>(M), unwrapDI<DIFile>(File),
1034  Line, Elts));
1035 }
1036 
1039  LLVMMetadataRef File, unsigned Line, const char *Name, size_t NameLen,
1040  LLVMMetadataRef *Elements, unsigned NumElements) {
1041  auto Elts =
1042  (NumElements > 0)
1043  ? unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements})
1044  : nullptr;
1045  return wrap(unwrap(Builder)->createImportedDeclaration(
1046  unwrapDI<DIScope>(Scope), unwrapDI<DINode>(Decl), unwrapDI<DIFile>(File),
1047  Line, {Name, NameLen}, Elts));
1048 }
1049 
1052  unsigned Column, LLVMMetadataRef Scope,
1053  LLVMMetadataRef InlinedAt) {
1054  return wrap(DILocation::get(*unwrap(Ctx), Line, Column, unwrap(Scope),
1055  unwrap(InlinedAt)));
1056 }
1057 
1059  return unwrapDI<DILocation>(Location)->getLine();
1060 }
1061 
1063  return unwrapDI<DILocation>(Location)->getColumn();
1064 }
1065 
1067  return wrap(unwrapDI<DILocation>(Location)->getScope());
1068 }
1069 
1071  return wrap(unwrapDI<DILocation>(Location)->getInlinedAt());
1072 }
1073 
1075  return wrap(unwrapDI<DIScope>(Scope)->getFile());
1076 }
1077 
1078 const char *LLVMDIFileGetDirectory(LLVMMetadataRef File, unsigned *Len) {
1079  auto Dir = unwrapDI<DIFile>(File)->getDirectory();
1080  *Len = Dir.size();
1081  return Dir.data();
1082 }
1083 
1084 const char *LLVMDIFileGetFilename(LLVMMetadataRef File, unsigned *Len) {
1085  auto Name = unwrapDI<DIFile>(File)->getFilename();
1086  *Len = Name.size();
1087  return Name.data();
1088 }
1089 
1090 const char *LLVMDIFileGetSource(LLVMMetadataRef File, unsigned *Len) {
1091  if (auto Src = unwrapDI<DIFile>(File)->getSource()) {
1092  *Len = Src->size();
1093  return Src->data();
1094  }
1095  *Len = 0;
1096  return "";
1097 }
1098 
1100  LLVMMetadataRef ParentMacroFile,
1101  unsigned Line,
1103  const char *Name, size_t NameLen,
1104  const char *Value, size_t ValueLen) {
1105  return wrap(
1106  unwrap(Builder)->createMacro(unwrapDI<DIMacroFile>(ParentMacroFile), Line,
1107  static_cast<MacinfoRecordType>(RecordType),
1108  {Name, NameLen}, {Value, ValueLen}));
1109 }
1110 
1113  LLVMMetadataRef ParentMacroFile, unsigned Line,
1115  return wrap(unwrap(Builder)->createTempMacroFile(
1116  unwrapDI<DIMacroFile>(ParentMacroFile), Line, unwrapDI<DIFile>(File)));
1117 }
1118 
1120  const char *Name, size_t NameLen,
1121  int64_t Value,
1122  LLVMBool IsUnsigned) {
1123  return wrap(unwrap(Builder)->createEnumerator({Name, NameLen}, Value,
1124  IsUnsigned != 0));
1125 }
1126 
1129  size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1130  uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef *Elements,
1131  unsigned NumElements, LLVMMetadataRef ClassTy) {
1132 auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1133  NumElements});
1134 return wrap(unwrap(Builder)->createEnumerationType(
1135  unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
1136  LineNumber, SizeInBits, AlignInBits, Elts, unwrapDI<DIType>(ClassTy)));
1137 }
1138 
1141  size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1142  uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags,
1143  LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang,
1144  const char *UniqueId, size_t UniqueIdLen) {
1145  auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1146  NumElements});
1147  return wrap(unwrap(Builder)->createUnionType(
1148  unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
1149  LineNumber, SizeInBits, AlignInBits, map_from_llvmDIFlags(Flags),
1150  Elts, RunTimeLang, {UniqueId, UniqueIdLen}));
1151 }
1152 
1153 
1156  uint32_t AlignInBits, LLVMMetadataRef Ty,
1157  LLVMMetadataRef *Subscripts,
1158  unsigned NumSubscripts) {
1159  auto Subs = unwrap(Builder)->getOrCreateArray({unwrap(Subscripts),
1160  NumSubscripts});
1161  return wrap(unwrap(Builder)->createArrayType(Size, AlignInBits,
1162  unwrapDI<DIType>(Ty), Subs));
1163 }
1164 
1167  uint32_t AlignInBits, LLVMMetadataRef Ty,
1168  LLVMMetadataRef *Subscripts,
1169  unsigned NumSubscripts) {
1170  auto Subs = unwrap(Builder)->getOrCreateArray({unwrap(Subscripts),
1171  NumSubscripts});
1172  return wrap(unwrap(Builder)->createVectorType(Size, AlignInBits,
1173  unwrapDI<DIType>(Ty), Subs));
1174 }
1175 
1178  size_t NameLen, uint64_t SizeInBits,
1179  LLVMDWARFTypeEncoding Encoding,
1180  LLVMDIFlags Flags) {
1181  return wrap(unwrap(Builder)->createBasicType({Name, NameLen},
1182  SizeInBits, Encoding,
1183  map_from_llvmDIFlags(Flags)));
1184 }
1185 
1188  uint64_t SizeInBits, uint32_t AlignInBits, unsigned AddressSpace,
1189  const char *Name, size_t NameLen) {
1190  return wrap(unwrap(Builder)->createPointerType(unwrapDI<DIType>(PointeeTy),
1191  SizeInBits, AlignInBits,
1192  AddressSpace, {Name, NameLen}));
1193 }
1194 
1197  size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1198  uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags,
1199  LLVMMetadataRef DerivedFrom, LLVMMetadataRef *Elements,
1200  unsigned NumElements, unsigned RunTimeLang, LLVMMetadataRef VTableHolder,
1201  const char *UniqueId, size_t UniqueIdLen) {
1202  auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1203  NumElements});
1204  return wrap(unwrap(Builder)->createStructType(
1205  unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
1206  LineNumber, SizeInBits, AlignInBits, map_from_llvmDIFlags(Flags),
1207  unwrapDI<DIType>(DerivedFrom), Elts, RunTimeLang,
1208  unwrapDI<DIType>(VTableHolder), {UniqueId, UniqueIdLen}));
1209 }
1210 
1213  size_t NameLen, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits,
1214  uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags,
1215  LLVMMetadataRef Ty) {
1216  return wrap(unwrap(Builder)->createMemberType(unwrapDI<DIScope>(Scope),
1217  {Name, NameLen}, unwrapDI<DIFile>(File), LineNo, SizeInBits, AlignInBits,
1218  OffsetInBits, map_from_llvmDIFlags(Flags), unwrapDI<DIType>(Ty)));
1219 }
1220 
1223  size_t NameLen) {
1224  return wrap(unwrap(Builder)->createUnspecifiedType({Name, NameLen}));
1225 }
1226 
1230  size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
1231  LLVMMetadataRef Type, LLVMDIFlags Flags, LLVMValueRef ConstantVal,
1232  uint32_t AlignInBits) {
1233  return wrap(unwrap(Builder)->createStaticMemberType(
1234  unwrapDI<DIScope>(Scope), {Name, NameLen},
1235  unwrapDI<DIFile>(File), LineNumber, unwrapDI<DIType>(Type),
1236  map_from_llvmDIFlags(Flags), unwrap<Constant>(ConstantVal),
1237  AlignInBits));
1238 }
1239 
1242  const char *Name, size_t NameLen,
1243  LLVMMetadataRef File, unsigned LineNo,
1244  uint64_t SizeInBits, uint32_t AlignInBits,
1245  uint64_t OffsetInBits, LLVMDIFlags Flags,
1246  LLVMMetadataRef Ty, LLVMMetadataRef PropertyNode) {
1247  return wrap(unwrap(Builder)->createObjCIVar(
1248  {Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1249  SizeInBits, AlignInBits, OffsetInBits,
1250  map_from_llvmDIFlags(Flags), unwrapDI<DIType>(Ty),
1251  unwrapDI<MDNode>(PropertyNode)));
1252 }
1253 
1256  const char *Name, size_t NameLen,
1257  LLVMMetadataRef File, unsigned LineNo,
1258  const char *GetterName, size_t GetterNameLen,
1259  const char *SetterName, size_t SetterNameLen,
1260  unsigned PropertyAttributes,
1261  LLVMMetadataRef Ty) {
1262  return wrap(unwrap(Builder)->createObjCProperty(
1263  {Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1264  {GetterName, GetterNameLen}, {SetterName, SetterNameLen},
1265  PropertyAttributes, unwrapDI<DIType>(Ty)));
1266 }
1267 
1271  return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type)));
1272 }
1273 
1276  const char *Name, size_t NameLen,
1277  LLVMMetadataRef File, unsigned LineNo,
1278  LLVMMetadataRef Scope, uint32_t AlignInBits) {
1279  return wrap(unwrap(Builder)->createTypedef(
1280  unwrapDI<DIType>(Type), {Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1281  unwrapDI<DIScope>(Scope), AlignInBits));
1282 }
1283 
1286  LLVMMetadataRef Ty, LLVMMetadataRef BaseTy,
1287  uint64_t BaseOffset, uint32_t VBPtrOffset,
1288  LLVMDIFlags Flags) {
1289  return wrap(unwrap(Builder)->createInheritance(
1290  unwrapDI<DIType>(Ty), unwrapDI<DIType>(BaseTy),
1291  BaseOffset, VBPtrOffset, map_from_llvmDIFlags(Flags)));
1292 }
1293 
1296  LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
1297  size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
1298  unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
1299  const char *UniqueIdentifier, size_t UniqueIdentifierLen) {
1300  return wrap(unwrap(Builder)->createForwardDecl(
1301  Tag, {Name, NameLen}, unwrapDI<DIScope>(Scope),
1302  unwrapDI<DIFile>(File), Line, RuntimeLang, SizeInBits,
1303  AlignInBits, {UniqueIdentifier, UniqueIdentifierLen}));
1304 }
1305 
1308  LLVMDIBuilderRef Builder, unsigned Tag, const char *Name,
1309  size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line,
1310  unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
1311  LLVMDIFlags Flags, const char *UniqueIdentifier,
1312  size_t UniqueIdentifierLen) {
1313  return wrap(unwrap(Builder)->createReplaceableCompositeType(
1314  Tag, {Name, NameLen}, unwrapDI<DIScope>(Scope),
1315  unwrapDI<DIFile>(File), Line, RuntimeLang, SizeInBits,
1316  AlignInBits, map_from_llvmDIFlags(Flags),
1317  {UniqueIdentifier, UniqueIdentifierLen}));
1318 }
1319 
1323  return wrap(unwrap(Builder)->createQualifiedType(Tag,
1324  unwrapDI<DIType>(Type)));
1325 }
1326 
1330  return wrap(unwrap(Builder)->createReferenceType(Tag,
1331  unwrapDI<DIType>(Type)));
1332 }
1333 
1336  return wrap(unwrap(Builder)->createNullPtrType());
1337 }
1338 
1341  LLVMMetadataRef PointeeType,
1342  LLVMMetadataRef ClassType,
1343  uint64_t SizeInBits,
1344  uint32_t AlignInBits,
1345  LLVMDIFlags Flags) {
1346  return wrap(unwrap(Builder)->createMemberPointerType(
1347  unwrapDI<DIType>(PointeeType),
1348  unwrapDI<DIType>(ClassType), AlignInBits, SizeInBits,
1349  map_from_llvmDIFlags(Flags)));
1350 }
1351 
1355  const char *Name, size_t NameLen,
1356  LLVMMetadataRef File, unsigned LineNumber,
1357  uint64_t SizeInBits,
1358  uint64_t OffsetInBits,
1359  uint64_t StorageOffsetInBits,
1360  LLVMDIFlags Flags, LLVMMetadataRef Type) {
1361  return wrap(unwrap(Builder)->createBitFieldMemberType(
1362  unwrapDI<DIScope>(Scope), {Name, NameLen},
1363  unwrapDI<DIFile>(File), LineNumber,
1364  SizeInBits, OffsetInBits, StorageOffsetInBits,
1365  map_from_llvmDIFlags(Flags), unwrapDI<DIType>(Type)));
1366 }
1367 
1369  LLVMMetadataRef Scope, const char *Name, size_t NameLen,
1370  LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
1371  uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags,
1372  LLVMMetadataRef DerivedFrom,
1373  LLVMMetadataRef *Elements, unsigned NumElements,
1374  LLVMMetadataRef VTableHolder, LLVMMetadataRef TemplateParamsNode,
1375  const char *UniqueIdentifier, size_t UniqueIdentifierLen) {
1376  auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1377  NumElements});
1378  return wrap(unwrap(Builder)->createClassType(
1379  unwrapDI<DIScope>(Scope), {Name, NameLen},
1380  unwrapDI<DIFile>(File), LineNumber,
1381  SizeInBits, AlignInBits, OffsetInBits,
1382  map_from_llvmDIFlags(Flags), unwrapDI<DIType>(DerivedFrom),
1383  Elts, unwrapDI<DIType>(VTableHolder),
1384  unwrapDI<MDNode>(TemplateParamsNode),
1385  {UniqueIdentifier, UniqueIdentifierLen}));
1386 }
1387 
1391  return wrap(unwrap(Builder)->createArtificialType(unwrapDI<DIType>(Type)));
1392 }
1393 
1394 const char *LLVMDITypeGetName(LLVMMetadataRef DType, size_t *Length) {
1395  StringRef Str = unwrap<DIType>(DType)->getName();
1396  *Length = Str.size();
1397  return Str.data();
1398 }
1399 
1401  return unwrapDI<DIType>(DType)->getSizeInBits();
1402 }
1403 
1405  return unwrapDI<DIType>(DType)->getOffsetInBits();
1406 }
1407 
1409  return unwrapDI<DIType>(DType)->getAlignInBits();
1410 }
1411 
1413  return unwrapDI<DIType>(DType)->getLine();
1414 }
1415 
1417  return map_to_llvmDIFlags(unwrapDI<DIType>(DType)->getFlags());
1418 }
1419 
1421  LLVMMetadataRef *Types,
1422  size_t Length) {
1423  return wrap(
1424  unwrap(Builder)->getOrCreateTypeArray({unwrap(Types), Length}).get());
1425 }
1426 
1430  LLVMMetadataRef *ParameterTypes,
1431  unsigned NumParameterTypes,
1432  LLVMDIFlags Flags) {
1433  auto Elts = unwrap(Builder)->getOrCreateTypeArray({unwrap(ParameterTypes),
1434  NumParameterTypes});
1435  return wrap(unwrap(Builder)->createSubroutineType(
1436  Elts, map_from_llvmDIFlags(Flags)));
1437 }
1438 
1440  int64_t *Addr, size_t Length) {
1441  return wrap(unwrap(Builder)->createExpression(ArrayRef<int64_t>(Addr,
1442  Length)));
1443 }
1444 
1447  int64_t Value) {
1448  return wrap(unwrap(Builder)->createConstantValueExpression(Value));
1449 }
1450 
1453  size_t NameLen, const char *Linkage, size_t LinkLen, LLVMMetadataRef File,
1454  unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
1455  LLVMMetadataRef Expr, LLVMMetadataRef Decl, uint32_t AlignInBits) {
1456  return wrap(unwrap(Builder)->createGlobalVariableExpression(
1457  unwrapDI<DIScope>(Scope), {Name, NameLen}, {Linkage, LinkLen},
1458  unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
1459  true, unwrap<DIExpression>(Expr), unwrapDI<MDNode>(Decl),
1460  nullptr, AlignInBits));
1461 }
1462 
1464  return wrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getVariable());
1465 }
1466 
1468  LLVMMetadataRef GVE) {
1469  return wrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getExpression());
1470 }
1471 
1473  return wrap(unwrapDI<DIVariable>(Var)->getFile());
1474 }
1475 
1477  return wrap(unwrapDI<DIVariable>(Var)->getScope());
1478 }
1479 
1481  return unwrapDI<DIVariable>(Var)->getLine();
1482 }
1483 
1485  size_t Count) {
1486  return wrap(
1487  MDTuple::getTemporary(*unwrap(Ctx), {unwrap(Data), Count}).release());
1488 }
1489 
1491  MDNode::deleteTemporary(unwrapDI<MDNode>(TempNode));
1492 }
1493 
1495  LLVMMetadataRef Replacement) {
1496  auto *Node = unwrapDI<MDNode>(TargetMetadata);
1497  Node->replaceAllUsesWith(unwrap<Metadata>(Replacement));
1499 }
1500 
1503  size_t NameLen, const char *Linkage, size_t LnkLen, LLVMMetadataRef File,
1504  unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
1505  LLVMMetadataRef Decl, uint32_t AlignInBits) {
1506  return wrap(unwrap(Builder)->createTempGlobalVariableFwdDecl(
1507  unwrapDI<DIScope>(Scope), {Name, NameLen}, {Linkage, LnkLen},
1508  unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
1509  unwrapDI<MDNode>(Decl), nullptr, AlignInBits));
1510 }
1511 
1514  LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
1515  LLVMMetadataRef DL, LLVMValueRef Instr) {
1516  return wrap(unwrap(Builder)->insertDeclare(
1517  unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1518  unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
1519  unwrap<Instruction>(Instr)));
1520 }
1521 
1525  return wrap(unwrap(Builder)->insertDeclare(
1526  unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1527  unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
1528  unwrap(Block)));
1529 }
1530 
1532  LLVMValueRef Val,
1533  LLVMMetadataRef VarInfo,
1534  LLVMMetadataRef Expr,
1536  LLVMValueRef Instr) {
1537  return wrap(unwrap(Builder)->insertDbgValueIntrinsic(
1538  unwrap(Val), unwrap<DILocalVariable>(VarInfo),
1539  unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
1540  unwrap<Instruction>(Instr)));
1541 }
1542 
1544  LLVMValueRef Val,
1545  LLVMMetadataRef VarInfo,
1546  LLVMMetadataRef Expr,
1548  LLVMBasicBlockRef Block) {
1549  return wrap(unwrap(Builder)->insertDbgValueIntrinsic(
1550  unwrap(Val), unwrap<DILocalVariable>(VarInfo),
1551  unwrap<DIExpression>(Expr), unwrap<DILocation>(DebugLoc),
1552  unwrap(Block)));
1553 }
1554 
1557  size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty,
1558  LLVMBool AlwaysPreserve, LLVMDIFlags Flags, uint32_t AlignInBits) {
1559  return wrap(unwrap(Builder)->createAutoVariable(
1560  unwrap<DIScope>(Scope), {Name, NameLen}, unwrap<DIFile>(File),
1561  LineNo, unwrap<DIType>(Ty), AlwaysPreserve,
1562  map_from_llvmDIFlags(Flags), AlignInBits));
1563 }
1564 
1567  size_t NameLen, unsigned ArgNo, LLVMMetadataRef File, unsigned LineNo,
1568  LLVMMetadataRef Ty, LLVMBool AlwaysPreserve, LLVMDIFlags Flags) {
1569  return wrap(unwrap(Builder)->createParameterVariable(
1570  unwrap<DIScope>(Scope), {Name, NameLen}, ArgNo, unwrap<DIFile>(File),
1571  LineNo, unwrap<DIType>(Ty), AlwaysPreserve,
1572  map_from_llvmDIFlags(Flags)));
1573 }
1574 
1576  int64_t Lo, int64_t Count) {
1577  return wrap(unwrap(Builder)->getOrCreateSubrange(Lo, Count));
1578 }
1579 
1581  LLVMMetadataRef *Data,
1582  size_t Length) {
1583  Metadata **DataValue = unwrap(Data);
1584  return wrap(unwrap(Builder)->getOrCreateArray({DataValue, Length}).get());
1585 }
1586 
1588  return wrap(unwrap<Function>(Func)->getSubprogram());
1589 }
1590 
1592  unwrap<Function>(Func)->setSubprogram(unwrap<DISubprogram>(SP));
1593 }
1594 
1596  return unwrapDI<DISubprogram>(Subprogram)->getLine();
1597 }
1598 
1600  return wrap(unwrap<Instruction>(Inst)->getDebugLoc().getAsMDNode());
1601 }
1602 
1604  if (Loc)
1605  unwrap<Instruction>(Inst)->setDebugLoc(DebugLoc(unwrap<MDNode>(Loc)));
1606  else
1607  unwrap<Instruction>(Inst)->setDebugLoc(DebugLoc());
1608 }
1609 
1611  switch(unwrap(Metadata)->getMetadataID()) {
1612 #define HANDLE_METADATA_LEAF(CLASS) \
1613  case Metadata::CLASS##Kind: \
1614  return (LLVMMetadataKind)LLVM##CLASS##MetadataKind;
1615 #include "llvm/IR/Metadata.def"
1616  default:
1618  }
1619 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::DIType::getScope
DIScope * getScope() const
Definition: DebugInfoMetadata.h:707
LLVMDWARFTypeEncoding
unsigned LLVMDWARFTypeEncoding
An LLVM DWARF type encoding.
Definition: DebugInfo.h:172
i
i
Definition: README.txt:29
LLVMDIVariableGetFile
LLVMMetadataRef LLVMDIVariableGetFile(LLVMMetadataRef Var)
Get the metadata of the file associated with a given variable.
Definition: DebugInfo.cpp:1472
llvm::StripDebugInfo
bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
Definition: DebugInfo.cpp:476
LLVMDIBuilderCreatePointerType
LLVMMetadataRef LLVMDIBuilderCreatePointerType(LLVMDIBuilderRef Builder, LLVMMetadataRef PointeeTy, uint64_t SizeInBits, uint32_t AlignInBits, unsigned AddressSpace, const char *Name, size_t NameLen)
Create debugging information entry for a pointer.
Definition: DebugInfo.cpp:1186
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::DIType
Base class for types.
Definition: DebugInfoMetadata.h:662
LLVMDIBuilderCreateAutoVariable
LLVMMetadataRef LLVMDIBuilderCreateAutoVariable(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool AlwaysPreserve, LLVMDIFlags Flags, uint32_t AlignInBits)
Create a new descriptor for a local auto variable.
Definition: DebugInfo.cpp:1555
LLVMDITypeGetOffsetInBits
uint64_t LLVMDITypeGetOffsetInBits(LLVMMetadataRef DType)
Get the offset of this DIType in bits.
Definition: DebugInfo.cpp:1404
LLVMContextRef
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
Definition: Types.h:53
llvm::DILocalScope::getSubprogram
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
Definition: DebugInfoMetadata.cpp:814
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::AArch64CC::AL
@ AL
Definition: AArch64BaseInfo.h:269
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:153
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1421
llvm::dwarf
Definition: Dwarf.h:35
LLVMDIBuilderCreateNullPtrType
LLVMMetadataRef LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder)
Create C++11 nullptr type.
Definition: DebugInfo.cpp:1335
Metadata.h
llvm::GVMaterializer
Definition: GVMaterializer.h:28
llvm::DebugInfoFinder::reset
void reset()
Clear all lists.
Definition: DebugInfo.cpp:139
IntrinsicInst.h
llvm::DIBuilder
Definition: DIBuilder.h:41
llvm::DILocation::getMergedLocation
static const DILocation * getMergedLocation(const DILocation *LocA, const DILocation *LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
Definition: DebugInfoMetadata.cpp:100
DebugInfoMetadata.h
LLVMDIBuilderCreateFunction
LLVMMetadataRef LLVMDIBuilderCreateFunction(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, const char *LinkageName, size_t LinkageNameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool IsLocalToUnit, LLVMBool IsDefinition, unsigned ScopeLine, LLVMDIFlags Flags, LLVMBool IsOptimized)
Create a new descriptor for the specified subprogram.
Definition: DebugInfo.cpp:966
T
llvm::Function
Definition: Function.h:62
getFunction
static Function * getFunction(Constant *C)
Definition: Evaluator.cpp:255
llvm::DenseMapBase< DenseMap< KeyT, ValueT, 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
StringRef.h
LLVMDIVariableGetLine
unsigned LLVMDIVariableGetLine(LLVMMetadataRef Var)
Get the source line where this DIVariable is declared.
Definition: DebugInfo.cpp:1480
LLVMDIBuilderCreateClassType
LLVMMetadataRef LLVMDIBuilderCreateClassType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef DerivedFrom, LLVMMetadataRef *Elements, unsigned NumElements, LLVMMetadataRef VTableHolder, LLVMMetadataRef TemplateParamsNode, const char *UniqueIdentifier, size_t UniqueIdentifierLen)
Create debugging information entry for a class.
Definition: DebugInfo.cpp:1368
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
LLVMDITypeGetLine
unsigned LLVMDITypeGetLine(LLVMMetadataRef DType)
Get the source line where this DIType is declared.
Definition: DebugInfo.cpp:1412
llvm::FunctionLoweringInfo::StatepointRelocationRecord
Helper object to track which of three possible relocation mechanisms are used for a particular value ...
Definition: FunctionLoweringInfo.h:95
LLVMDITypeGetSizeInBits
uint64_t LLVMDITypeGetSizeInBits(LLVMMetadataRef DType)
Get the size of this DIType in bits.
Definition: DebugInfo.cpp:1400
llvm::Function::getSubprogram
DISubprogram * getSubprogram() const
Get the attached subprogram.
Definition: Metadata.cpp:1541
llvm::MipsISD::Lo
@ Lo
Definition: MipsISelLowering.h:79
LLVMDIBuilderCreateModule
LLVMMetadataRef LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope, const char *Name, size_t NameLen, const char *ConfigMacros, size_t ConfigMacrosLen, const char *IncludePath, size_t IncludePathLen, const char *APINotesFile, size_t APINotesFileLen)
Creates a new descriptor for a module with the specified parent scope.
Definition: DebugInfo.cpp:946
LLVMDIBuilderCreateSubroutineType
LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder, LLVMMetadataRef File, LLVMMetadataRef *ParameterTypes, unsigned NumParameterTypes, LLVMDIFlags Flags)
Create subroutine type.
Definition: DebugInfo.cpp:1428
llvm::findDbgUsers
void findDbgUsers(SmallVectorImpl< DbgVariableIntrinsic * > &DbgInsts, Value *V)
Finds the debug info intrinsics describing a value.
Definition: DebugInfo.cpp:102
LLVMDIGlobalVariableExpressionGetExpression
LLVMMetadataRef LLVMDIGlobalVariableExpressionGetExpression(LLVMMetadataRef GVE)
Retrieves the DIExpression associated with this global variable expression.
Definition: DebugInfo.cpp:1467
LLVMDIBuilderGetOrCreateSubrange
LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, int64_t Lo, int64_t Count)
Create a descriptor for a value range.
Definition: DebugInfo.cpp:1575
LLVMDIBuilderCreateUnspecifiedType
LLVMMetadataRef LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen)
Create a DWARF unspecified type.
Definition: DebugInfo.cpp:1222
LLVMDIBuilderCreateTypedef
LLVMMetadataRef LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Scope, uint32_t AlignInBits)
Create debugging information entry for a typedef.
Definition: DebugInfo.cpp:1275
llvm::DIScope::getName
StringRef getName() const
Definition: DebugInfoMetadata.cpp:261
LLVMDisposeTemporaryMDNode
void LLVMDisposeTemporaryMDNode(LLVMMetadataRef TempNode)
Deallocate a temporary node.
Definition: DebugInfo.cpp:1490
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1580
llvm::getDISubprogram
DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Definition: DebugInfo.cpp:129
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
DenseMap.h
llvm::AtomicOrderingCABI::release
@ release
LLVMInstructionSetDebugLoc
void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc)
Set the debug location for the given instruction.
Definition: DebugInfo.cpp:1603
Module.h
llvm::DbgVariableIntrinsic::getVariable
DILocalVariable * getVariable() const
Definition: IntrinsicInst.h:253
LLVMDIBuilderCreateUnionType
LLVMMetadataRef LLVMDIBuilderCreateUnionType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags, LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang, const char *UniqueId, size_t UniqueIdLen)
Create debugging information entry for a union.
Definition: DebugInfo.cpp:1139
LLVMMetadataKind
unsigned LLVMMetadataKind
Definition: DebugInfo.h:167
LLVMDIBuilderCreateObjectPointerType
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder, LLVMMetadataRef Type)
Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
Definition: DebugInfo.cpp:1269
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:449
llvm::FindDbgAddrUses
TinyPtrVector< DbgVariableIntrinsic * > FindDbgAddrUses(Value *V)
Finds all intrinsics declaring local variables as living in the memory that 'V' points to.
Definition: DebugInfo.cpp:46
LLVMDIBuilderGetOrCreateTypeArray
LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder, LLVMMetadataRef *Types, size_t Length)
Create a type array.
Definition: DebugInfo.cpp:1420
LLVMSetSubprogram
void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP)
Set the subprogram attached to a function.
Definition: DebugInfo.cpp:1591
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
LLVMDIFileGetSource
const char * LLVMDIFileGetSource(LLVMMetadataRef File, unsigned *Len)
Get the source of a given file.
Definition: DebugInfo.cpp:1090
STLExtras.h
llvm::dwarf::Tag
Tag
Definition: Dwarf.h:104
llvm::DINameKind::LinkageName
@ LinkageName
map_from_llvmDWARFsourcelanguage
static unsigned map_from_llvmDWARFsourcelanguage(LLVMDWARFSourceLanguage lang)
Definition: DebugInfo.cpp:856
LLVMDisposeDIBuilder
void LLVMDisposeDIBuilder(LLVMDIBuilderRef Builder)
Deallocates the DIBuilder and everything it owns.
Definition: DebugInfo.cpp:904
LLVMDIBuilderInsertDeclareBefore
LLVMValueRef LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMValueRef Instr)
Insert a new llvm.dbg.declare intrinsic call before the given instruction.
Definition: DebugInfo.cpp:1513
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::DICompileUnit::DebugEmissionKind
DebugEmissionKind
Definition: DebugInfoMetadata.h:1340
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::count_if
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
Definition: STLExtras.h:1641
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
LLVMDIBuilderCreateImportedModuleFromNamespace
LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromNamespace(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef NS, LLVMMetadataRef File, unsigned Line)
Create a descriptor for an imported namespace.
Definition: DebugInfo.cpp:1000
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1233
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::MDNode::getNumOperands
unsigned getNumOperands() const
Return number of MDNode operands.
Definition: Metadata.h:1143
LLVMDIBuilderCreateNameSpace
LLVMMetadataRef LLVMDIBuilderCreateNameSpace(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope, const char *Name, size_t NameLen, LLVMBool ExportSymbols)
Creates a new descriptor for a namespace with the specified parent scope.
Definition: DebugInfo.cpp:958
Instruction.h
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:1551
LLVMDIVariableGetScope
LLVMMetadataRef LLVMDIVariableGetScope(LLVMMetadataRef Var)
Get the metadata of the scope associated with a given variable.
Definition: DebugInfo.cpp:1476
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
Constants.h
LLVMDIBuilderCreateReplaceableCompositeType
LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType(LLVMDIBuilderRef Builder, unsigned Tag, const char *Name, size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags, const char *UniqueIdentifier, size_t UniqueIdentifierLen)
Create a temporary forward-declared type.
Definition: DebugInfo.cpp:1307
llvm::DbgValueInst
This represents the llvm.dbg.value instruction.
Definition: IntrinsicInst.h:347
llvm::User
Definition: User.h:44
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::NamedMDNode::getName
StringRef getName() const
Definition: Metadata.cpp:1141
LLVMDILocationGetScope
LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location)
Get the local scope associated with this debug location.
Definition: DebugInfo.cpp:1066
llvm::DICompileUnit::LineTablesOnly
@ LineTablesOnly
Definition: DebugInfoMetadata.h:1343
LLVMDIBuilderCreateEnumerator
LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, int64_t Value, LLVMBool IsUnsigned)
Create debugging information entry for an enumerator.
Definition: DebugInfo.cpp:1119
LLVMDIBuilderFinalize
void LLVMDIBuilderFinalize(LLVMDIBuilderRef Builder)
Construct any deferred debug info descriptors.
Definition: DebugInfo.cpp:908
llvm::TinyPtrVector::push_back
void push_back(EltTy NewVal)
Definition: TinyPtrVector.h:244
LLVMDITypeGetAlignInBits
uint32_t LLVMDITypeGetAlignInBits(LLVMMetadataRef DType)
Get the alignment of this DIType in bits.
Definition: DebugInfo.cpp:1408
llvm::DISubprogram::DISPFlags
DISPFlags
Debug info subprogram flags.
Definition: DebugInfoMetadata.h:1835
llvm::MDTuple
Tuple of metadata.
Definition: Metadata.h:1174
LLVMBasicBlockRef
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
Represents a basic block of instructions in LLVM IR.
Definition: Types.h:82
llvm::Instruction::applyMergedLocation
void applyMergedLocation(const DILocation *LocA, const DILocation *LocB)
Merge 2 debug locations and apply it to the Instruction.
Definition: DebugInfo.cpp:815
map_to_llvmDIFlags
static LLVMDIFlags map_to_llvmDIFlags(DINode::DIFlags Flags)
Definition: DebugInfo.cpp:875
GVMaterializer.h
DenseSet.h
llvm::Instruction
Definition: Instruction.h:45
llvm::FindDbgDeclareUses
TinyPtrVector< DbgDeclareInst * > FindDbgDeclareUses(Value *V)
Like FindDbgAddrUses, but only returns dbg.declare intrinsics, not dbg.addr.
Definition: DebugInfo.cpp:68
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:257
llvm::stripDebugInfo
bool stripDebugInfo(Function &F)
Definition: DebugInfo.cpp:441
LLVMDIBuilderCreateTempMacroFile
LLVMMetadataRef LLVMDIBuilderCreateTempMacroFile(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentMacroFile, unsigned Line, LLVMMetadataRef File)
Create debugging information temporary entry for a macro file.
Definition: DebugInfo.cpp:1112
LLVMDIBuilderCreateBasicType
LLVMMetadataRef LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, uint64_t SizeInBits, LLVMDWARFTypeEncoding Encoding, LLVMDIFlags Flags)
Create debugging information entry for a basic type.
Definition: DebugInfo.cpp:1177
DebugLoc.h
SmallPtrSet.h
createImportedModule
static DIImportedEntity * createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context, Metadata *NS, DIFile *File, unsigned Line, StringRef Name, DINodeArray Elements, SmallVectorImpl< TrackingMDNodeRef > &AllImportedModules)
Definition: DIBuilder.cpp:166
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::DEBUG_METADATA_VERSION
@ DEBUG_METADATA_VERSION
Definition: Metadata.h:52
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
stripDebugLocFromLoopID
static MDNode * stripDebugLocFromLoopID(MDNode *N)
Definition: DebugInfo.cpp:405
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::PassSummaryAction::Import
@ Import
Import information from summary.
LLVMDILocationGetLine
unsigned LLVMDILocationGetLine(LLVMMetadataRef Location)
Get the line number of this debug location.
Definition: DebugInfo.cpp:1058
LLVMDIBuilderCreateMacro
LLVMMetadataRef LLVMDIBuilderCreateMacro(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentMacroFile, unsigned Line, LLVMDWARFMacinfoRecordType RecordType, const char *Name, size_t NameLen, const char *Value, size_t ValueLen)
Create debugging information entry for a macro.
Definition: DebugInfo.cpp:1099
llvm::LocalAsMetadata::getIfExists
static LocalAsMetadata * getIfExists(Value *Local)
Definition: Metadata.h:449
unwrapDI
DIT * unwrapDI(LLVMMetadataRef Ref)
Definition: DebugInfo.cpp:867
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::DebugInfoFinder::processSubprogram
void processSubprogram(DISubprogram *SP)
Process subprogram.
Definition: DebugInfo.cpp:258
llvm::MDNode::getOperand
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:1137
LLVMDIBuilderCreateEnumerationType
LLVMMetadataRef LLVMDIBuilderCreateEnumerationType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef *Elements, unsigned NumElements, LLVMMetadataRef ClassTy)
Create debugging information entry for an enumeration.
Definition: DebugInfo.cpp:1127
LLVMDIBuilderCreateConstantValueExpression
LLVMMetadataRef LLVMDIBuilderCreateConstantValueExpression(LLVMDIBuilderRef Builder, int64_t Value)
Create a new descriptor for the specified variable that does not have an address, but does have a con...
Definition: DebugInfo.cpp:1446
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
BasicBlock.h
LLVMDIBuilderCreateInheritance
LLVMMetadataRef LLVMDIBuilderCreateInheritance(LLVMDIBuilderRef Builder, LLVMMetadataRef Ty, LLVMMetadataRef BaseTy, uint64_t BaseOffset, uint32_t VBPtrOffset, LLVMDIFlags Flags)
Create debugging information entry to establish inheritance relationship between two types.
Definition: DebugInfo.cpp:1285
llvm::DbgVariableIntrinsic
This is the common base class for debug info intrinsics for variables.
Definition: IntrinsicInst.h:148
LLVMDIBuilderCreateArrayType
LLVMMetadataRef LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts)
Create debugging information entry for an array.
Definition: DebugInfo.cpp:1155
LLVMDIFlags
LLVMDIFlags
This file declares the C API endpoints for generating DWARF Debug Info.
Definition: DebugInfo.h:27
LLVMInstructionGetDebugLoc
LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst)
Get the debug location for the given instruction.
Definition: DebugInfo.cpp:1599
uint64_t
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
LLVMDIGlobalVariableExpressionGetVariable
LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE)
Retrieves the DIVariable associated with this global variable expression.
Definition: DebugInfo.cpp:1463
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:80
DebugInfo.h
LLVMDIBuilderGetOrCreateArray
LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder, LLVMMetadataRef *Data, size_t Length)
Create an array of DI Nodes.
Definition: DebugInfo.cpp:1580
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::DenseMap
Definition: DenseMap.h:714
LLVMDIBuilderInsertDbgValueBefore
LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr)
Insert a new llvm.dbg.value intrinsic call before the given instruction.
Definition: DebugInfo.cpp:1531
DebugInfo.h
LLVMDIBuilderCreateMemberType
LLVMMetadataRef LLVMDIBuilderCreateMemberType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef Ty)
Create debugging information entry for a member.
Definition: DebugInfo.cpp:1211
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::make_early_inc_range
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition: STLExtras.h:576
DIBuilder.h
llvm::DICompileUnit
Compile unit.
Definition: DebugInfoMetadata.h:1335
llvm::findDbgValues
void findDbgValues(SmallVectorImpl< DbgValueInst * > &DbgValues, Value *V)
Finds the llvm.dbg.value intrinsics describing a value.
Definition: DebugInfo.cpp:76
LLVMDIBuilderInsertDbgValueAtEnd
LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block)
Insert a new llvm.dbg.value intrinsic call at the end of the given basic block.
Definition: DebugInfo.cpp:1543
llvm::Instruction::updateLocationAfterHoist
void updateLocationAfterHoist()
Updates the debug location given that the instruction has been hoisted from a block to a predecessor ...
Definition: DebugInfo.cpp:820
llvm::Instruction::dropLocation
void dropLocation()
Drop the instruction's debug location.
Definition: DebugInfo.cpp:822
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVMDIBuilderInsertDeclareAtEnd
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block)
Insert a new llvm.dbg.declare intrinsic call at the end of the given basic block.
Definition: DebugInfo.cpp:1522
llvm::DebugInfoFinder::processModule
void processModule(const Module &M)
Process entire module and collect debug info anchors.
Definition: DebugInfo.cpp:148
LLVMDIBuilderCreateObjCProperty
LLVMMetadataRef LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, const char *GetterName, size_t GetterNameLen, const char *SetterName, size_t SetterNameLen, unsigned PropertyAttributes, LLVMMetadataRef Ty)
Create debugging information entry for Objective-C property.
Definition: DebugInfo.cpp:1255
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:906
LLVMDIBuilderCreateImportedDeclaration
LLVMMetadataRef LLVMDIBuilderCreateImportedDeclaration(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef Decl, LLVMMetadataRef File, unsigned Line, const char *Name, size_t NameLen, LLVMMetadataRef *Elements, unsigned NumElements)
Create a descriptor for an imported function, type, or variable.
Definition: DebugInfo.cpp:1037
LLVMDIBuilderCreateParameterVariable
LLVMMetadataRef LLVMDIBuilderCreateParameterVariable(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, unsigned ArgNo, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool AlwaysPreserve, LLVMDIFlags Flags)
Create a new descriptor for a function parameter variable.
Definition: DebugInfo.cpp:1565
LLVMDebugMetadataVersion
unsigned LLVMDebugMetadataVersion()
The current debug metadata version number.
Definition: DebugInfo.cpp:884
llvm::SmallPtrSetImpl::count
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition: SmallPtrSet.h:382
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:650
llvm::DebugInfoFinder::processLocation
void processLocation(const Module &M, const DILocation *Loc)
Process debug info location.
Definition: DebugInfo.cpp:201
isDILocationReachable
static bool isDILocationReachable(SmallPtrSetImpl< Metadata * > &Visited, SmallPtrSetImpl< Metadata * > &Reachable, Metadata *MD)
Return true if a node is a DILocation or if a DILocation is indirectly referenced by one of the node'...
Definition: DebugInfo.cpp:385
llvm::DISubroutineType
Type array for a subprogram.
Definition: DebugInfoMetadata.h:1281
llvm::wrap
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:252
getDebugLoc
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first found DebugLoc that has a DILocation, given a range of instructions.
Definition: MachineInstrBundle.cpp:109
LLVMTemporaryMDNode
LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef Ctx, LLVMMetadataRef *Data, size_t Count)
Create a new temporary MDNode.
Definition: DebugInfo.cpp:1484
llvm::DIScope::getScope
DIScope * getScope() const
Definition: DebugInfoMetadata.cpp:237
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
None.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::DINode
Tagged DWARF-like metadata node.
Definition: DebugInfoMetadata.h:127
updateLoopMetadataDebugLocationsImpl
static MDNode * updateLoopMetadataDebugLocationsImpl(MDNode *OrigLoopID, function_ref< Metadata *(Metadata *)> Updater)
Definition: DebugInfo.cpp:350
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
LLVMDIBuilderCreateExpression
LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Builder, int64_t *Addr, size_t Length)
Create a new descriptor for the specified variable which has a complex address expression for its add...
Definition: DebugInfo.cpp:1439
llvm::DebugInfoFinder::processVariable
void processVariable(const Module &M, const DbgVariableIntrinsic &DVI)
Process DbgVariableIntrinsic.
Definition: DebugInfo.cpp:281
LLVMDIBuilderCreateTempGlobalVariableFwdDecl
LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, const char *Linkage, size_t LnkLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit, LLVMMetadataRef Decl, uint32_t AlignInBits)
Create a new descriptor for the specified global variable that is temporary and meant to be RAUWed.
Definition: DebugInfo.cpp:1501
LLVMGetMetadataKind
LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata)
Obtain the enumerated type of a Metadata instance.
Definition: DebugInfo.cpp:1610
LLVMDIFileGetDirectory
const char * LLVMDIFileGetDirectory(LLVMMetadataRef File, unsigned *Len)
Get the directory of a given file.
Definition: DebugInfo.cpp:1078
uint32_t
LLVMGenericDINodeMetadataKind
@ LLVMGenericDINodeMetadataKind
Definition: DebugInfo.h:139
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:990
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
LLVMDILocationGetInlinedAt
LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location)
Get the "inline at" location associated with this debug location.
Definition: DebugInfo.cpp:1070
LLVMDIBuilderCreateGlobalVariableExpression
LLVMMetadataRef LLVMDIBuilderCreateGlobalVariableExpression(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, const char *Linkage, size_t LinkLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit, LLVMMetadataRef Expr, LLVMMetadataRef Decl, uint32_t AlignInBits)
Create a new descriptor for the specified variable.
Definition: DebugInfo.cpp:1451
llvm::updateLoopMetadataDebugLocations
void updateLoopMetadataDebugLocations(Instruction &I, function_ref< Metadata *(Metadata *)> Updater)
Update the debug locations contained within the MD_loop metadata attached to the instruction I,...
Definition: DebugInfo.cpp:374
LLVMDIBuilderCreateObjCIVar
LLVMMetadataRef LLVMDIBuilderCreateObjCIVar(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef Ty, LLVMMetadataRef PropertyNode)
Create debugging information entry for Objective-C instance variable.
Definition: DebugInfo.cpp:1241
llvm::MDTuple::getTemporary
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a temporary node.
Definition: Metadata.h:1220
llvm::MDNode::getDistinct
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1241
LLVMDIBuilderCreateCompileUnit
LLVMMetadataRef LLVMDIBuilderCreateCompileUnit(LLVMDIBuilderRef Builder, LLVMDWARFSourceLanguage Lang, LLVMMetadataRef FileRef, const char *Producer, size_t ProducerLen, LLVMBool isOptimized, const char *Flags, size_t FlagsLen, unsigned RuntimeVer, const char *SplitName, size_t SplitNameLen, LLVMDWARFEmissionKind Kind, unsigned DWOId, LLVMBool SplitDebugInlining, LLVMBool DebugInfoForProfiling, const char *SysRoot, size_t SysRootLen, const char *SDK, size_t SDKLen)
A CompileUnit provides an anchor for all debugging information generated during this instance of comp...
Definition: DebugInfo.cpp:917
pack_into_DISPFlags
static DISubprogram::DISPFlags pack_into_DISPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized)
Definition: DebugInfo.cpp:880
LLVMDIBuilderCreateReferenceType
LLVMMetadataRef LLVMDIBuilderCreateReferenceType(LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type)
Create debugging information entry for a c++ style reference or rvalue reference type.
Definition: DebugInfo.cpp:1328
LLVMDIBuilderCreateLexicalBlock
LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned Col)
Create a descriptor for a lexical block with the specified parent context.
Definition: DebugInfo.cpp:981
llvm::MDNode::getContext
LLVMContext & getContext() const
Definition: Metadata.h:967
llvm::MDNode::isDistinct
bool isDistinct() const
Definition: Metadata.h:986
LLVMDIBuilderCreateMemberPointerType
LLVMMetadataRef LLVMDIBuilderCreateMemberPointerType(LLVMDIBuilderRef Builder, LLVMMetadataRef PointeeType, LLVMMetadataRef ClassType, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags)
Create debugging information entry for a pointer to member.
Definition: DebugInfo.cpp:1340
LLVMDIFileGetFilename
const char * LLVMDIFileGetFilename(LLVMMetadataRef File, unsigned *Len)
Get the name of a given file.
Definition: DebugInfo.cpp:1084
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
LLVMDIBuilderCreateImportedModuleFromModule
LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromModule(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef M, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef *Elements, unsigned NumElements)
Create a descriptor for an imported module.
Definition: DebugInfo.cpp:1024
LLVMBool
int LLVMBool
Definition: Types.h:28
llvm::DIScope
Base class for scope-like contexts.
Definition: DebugInfoMetadata.h:476
get
Should compile to something r4 addze r3 instead we get
Definition: README.txt:24
getFlags
static uint32_t getFlags(const Symbol *Sym)
Definition: TapiFile.cpp:23
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:324
Casting.h
Function.h
LLVMDILocationGetColumn
unsigned LLVMDILocationGetColumn(LLVMMetadataRef Location)
Get the column number of this debug location.
Definition: DebugInfo.cpp:1062
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::DISubprogram::toSPFlags
static DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, unsigned Virtuality=SPFlagNonvirtual, bool IsMainSubprogram=false)
Definition: DebugInfoMetadata.h:1855
LLVMDISubprogramGetLine
unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram)
Get the line associated with a given subprogram.
Definition: DebugInfo.cpp:1595
LLVMDIBuilderCreateFile
LLVMMetadataRef LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const char *Filename, size_t FilenameLen, const char *Directory, size_t DirectoryLen)
Create a file descriptor to hold debugging information for a file.
Definition: DebugInfo.cpp:938
LLVMDIBuilderCreateForwardDecl
LLVMMetadataRef LLVMDIBuilderCreateForwardDecl(LLVMDIBuilderRef Builder, unsigned Tag, const char *Name, size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits, const char *UniqueIdentifier, size_t UniqueIdentifierLen)
Create a permanent forward-declared type.
Definition: DebugInfo.cpp:1295
LLVMDWARFMacinfoRecordType
LLVMDWARFMacinfoRecordType
Describes the kind of macro declaration used for LLVMDIBuilderCreateMacro.
Definition: DebugInfo.h:179
LLVMDIBuilderCreateQualifiedType
LLVMMetadataRef LLVMDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type)
Create debugging information entry for a qualified type, e.g.
Definition: DebugInfo.cpp:1321
llvm::DICompileUnit::DebugNameTableKind::Default
@ Default
llvm::MDNode::deleteTemporary
static void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
Definition: Metadata.cpp:849
LLVMDIBuilderCreateDebugLocation
LLVMMetadataRef LLVMDIBuilderCreateDebugLocation(LLVMContextRef Ctx, unsigned Line, unsigned Column, LLVMMetadataRef Scope, LLVMMetadataRef InlinedAt)
Creates a new DebugLocation that describes a source location.
Definition: DebugInfo.cpp:1051
llvm::DIGlobalVariableExpression
A pair of DIGlobalVariable and DIExpression.
Definition: DebugInfoMetadata.h:3401
llvm::MDNode::replaceOperandWith
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
Definition: Metadata.cpp:877
LLVMDITypeGetName
const char * LLVMDITypeGetName(LLVMMetadataRef DType, size_t *Length)
Get the name of this DIType.
Definition: DebugInfo.cpp:1394
LLVMDIBuilderCreateVectorType
LLVMMetadataRef LLVMDIBuilderCreateVectorType(LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts)
Create debugging information entry for a vector type.
Definition: DebugInfo.cpp:1166
LLVMDIBuilderRef
struct LLVMOpaqueDIBuilder * LLVMDIBuilderRef
Represents an LLVM debug info builder.
Definition: Types.h:117
llvm::MetadataAsValue::getIfExists
static MetadataAsValue * getIfExists(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:114
SmallVector.h
llvm::DINode::DIFlags
DIFlags
Debug info flags.
Definition: DebugInfoMetadata.h:166
llvm::Value::isUsedByMetadata
bool isUsedByMetadata() const
Return true if there is metadata referencing this value.
Definition: Value.h:557
LLVMGetSubprogram
LLVMMetadataRef LLVMGetSubprogram(LLVMValueRef Func)
Get the metadata of the subprogram attached to a function.
Definition: DebugInfo.cpp:1587
N
#define N
llvm::stripNonLineTableDebugInfo
bool stripNonLineTableDebugInfo(Module &M)
Downgrade the debug info in a module to contain only line table information.
Definition: DebugInfo.cpp:711
LLVMDIBuilderCreateStructType
LLVMMetadataRef LLVMDIBuilderCreateStructType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags, LLVMMetadataRef DerivedFrom, LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang, LLVMMetadataRef VTableHolder, const char *UniqueId, size_t UniqueIdLen)
Create debugging information entry for a struct.
Definition: DebugInfo.cpp:1195
LLVMDWARFSourceLanguage
LLVMDWARFSourceLanguage
Source languages known by DWARF.
Definition: DebugInfo.h:71
getSubprogram
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&... Args)
Definition: DIBuilder.cpp:819
LLVMDITypeGetFlags
LLVMDIFlags LLVMDITypeGetFlags(LLVMMetadataRef DType)
Get the flags associated with this DIType.
Definition: DebugInfo.cpp:1416
llvm::DISubprogram
Subprogram description.
Definition: DebugInfoMetadata.h:1820
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
LLVMDWARFEmissionKind
LLVMDWARFEmissionKind
The amount of debug information to emit.
Definition: DebugInfo.h:121
LLVMDIBuilderFinalizeSubprogram
void LLVMDIBuilderFinalizeSubprogram(LLVMDIBuilderRef Builder, LLVMMetadataRef subprogram)
Finalize a specific subprogram.
Definition: DebugInfo.cpp:912
LLVMValueRef
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition: Types.h:75
LLVMStripModuleDebugInfo
LLVMBool LLVMStripModuleDebugInfo(LLVMModuleRef M)
Strip debug info in the module if it exists.
Definition: DebugInfo.cpp:900
llvm::SmallPtrSetImpl
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:343
llvm::getDebugMetadataVersionFromModule
unsigned getDebugMetadataVersionFromModule(const Module &M)
Return Debug Info Metadata Version by checking module flags.
Definition: DebugInfo.cpp:808
LLVMDIBuilderCreateStaticMemberType
LLVMMetadataRef LLVMDIBuilderCreateStaticMemberType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, LLVMMetadataRef Type, LLVMDIFlags Flags, LLVMValueRef ConstantVal, uint32_t AlignInBits)
Create debugging information entry for a C++ static data member.
Definition: DebugInfo.cpp:1228
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
LLVMContext.h
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
LLVMDIScopeGetFile
LLVMMetadataRef LLVMDIScopeGetFile(LLVMMetadataRef Scope)
Get the metadata of the file associated with a given scope.
Definition: DebugInfo.cpp:1074
llvm::TinyPtrVector
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
Definition: TinyPtrVector.h:30
llvm::DebugInfoFinder::processInstruction
void processInstruction(const Module &M, const Instruction &I)
Process a single instruction and collect debug info anchors.
Definition: DebugInfo.cpp:192
LLVMDIBuilderCreateImportedModuleFromAlias
LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromAlias(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef ImportedEntity, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef *Elements, unsigned NumElements)
Create a descriptor for an imported module that aliases another imported entity descriptor.
Definition: DebugInfo.cpp:1011
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition: SmallVector.h:624
LLVMMetadataRef
struct LLVMOpaqueMetadata * LLVMMetadataRef
Represents an LLVM Metadata.
Definition: Types.h:89
LLVMGetModuleDebugMetadataVersion
unsigned LLVMGetModuleDebugMetadataVersion(LLVMModuleRef M)
The version of debug metadata that's present in the provided Module.
Definition: DebugInfo.cpp:896
map_from_llvmDIFlags
static DINode::DIFlags map_from_llvmDIFlags(LLVMDIFlags Flags)
Definition: DebugInfo.cpp:871
CU
Definition: AArch64AsmBackend.cpp:501
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::MDOperand::get
Metadata * get() const
Definition: Metadata.h:764
llvm::Value::users
iterator_range< user_iterator > users()
Definition: Value.h:421
File
Instrumentation for Order File
Definition: InstrOrderFile.cpp:205
LLVMDIBuilderCreateBitFieldMemberType
LLVMMetadataRef LLVMDIBuilderCreateBitFieldMemberType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef Type)
Create debugging information entry for a bit field member.
Definition: DebugInfo.cpp:1353
LLVMCreateDIBuilder
LLVMDIBuilderRef LLVMCreateDIBuilder(LLVMModuleRef M)
Construct a builder for a module and collect unresolved nodes attached to the module in order to reso...
Definition: DebugInfo.cpp:892
LLVMCreateDIBuilderDisallowUnresolved
LLVMDIBuilderRef LLVMCreateDIBuilderDisallowUnresolved(LLVMModuleRef M)
Construct a builder for a module, and do not allow for unresolved nodes attached to the module.
Definition: DebugInfo.cpp:888
llvm::MDOperand
Tracking metadata reference owned by Metadata.
Definition: Metadata.h:753
LLVMMetadataReplaceAllUsesWith
void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef TargetMetadata, LLVMMetadataRef Replacement)
Replace all uses of temporary metadata.
Definition: DebugInfo.cpp:1494
llvm::DIScope::getFile
DIFile * getFile() const
Definition: DebugInfoMetadata.h:484
LLVMModuleRef
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:61
LLVMDIBuilderCreateArtificialType
LLVMMetadataRef LLVMDIBuilderCreateArtificialType(LLVMDIBuilderRef Builder, LLVMMetadataRef Type)
Create a uniqued DIType* clone with FlagArtificial set.
Definition: DebugInfo.cpp:1389
llvm::SmallPtrSetImpl::insert
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:364
llvm::dwarf::MacinfoRecordType
MacinfoRecordType
Definition: Dwarf.h:379
LLVMDIBuilderCreateLexicalBlockFile
LLVMMetadataRef LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Discriminator)
Create a descriptor for a lexical block with a new file attached.
Definition: DebugInfo.cpp:990