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