Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.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 "LLVMContextImpl.h"
16#include "llvm/ADT/DenseMap.h"
17#include "llvm/ADT/DenseSet.h"
18#include "llvm/ADT/STLExtras.h"
19#include "llvm/ADT/SmallPtrSet.h"
20#include "llvm/ADT/SmallVector.h"
21#include "llvm/ADT/StringRef.h"
22#include "llvm/IR/BasicBlock.h"
23#include "llvm/IR/Constants.h"
24#include "llvm/IR/DIBuilder.h"
25#include "llvm/IR/DebugInfo.h"
26#include "llvm/IR/DebugInfoMetadata.h"
27#include "llvm/IR/DebugLoc.h"
28#include "llvm/IR/DebugProgramInstruction.h"
29#include "llvm/IR/Function.h"
30#include "llvm/IR/GVMaterializer.h"
31#include "llvm/IR/Instruction.h"
32#include "llvm/IR/IntrinsicInst.h"
33#include "llvm/IR/LLVMContext.h"
34#include "llvm/IR/Metadata.h"
35#include "llvm/IR/Module.h"
36#include "llvm/IR/PassManager.h"
37#include "llvm/Support/Casting.h"
38#include <algorithm>
39#include <cassert>
40#include <optional>
41#include <utility>
42
43using namespacellvm;
44using namespacellvm::at;
45using namespacellvm::dwarf;
46
47TinyPtrVector<DbgDeclareInst *>llvm::findDbgDeclares(Value *V) {
48// This function is hot. Check whether the value has any metadata to avoid a
49// DenseMap lookup. This check is a bitfield datamember lookup.
50if (!V->isUsedByMetadata())
51return {};
52auto *L =LocalAsMetadata::getIfExists(V);
53if (!L)
54return {};
55auto *MDV =MetadataAsValue::getIfExists(V->getContext(), L);
56if (!MDV)
57return {};
58
59TinyPtrVector<DbgDeclareInst *> Declares;
60for (User *U : MDV->users())
61if (auto *DDI = dyn_cast<DbgDeclareInst>(U))
62 Declares.push_back(DDI);
63
64return Declares;
65}
66TinyPtrVector<DbgVariableRecord *>llvm::findDVRDeclares(Value *V) {
67// This function is hot. Check whether the value has any metadata to avoid a
68// DenseMap lookup. This check is a bitfield datamember lookup.
69if (!V->isUsedByMetadata())
70return {};
71auto *L =LocalAsMetadata::getIfExists(V);
72if (!L)
73return {};
74
75TinyPtrVector<DbgVariableRecord *> Declares;
76for (DbgVariableRecord *DVR : L->getAllDbgVariableRecordUsers())
77if (DVR->getType() == DbgVariableRecord::LocationType::Declare)
78 Declares.push_back(DVR);
79
80return Declares;
81}
82
83TinyPtrVector<DbgVariableRecord *>llvm::findDVRValues(Value *V) {
84// This function is hot. Check whether the value has any metadata to avoid a
85// DenseMap lookup. This check is a bitfield datamember lookup.
86if (!V->isUsedByMetadata())
87return {};
88auto *L =LocalAsMetadata::getIfExists(V);
89if (!L)
90return {};
91
92TinyPtrVector<DbgVariableRecord *> Values;
93for (DbgVariableRecord *DVR : L->getAllDbgVariableRecordUsers())
94if (DVR->isValueOfVariable())
95 Values.push_back(DVR);
96
97return Values;
98}
99
100template <typename IntrinsicT,bool DbgAssignAndValuesOnly>
101staticvoid
102findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result,Value *V,
103SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords) {
104// This function is hot. Check whether the value has any metadata to avoid a
105// DenseMap lookup.
106if (!V->isUsedByMetadata())
107return;
108
109LLVMContext &Ctx = V->getContext();
110// TODO: If this value appears multiple times in a DIArgList, we should still
111// only add the owning DbgValueInst once; use this set to track ArgListUsers.
112// This behaviour can be removed when we can automatically remove duplicates.
113// V will also appear twice in a dbg.assign if its used in the both the value
114// and address components.
115SmallPtrSet<IntrinsicT *, 4> EncounteredIntrinsics;
116SmallPtrSet<DbgVariableRecord *, 4> EncounteredDbgVariableRecords;
117
118 /// Append IntrinsicT users of MetadataAsValue(MD).
119auto AppendUsers = [&Ctx, &EncounteredIntrinsics,
120 &EncounteredDbgVariableRecords, &Result,
121 DbgVariableRecords](Metadata *MD) {
122if (auto *MDV =MetadataAsValue::getIfExists(Ctx, MD)) {
123for (User *U : MDV->users())
124if (IntrinsicT *DVI = dyn_cast<IntrinsicT>(U))
125if (EncounteredIntrinsics.insert(DVI).second)
126 Result.push_back(DVI);
127 }
128if (!DbgVariableRecords)
129return;
130// Get DbgVariableRecords that use this as a single value.
131if (LocalAsMetadata *L = dyn_cast<LocalAsMetadata>(MD)) {
132for (DbgVariableRecord *DVR : L->getAllDbgVariableRecordUsers()) {
133if (!DbgAssignAndValuesOnly || DVR->isDbgValue() || DVR->isDbgAssign())
134if (EncounteredDbgVariableRecords.insert(DVR).second)
135 DbgVariableRecords->push_back(DVR);
136 }
137 }
138 };
139
140if (auto *L =LocalAsMetadata::getIfExists(V)) {
141 AppendUsers(L);
142for (Metadata *AL : L->getAllArgListUsers()) {
143 AppendUsers(AL);
144if (!DbgVariableRecords)
145continue;
146DIArgList *DI = cast<DIArgList>(AL);
147for (DbgVariableRecord *DVR : DI->getAllDbgVariableRecordUsers())
148if (!DbgAssignAndValuesOnly || DVR->isDbgValue() || DVR->isDbgAssign())
149if (EncounteredDbgVariableRecords.insert(DVR).second)
150 DbgVariableRecords->push_back(DVR);
151 }
152 }
153}
154
155voidllvm::findDbgValues(
156SmallVectorImpl<DbgValueInst *> &DbgValues,Value *V,
157SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords) {
158findDbgIntrinsics<DbgValueInst,/*DbgAssignAndValuesOnly=*/true>(
159 DbgValues, V, DbgVariableRecords);
160}
161
162voidllvm::findDbgUsers(
163SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers,Value *V,
164SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords) {
165findDbgIntrinsics<DbgVariableIntrinsic,/*DbgAssignAndValuesOnly=*/false>(
166 DbgUsers, V, DbgVariableRecords);
167}
168
169DISubprogram *llvm::getDISubprogram(constMDNode *Scope) {
170if (auto *LocalScope = dyn_cast_or_null<DILocalScope>(Scope))
171return LocalScope->getSubprogram();
172returnnullptr;
173}
174
175DebugLocllvm::getDebugValueLoc(DbgVariableIntrinsic *DII) {
176// Original dbg.declare must have a location.
177constDebugLoc &DeclareLoc = DII->getDebugLoc();
178MDNode *Scope = DeclareLoc.getScope();
179DILocation *InlinedAt = DeclareLoc.getInlinedAt();
180// Because no machine insts can come from debug intrinsics, only the scope
181// and inlinedAt is significant. Zero line numbers are used in case this
182// DebugLoc leaks into any adjacent instructions. Produce an unknown location
183// with the correct scope / inlinedAt fields.
184return DILocation::get(DII->getContext(), 0, 0, Scope, InlinedAt);
185}
186
187DebugLocllvm::getDebugValueLoc(DbgVariableRecord *DVR) {
188// Original dbg.declare must have a location.
189constDebugLoc &DeclareLoc = DVR->getDebugLoc();
190MDNode *Scope = DeclareLoc.getScope();
191DILocation *InlinedAt = DeclareLoc.getInlinedAt();
192// Because no machine insts can come from debug intrinsics, only the scope
193// and inlinedAt is significant. Zero line numbers are used in case this
194// DebugLoc leaks into any adjacent instructions. Produce an unknown location
195// with the correct scope / inlinedAt fields.
196return DILocation::get(DVR->getContext(), 0, 0, Scope, InlinedAt);
197}
198
199//===----------------------------------------------------------------------===//
200// DebugInfoFinder implementations.
201//===----------------------------------------------------------------------===//
202
203voidDebugInfoFinder::reset() {
204 CUs.clear();
205 SPs.clear();
206 GVs.clear();
207 TYs.clear();
208 Scopes.clear();
209 NodesSeen.clear();
210}
211
212voidDebugInfoFinder::processModule(constModule &M) {
213for (auto *CU : M.debug_compile_units())
214 processCompileUnit(CU);
215for (auto &F : M.functions()) {
216if (auto *SP = cast_or_null<DISubprogram>(F.getSubprogram()))
217processSubprogram(SP);
218// There could be subprograms from inlined functions referenced from
219// instructions only. Walk the function to find them.
220for (constBasicBlock &BB :F)
221for (constInstruction &I : BB)
222processInstruction(M,I);
223 }
224}
225
226void DebugInfoFinder::processCompileUnit(DICompileUnit *CU) {
227if (!addCompileUnit(CU))
228return;
229for (auto *DIG :CU->getGlobalVariables()) {
230if (!addGlobalVariable(DIG))
231continue;
232auto *GV = DIG->getVariable();
233 processScope(GV->getScope());
234 processType(GV->getType());
235 }
236for (auto *ET :CU->getEnumTypes())
237 processType(ET);
238for (auto *RT :CU->getRetainedTypes())
239if (auto *T = dyn_cast<DIType>(RT))
240 processType(T);
241else
242processSubprogram(cast<DISubprogram>(RT));
243for (auto *Import :CU->getImportedEntities()) {
244auto *Entity =Import->getEntity();
245if (auto *T = dyn_cast<DIType>(Entity))
246 processType(T);
247elseif (auto *SP = dyn_cast<DISubprogram>(Entity))
248processSubprogram(SP);
249elseif (auto *NS = dyn_cast<DINamespace>(Entity))
250 processScope(NS->getScope());
251elseif (auto *M = dyn_cast<DIModule>(Entity))
252 processScope(M->getScope());
253 }
254}
255
256voidDebugInfoFinder::processInstruction(constModule &M,
257constInstruction &I) {
258if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&I))
259processVariable(M, DVI->getVariable());
260
261if (auto DbgLoc =I.getDebugLoc())
262processLocation(M, DbgLoc.get());
263
264for (constDbgRecord &DPR :I.getDbgRecordRange())
265processDbgRecord(M, DPR);
266}
267
268voidDebugInfoFinder::processLocation(constModule &M,constDILocation *Loc) {
269if (!Loc)
270return;
271 processScope(Loc->getScope());
272processLocation(M, Loc->getInlinedAt());
273}
274
275voidDebugInfoFinder::processDbgRecord(constModule &M,constDbgRecord &DR) {
276if (constDbgVariableRecord *DVR = dyn_cast<const DbgVariableRecord>(&DR))
277processVariable(M, DVR->getVariable());
278processLocation(M, DR.getDebugLoc().get());
279}
280
281void DebugInfoFinder::processType(DIType *DT) {
282if (!addType(DT))
283return;
284 processScope(DT->getScope());
285if (auto *ST = dyn_cast<DISubroutineType>(DT)) {
286for (DIType *Ref : ST->getTypeArray())
287 processType(Ref);
288return;
289 }
290if (auto *DCT = dyn_cast<DICompositeType>(DT)) {
291 processType(DCT->getBaseType());
292for (Metadata *D : DCT->getElements()) {
293if (auto *T = dyn_cast<DIType>(D))
294 processType(T);
295elseif (auto *SP = dyn_cast<DISubprogram>(D))
296processSubprogram(SP);
297 }
298return;
299 }
300if (auto *DDT = dyn_cast<DIDerivedType>(DT)) {
301 processType(DDT->getBaseType());
302 }
303}
304
305void DebugInfoFinder::processScope(DIScope *Scope) {
306if (!Scope)
307return;
308if (auto *Ty = dyn_cast<DIType>(Scope)) {
309 processType(Ty);
310return;
311 }
312if (auto *CU = dyn_cast<DICompileUnit>(Scope)) {
313 addCompileUnit(CU);
314return;
315 }
316if (auto *SP = dyn_cast<DISubprogram>(Scope)) {
317processSubprogram(SP);
318return;
319 }
320if (!addScope(Scope))
321return;
322if (auto *LB = dyn_cast<DILexicalBlockBase>(Scope)) {
323 processScope(LB->getScope());
324 }elseif (auto *NS = dyn_cast<DINamespace>(Scope)) {
325 processScope(NS->getScope());
326 }elseif (auto *M = dyn_cast<DIModule>(Scope)) {
327 processScope(M->getScope());
328 }
329}
330
331voidDebugInfoFinder::processSubprogram(DISubprogram *SP) {
332if (!addSubprogram(SP))
333return;
334 processScope(SP->getScope());
335// Some of the users, e.g. CloneFunctionInto / CloneModule, need to set up a
336// ValueMap containing identity mappings for all of the DICompileUnit's, not
337// just DISubprogram's, referenced from anywhere within the Function being
338// cloned prior to calling MapMetadata / RemapInstruction to avoid their
339// duplication later as DICompileUnit's are also directly referenced by
340// llvm.dbg.cu list. Thefore we need to collect DICompileUnit's here as well.
341// Also, DICompileUnit's may reference DISubprogram's too and therefore need
342// to be at least looked through.
343 processCompileUnit(SP->getUnit());
344 processType(SP->getType());
345for (auto *Element : SP->getTemplateParams()) {
346if (auto *TType = dyn_cast<DITemplateTypeParameter>(Element)) {
347 processType(TType->getType());
348 }elseif (auto *TVal = dyn_cast<DITemplateValueParameter>(Element)) {
349 processType(TVal->getType());
350 }
351 }
352}
353
354voidDebugInfoFinder::processVariable(constModule &M,
355constDILocalVariable *DV) {
356if (!NodesSeen.insert(DV).second)
357return;
358 processScope(DV->getScope());
359 processType(DV->getType());
360}
361
362bool DebugInfoFinder::addType(DIType *DT) {
363if (!DT)
364returnfalse;
365
366if (!NodesSeen.insert(DT).second)
367returnfalse;
368
369 TYs.push_back(const_cast<DIType *>(DT));
370returntrue;
371}
372
373bool DebugInfoFinder::addCompileUnit(DICompileUnit *CU) {
374if (!CU)
375returnfalse;
376if (!NodesSeen.insert(CU).second)
377returnfalse;
378
379 CUs.push_back(CU);
380returntrue;
381}
382
383bool DebugInfoFinder::addGlobalVariable(DIGlobalVariableExpression *DIG) {
384if (!NodesSeen.insert(DIG).second)
385returnfalse;
386
387 GVs.push_back(DIG);
388returntrue;
389}
390
391bool DebugInfoFinder::addSubprogram(DISubprogram *SP) {
392if (!SP)
393returnfalse;
394
395if (!NodesSeen.insert(SP).second)
396returnfalse;
397
398 SPs.push_back(SP);
399returntrue;
400}
401
402bool DebugInfoFinder::addScope(DIScope *Scope) {
403if (!Scope)
404returnfalse;
405// FIXME: Ocaml binding generates a scope with no content, we treat it
406// as null for now.
407if (Scope->getNumOperands() == 0)
408returnfalse;
409if (!NodesSeen.insert(Scope).second)
410returnfalse;
411 Scopes.push_back(Scope);
412returntrue;
413}
414
415staticMDNode *updateLoopMetadataDebugLocationsImpl(
416MDNode *OrigLoopID,function_ref<Metadata *(Metadata *)> Updater) {
417assert(OrigLoopID && OrigLoopID->getNumOperands() > 0 &&
418"Loop ID needs at least one operand");
419assert(OrigLoopID && OrigLoopID->getOperand(0).get() == OrigLoopID &&
420"Loop ID should refer to itself");
421
422// Save space for the self-referential LoopID.
423SmallVector<Metadata *, 4> MDs = {nullptr};
424
425for (unsigned i = 1; i < OrigLoopID->getNumOperands(); ++i) {
426Metadata *MD = OrigLoopID->getOperand(i);
427if (!MD)
428 MDs.push_back(nullptr);
429elseif (Metadata *NewMD = Updater(MD))
430 MDs.push_back(NewMD);
431 }
432
433MDNode *NewLoopID =MDNode::getDistinct(OrigLoopID->getContext(), MDs);
434// Insert the self-referential LoopID.
435 NewLoopID->replaceOperandWith(0, NewLoopID);
436return NewLoopID;
437}
438
439voidllvm::updateLoopMetadataDebugLocations(
440Instruction &I,function_ref<Metadata *(Metadata *)> Updater) {
441MDNode *OrigLoopID =I.getMetadata(LLVMContext::MD_loop);
442if (!OrigLoopID)
443return;
444MDNode *NewLoopID =updateLoopMetadataDebugLocationsImpl(OrigLoopID, Updater);
445I.setMetadata(LLVMContext::MD_loop, NewLoopID);
446}
447
448/// Return true if a node is a DILocation or if a DILocation is
449/// indirectly referenced by one of the node's children.
450staticboolisDILocationReachable(SmallPtrSetImpl<Metadata *> &Visited,
451SmallPtrSetImpl<Metadata *> &Reachable,
452Metadata *MD) {
453MDNode *N = dyn_cast_or_null<MDNode>(MD);
454if (!N)
455returnfalse;
456if (isa<DILocation>(N) || Reachable.count(N))
457returntrue;
458if (!Visited.insert(N).second)
459returnfalse;
460for (auto &OpIt :N->operands()) {
461Metadata *Op = OpIt.get();
462if (isDILocationReachable(Visited, Reachable,Op)) {
463// Don't return just yet as we want to visit all MD's children to
464// initialize DILocationReachable in stripDebugLocFromLoopID
465 Reachable.insert(N);
466 }
467 }
468return Reachable.count(N);
469}
470
471staticboolisAllDILocation(SmallPtrSetImpl<Metadata *> &Visited,
472SmallPtrSetImpl<Metadata *> &AllDILocation,
473constSmallPtrSetImpl<Metadata *> &DIReachable,
474Metadata *MD) {
475MDNode *N = dyn_cast_or_null<MDNode>(MD);
476if (!N)
477returnfalse;
478if (isa<DILocation>(N) || AllDILocation.count(N))
479returntrue;
480if (!DIReachable.count(N))
481returnfalse;
482if (!Visited.insert(N).second)
483returnfalse;
484for (auto &OpIt :N->operands()) {
485Metadata *Op = OpIt.get();
486if (Op == MD)
487continue;
488if (!isAllDILocation(Visited, AllDILocation, DIReachable,Op)) {
489returnfalse;
490 }
491 }
492 AllDILocation.insert(N);
493returntrue;
494}
495
496staticMetadata *
497stripLoopMDLoc(constSmallPtrSetImpl<Metadata *> &AllDILocation,
498constSmallPtrSetImpl<Metadata *> &DIReachable,Metadata *MD) {
499if (isa<DILocation>(MD) || AllDILocation.count(MD))
500returnnullptr;
501
502if (!DIReachable.count(MD))
503return MD;
504
505MDNode *N = dyn_cast_or_null<MDNode>(MD);
506if (!N)
507return MD;
508
509SmallVector<Metadata *, 4> Args;
510bool HasSelfRef =false;
511for (unsigned i = 0; i <N->getNumOperands(); ++i) {
512Metadata *A =N->getOperand(i);
513if (!A) {
514 Args.push_back(nullptr);
515 }elseif (A == MD) {
516assert(i == 0 &&"expected i==0 for self-reference");
517 HasSelfRef =true;
518 Args.push_back(nullptr);
519 }elseif (Metadata *NewArg =
520stripLoopMDLoc(AllDILocation, DIReachable,A)) {
521 Args.push_back(NewArg);
522 }
523 }
524if (Args.empty() || (HasSelfRef && Args.size() == 1))
525returnnullptr;
526
527MDNode *NewMD =N->isDistinct() ?MDNode::getDistinct(N->getContext(), Args)
528 :MDNode::get(N->getContext(), Args);
529if (HasSelfRef)
530 NewMD->replaceOperandWith(0, NewMD);
531return NewMD;
532}
533
534staticMDNode *stripDebugLocFromLoopID(MDNode *N) {
535assert(!N->operands().empty() &&"Missing self reference?");
536SmallPtrSet<Metadata *, 8> Visited, DILocationReachable, AllDILocation;
537// If we already visited N, there is nothing to do.
538if (!Visited.insert(N).second)
539returnN;
540
541// If there is no debug location, we do not have to rewrite this
542// MDNode. This loop also initializes DILocationReachable, later
543// needed by updateLoopMetadataDebugLocationsImpl; the use of
544// count_if avoids an early exit.
545if (!llvm::count_if(llvm::drop_begin(N->operands()),
546 [&Visited, &DILocationReachable](constMDOperand &Op) {
547 return isDILocationReachable(
548 Visited, DILocationReachable, Op.get());
549 }))
550returnN;
551
552 Visited.clear();
553// If there is only the debug location without any actual loop metadata, we
554// can remove the metadata.
555if (llvm::all_of(llvm::drop_begin(N->operands()),
556 [&Visited, &AllDILocation,
557 &DILocationReachable](constMDOperand &Op) {
558 return isAllDILocation(Visited, AllDILocation,
559 DILocationReachable, Op.get());
560 }))
561returnnullptr;
562
563returnupdateLoopMetadataDebugLocationsImpl(
564N, [&AllDILocation, &DILocationReachable](Metadata *MD) ->Metadata * {
565returnstripLoopMDLoc(AllDILocation, DILocationReachable, MD);
566 });
567}
568
569boolllvm::stripDebugInfo(Function &F) {
570bool Changed =false;
571if (F.hasMetadata(LLVMContext::MD_dbg)) {
572 Changed =true;
573F.setSubprogram(nullptr);
574 }
575
576DenseMap<MDNode *, MDNode *> LoopIDsMap;
577for (BasicBlock &BB :F) {
578for (Instruction &I :llvm::make_early_inc_range(BB)) {
579if (isa<DbgInfoIntrinsic>(&I)) {
580I.eraseFromParent();
581 Changed =true;
582continue;
583 }
584if (I.getDebugLoc()) {
585 Changed =true;
586I.setDebugLoc(DebugLoc());
587 }
588if (auto *LoopID =I.getMetadata(LLVMContext::MD_loop)) {
589auto *NewLoopID = LoopIDsMap.lookup(LoopID);
590if (!NewLoopID)
591 NewLoopID = LoopIDsMap[LoopID] =stripDebugLocFromLoopID(LoopID);
592if (NewLoopID != LoopID)
593I.setMetadata(LLVMContext::MD_loop, NewLoopID);
594 }
595// Strip other attachments that are or use debug info.
596if (I.hasMetadataOtherThanDebugLoc()) {
597// Heapallocsites point into the DIType system.
598I.setMetadata("heapallocsite",nullptr);
599// DIAssignID are debug info metadata primitives.
600I.setMetadata(LLVMContext::MD_DIAssignID,nullptr);
601 }
602I.dropDbgRecords();
603 }
604 }
605return Changed;
606}
607
608boolllvm::StripDebugInfo(Module &M) {
609bool Changed =false;
610
611for (NamedMDNode &NMD :llvm::make_early_inc_range(M.named_metadata())) {
612// We're stripping debug info, and without them, coverage information
613// doesn't quite make sense.
614if (NMD.getName().starts_with("llvm.dbg.") ||
615 NMD.getName() =="llvm.gcov") {
616 NMD.eraseFromParent();
617 Changed =true;
618 }
619 }
620
621for (Function &F : M)
622 Changed |=stripDebugInfo(F);
623
624for (auto &GV : M.globals()) {
625 Changed |= GV.eraseMetadata(LLVMContext::MD_dbg);
626 }
627
628if (GVMaterializer *Materializer = M.getMaterializer())
629 Materializer->setStripDebugInfo();
630
631return Changed;
632}
633
634namespace{
635
636/// Helper class to downgrade -g metadata to -gline-tables-only metadata.
637classDebugTypeInfoRemoval {
638DenseMap<Metadata *, Metadata *> Replacements;
639
640public:
641 /// The (void)() type.
642MDNode *EmptySubroutineType;
643
644private:
645 /// Remember what linkage name we originally had before stripping. If we end
646 /// up making two subprograms identical who originally had different linkage
647 /// names, then we need to make one of them distinct, to avoid them getting
648 /// uniqued. Maps the new node to the old linkage name.
649DenseMap<DISubprogram *, StringRef> NewToLinkageName;
650
651// TODO: Remember the distinct subprogram we created for a given linkage name,
652// so that we can continue to unique whenever possible. Map <newly created
653// node, old linkage name> to the first (possibly distinct) mdsubprogram
654// created for that combination. This is not strictly needed for correctness,
655// but can cut down on the number of MDNodes and let us diff cleanly with the
656// output of -gline-tables-only.
657
658public:
659 DebugTypeInfoRemoval(LLVMContext &C)
660 : EmptySubroutineType(DISubroutineType::get(C,DINode::FlagZero, 0,
661MDNode::get(C, {}))) {}
662
663Metadata *map(Metadata *M) {
664if (!M)
665returnnullptr;
666auto Replacement = Replacements.find(M);
667if (Replacement != Replacements.end())
668return Replacement->second;
669
670returnM;
671 }
672MDNode *mapNode(Metadata *N) {return dyn_cast_or_null<MDNode>(map(N)); }
673
674 /// Recursively remap N and all its referenced children. Does a DF post-order
675 /// traversal, so as to remap bottoms up.
676void traverseAndRemap(MDNode *N) { traverse(N); }
677
678private:
679// Create a new DISubprogram, to replace the one given.
680DISubprogram *getReplacementSubprogram(DISubprogram *MDS) {
681auto *FileAndScope = cast_or_null<DIFile>(map(MDS->getFile()));
682StringRefLinkageName = MDS->getName().empty() ? MDS->getLinkageName() :"";
683DISubprogram *Declaration =nullptr;
684auto *Type = cast_or_null<DISubroutineType>(map(MDS->getType()));
685DIType *ContainingType =
686 cast_or_null<DIType>(map(MDS->getContainingType()));
687auto *Unit = cast_or_null<DICompileUnit>(map(MDS->getUnit()));
688auto Variables =nullptr;
689auto TemplateParams =nullptr;
690
691// Make a distinct DISubprogram, for situations that warrent it.
692auto distinctMDSubprogram = [&]() {
693return DISubprogram::getDistinct(
694 MDS->getContext(), FileAndScope, MDS->getName(),LinkageName,
695 FileAndScope, MDS->getLine(),Type, MDS->getScopeLine(),
696 ContainingType, MDS->getVirtualIndex(), MDS->getThisAdjustment(),
697 MDS->getFlags(), MDS->getSPFlags(), Unit, TemplateParams, Declaration,
698 Variables);
699 };
700
701if (MDS->isDistinct())
702return distinctMDSubprogram();
703
704auto *NewMDS = DISubprogram::get(
705 MDS->getContext(), FileAndScope, MDS->getName(),LinkageName,
706 FileAndScope, MDS->getLine(),Type, MDS->getScopeLine(), ContainingType,
707 MDS->getVirtualIndex(), MDS->getThisAdjustment(), MDS->getFlags(),
708 MDS->getSPFlags(), Unit, TemplateParams, Declaration, Variables);
709
710StringRef OldLinkageName = MDS->getLinkageName();
711
712// See if we need to make a distinct one.
713auto OrigLinkage = NewToLinkageName.find(NewMDS);
714if (OrigLinkage != NewToLinkageName.end()) {
715if (OrigLinkage->second == OldLinkageName)
716// We're good.
717return NewMDS;
718
719// Otherwise, need to make a distinct one.
720// TODO: Query the map to see if we already have one.
721return distinctMDSubprogram();
722 }
723
724 NewToLinkageName.insert({NewMDS, MDS->getLinkageName()});
725return NewMDS;
726 }
727
728 /// Create a new compile unit, to replace the one given
729DICompileUnit *getReplacementCU(DICompileUnit *CU) {
730// Drop skeleton CUs.
731if (CU->getDWOId())
732returnnullptr;
733
734auto *File = cast_or_null<DIFile>(map(CU->getFile()));
735MDTuple *EnumTypes =nullptr;
736MDTuple *RetainedTypes =nullptr;
737MDTuple *GlobalVariables =nullptr;
738MDTuple *ImportedEntities =nullptr;
739return DICompileUnit::getDistinct(
740CU->getContext(),CU->getSourceLanguage(), File,CU->getProducer(),
741CU->isOptimized(),CU->getFlags(),CU->getRuntimeVersion(),
742CU->getSplitDebugFilename(),DICompileUnit::LineTablesOnly, EnumTypes,
743 RetainedTypes, GlobalVariables, ImportedEntities,CU->getMacros(),
744CU->getDWOId(),CU->getSplitDebugInlining(),
745CU->getDebugInfoForProfiling(),CU->getNameTableKind(),
746CU->getRangesBaseAddress(),CU->getSysRoot(),CU->getSDK());
747 }
748
749DILocation *getReplacementMDLocation(DILocation *MLD) {
750auto *Scope = map(MLD->getScope());
751auto *InlinedAt = map(MLD->getInlinedAt());
752if (MLD->isDistinct())
753return DILocation::getDistinct(MLD->getContext(), MLD->getLine(),
754 MLD->getColumn(), Scope, InlinedAt);
755return DILocation::get(MLD->getContext(), MLD->getLine(), MLD->getColumn(),
756 Scope, InlinedAt);
757 }
758
759 /// Create a new generic MDNode, to replace the one given
760MDNode *getReplacementMDNode(MDNode *N) {
761SmallVector<Metadata *, 8> Ops;
762 Ops.reserve(N->getNumOperands());
763for (auto &I :N->operands())
764if (I)
765 Ops.push_back(map(I));
766auto *Ret =MDNode::get(N->getContext(), Ops);
767returnRet;
768 }
769
770 /// Attempt to re-map N to a newly created node.
771void remap(MDNode *N) {
772if (Replacements.count(N))
773return;
774
775auto doRemap = [&](MDNode *N) ->MDNode * {
776if (!N)
777returnnullptr;
778if (auto *MDSub = dyn_cast<DISubprogram>(N)) {
779 remap(MDSub->getUnit());
780return getReplacementSubprogram(MDSub);
781 }
782if (isa<DISubroutineType>(N))
783return EmptySubroutineType;
784if (auto *CU = dyn_cast<DICompileUnit>(N))
785return getReplacementCU(CU);
786if (isa<DIFile>(N))
787returnN;
788if (auto *MDLB = dyn_cast<DILexicalBlockBase>(N))
789// Remap to our referenced scope (recursively).
790return mapNode(MDLB->getScope());
791if (auto *MLD = dyn_cast<DILocation>(N))
792return getReplacementMDLocation(MLD);
793
794// Otherwise, if we see these, just drop them now. Not strictly necessary,
795// but this speeds things up a little.
796if (isa<DINode>(N))
797returnnullptr;
798
799return getReplacementMDNode(N);
800 };
801 Replacements[N] = doRemap(N);
802 }
803
804 /// Do the remapping traversal.
805void traverse(MDNode *);
806};
807
808}// end anonymous namespace
809
810void DebugTypeInfoRemoval::traverse(MDNode *N) {
811if (!N || Replacements.count(N))
812return;
813
814// To avoid cycles, as well as for efficiency sake, we will sometimes prune
815// parts of the graph.
816autoprune = [](MDNode *Parent,MDNode *Child) {
817if (auto *MDS = dyn_cast<DISubprogram>(Parent))
818return Child == MDS->getRetainedNodes().get();
819returnfalse;
820 };
821
822SmallVector<MDNode *, 16> ToVisit;
823DenseSet<MDNode *> Opened;
824
825// Visit each node starting at N in post order, and map them.
826 ToVisit.push_back(N);
827while (!ToVisit.empty()) {
828auto *N = ToVisit.back();
829if (!Opened.insert(N).second) {
830// Close it.
831 remap(N);
832 ToVisit.pop_back();
833continue;
834 }
835for (auto &I :N->operands())
836if (auto *MDN = dyn_cast_or_null<MDNode>(I))
837if (!Opened.count(MDN) && !Replacements.count(MDN) && !prune(N, MDN) &&
838 !isa<DICompileUnit>(MDN))
839 ToVisit.push_back(MDN);
840 }
841}
842
843boolllvm::stripNonLineTableDebugInfo(Module &M) {
844bool Changed =false;
845
846// First off, delete the debug intrinsics.
847auto RemoveUses = [&](StringRefName) {
848if (auto *DbgVal = M.getFunction(Name)) {
849while (!DbgVal->use_empty())
850 cast<Instruction>(DbgVal->user_back())->eraseFromParent();
851 DbgVal->eraseFromParent();
852 Changed =true;
853 }
854 };
855 RemoveUses("llvm.dbg.declare");
856 RemoveUses("llvm.dbg.label");
857 RemoveUses("llvm.dbg.value");
858
859// Delete non-CU debug info named metadata nodes.
860for (auto NMI = M.named_metadata_begin(), NME = M.named_metadata_end();
861 NMI != NME;) {
862NamedMDNode *NMD = &*NMI;
863 ++NMI;
864// Specifically keep dbg.cu around.
865if (NMD->getName() =="llvm.dbg.cu")
866continue;
867 }
868
869// Drop all dbg attachments from global variables.
870for (auto &GV : M.globals())
871 GV.eraseMetadata(LLVMContext::MD_dbg);
872
873 DebugTypeInfoRemoval Mapper(M.getContext());
874auto remap = [&](MDNode *Node) ->MDNode * {
875if (!Node)
876returnnullptr;
877 Mapper.traverseAndRemap(Node);
878auto *NewNode = Mapper.mapNode(Node);
879 Changed |= Node != NewNode;
880 Node = NewNode;
881return NewNode;
882 };
883
884// Rewrite the DebugLocs to be equivalent to what
885// -gline-tables-only would have created.
886for (auto &F : M) {
887if (auto *SP =F.getSubprogram()) {
888 Mapper.traverseAndRemap(SP);
889auto *NewSP = cast<DISubprogram>(Mapper.mapNode(SP));
890 Changed |= SP != NewSP;
891F.setSubprogram(NewSP);
892 }
893for (auto &BB :F) {
894for (auto &I : BB) {
895auto remapDebugLoc = [&](constDebugLoc &DL) ->DebugLoc {
896auto *Scope =DL.getScope();
897MDNode *InlinedAt =DL.getInlinedAt();
898 Scope = remap(Scope);
899 InlinedAt = remap(InlinedAt);
900returnDILocation::get(M.getContext(),DL.getLine(),DL.getCol(),
901 Scope, InlinedAt);
902 };
903
904if (I.getDebugLoc() !=DebugLoc())
905I.setDebugLoc(remapDebugLoc(I.getDebugLoc()));
906
907// Remap DILocations in llvm.loop attachments.
908updateLoopMetadataDebugLocations(I, [&](Metadata *MD) ->Metadata * {
909if (auto *Loc = dyn_cast_or_null<DILocation>(MD))
910return remapDebugLoc(Loc).get();
911return MD;
912 });
913
914// Strip heapallocsite attachments, they point into the DIType system.
915if (I.hasMetadataOtherThanDebugLoc())
916I.setMetadata("heapallocsite",nullptr);
917
918// Strip any DbgRecords attached.
919I.dropDbgRecords();
920 }
921 }
922 }
923
924// Create a new llvm.dbg.cu, which is equivalent to the one
925// -gline-tables-only would have created.
926for (auto &NMD : M.named_metadata()) {
927SmallVector<MDNode *, 8> Ops;
928for (MDNode *Op : NMD.operands())
929 Ops.push_back(remap(Op));
930
931if (!Changed)
932continue;
933
934 NMD.clearOperands();
935for (auto *Op : Ops)
936if (Op)
937 NMD.addOperand(Op);
938 }
939return Changed;
940}
941
942unsignedllvm::getDebugMetadataVersionFromModule(constModule &M) {
943if (auto *Val = mdconst::dyn_extract_or_null<ConstantInt>(
944 M.getModuleFlag("Debug Info Version")))
945return Val->getZExtValue();
946return 0;
947}
948
949voidInstruction::applyMergedLocation(DILocation *LocA,DILocation *LocB) {
950setDebugLoc(DILocation::getMergedLocation(LocA, LocB));
951}
952
953voidInstruction::mergeDIAssignID(
954ArrayRef<const Instruction *> SourceInstructions) {
955// Replace all uses (and attachments) of all the DIAssignIDs
956// on SourceInstructions with a single merged value.
957assert(getFunction() &&"Uninserted instruction merged");
958// Collect up the DIAssignID tags.
959SmallVector<DIAssignID *, 4> IDs;
960for (constInstruction *I : SourceInstructions) {
961if (auto *MD =I->getMetadata(LLVMContext::MD_DIAssignID))
962 IDs.push_back(cast<DIAssignID>(MD));
963assert(getFunction() ==I->getFunction() &&
964"Merging with instruction from another function not allowed");
965 }
966
967// Add this instruction's DIAssignID too, if it has one.
968if (auto *MD =getMetadata(LLVMContext::MD_DIAssignID))
969 IDs.push_back(cast<DIAssignID>(MD));
970
971if (IDs.empty())
972return;// No DIAssignID tags to process.
973
974DIAssignID *MergeID = IDs[0];
975for (auto It = std::next(IDs.begin()),End = IDs.end(); It !=End; ++It) {
976if (*It != MergeID)
977at::RAUW(*It, MergeID);
978 }
979setMetadata(LLVMContext::MD_DIAssignID, MergeID);
980}
981
982voidInstruction::updateLocationAfterHoist() {dropLocation(); }
983
984voidInstruction::dropLocation() {
985constDebugLoc &DL =getDebugLoc();
986if (!DL)
987return;
988
989// If this isn't a call, drop the location to allow a location from a
990// preceding instruction to propagate.
991bool MayLowerToCall =false;
992if (isa<CallBase>(this)) {
993auto *II = dyn_cast<IntrinsicInst>(this);
994 MayLowerToCall =
995 !II ||IntrinsicInst::mayLowerToFunctionCall(II->getIntrinsicID());
996 }
997
998if (!MayLowerToCall) {
999setDebugLoc(DebugLoc());
1000return;
1001 }
1002
1003// Set a line 0 location for calls to preserve scope information in case
1004// inlining occurs.
1005DISubprogram *SP =getFunction()->getSubprogram();
1006if (SP)
1007// If a function scope is available, set it on the line 0 location. When
1008// hoisting a call to a predecessor block, using the function scope avoids
1009// making it look like the callee was reached earlier than it should be.
1010setDebugLoc(DILocation::get(getContext(), 0, 0, SP));
1011else
1012// The parent function has no scope. Go ahead and drop the location. If
1013// the parent function is inlined, and the callee has a subprogram, the
1014// inliner will attach a location to the call.
1015//
1016// One alternative is to set a line 0 location with the existing scope and
1017// inlinedAt info. The location might be sensitive to when inlining occurs.
1018setDebugLoc(DebugLoc());
1019}
1020
1021//===----------------------------------------------------------------------===//
1022// LLVM C API implementations.
1023//===----------------------------------------------------------------------===//
1024
1025staticunsignedmap_from_llvmDWARFsourcelanguage(LLVMDWARFSourceLanguage lang) {
1026switch (lang) {
1027#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
1028 case LLVMDWARFSourceLanguage##NAME: \
1029 return ID;
1030#include "llvm/BinaryFormat/Dwarf.def"
1031#undef HANDLE_DW_LANG
1032 }
1033llvm_unreachable("Unhandled Tag");
1034}
1035
1036template <typename DIT> DIT *unwrapDI(LLVMMetadataRefRef) {
1037return (DIT *)(Ref ? unwrap<MDNode>(Ref) :nullptr);
1038}
1039
1040staticDINode::DIFlagsmap_from_llvmDIFlags(LLVMDIFlags Flags) {
1041returnstatic_cast<DINode::DIFlags>(Flags);
1042}
1043
1044staticLLVMDIFlagsmap_to_llvmDIFlags(DINode::DIFlags Flags) {
1045returnstatic_cast<LLVMDIFlags>(Flags);
1046}
1047
1048staticDISubprogram::DISPFlags
1049pack_into_DISPFlags(bool IsLocalToUnit,bool IsDefinition,bool IsOptimized) {
1050returnDISubprogram::toSPFlags(IsLocalToUnit, IsDefinition, IsOptimized);
1051}
1052
1053unsignedLLVMDebugMetadataVersion() {
1054returnDEBUG_METADATA_VERSION;
1055}
1056
1057LLVMDIBuilderRefLLVMCreateDIBuilderDisallowUnresolved(LLVMModuleRef M) {
1058returnwrap(newDIBuilder(*unwrap(M),false));
1059}
1060
1061LLVMDIBuilderRefLLVMCreateDIBuilder(LLVMModuleRef M) {
1062returnwrap(newDIBuilder(*unwrap(M)));
1063}
1064
1065unsignedLLVMGetModuleDebugMetadataVersion(LLVMModuleRef M) {
1066returngetDebugMetadataVersionFromModule(*unwrap(M));
1067}
1068
1069LLVMBoolLLVMStripModuleDebugInfo(LLVMModuleRef M) {
1070returnStripDebugInfo(*unwrap(M));
1071}
1072
1073voidLLVMDisposeDIBuilder(LLVMDIBuilderRef Builder) {
1074deleteunwrap(Builder);
1075}
1076
1077voidLLVMDIBuilderFinalize(LLVMDIBuilderRef Builder) {
1078unwrap(Builder)->finalize();
1079}
1080
1081voidLLVMDIBuilderFinalizeSubprogram(LLVMDIBuilderRef Builder,
1082LLVMMetadataRef subprogram) {
1083unwrap(Builder)->finalizeSubprogram(unwrapDI<DISubprogram>(subprogram));
1084}
1085
1086LLVMMetadataRefLLVMDIBuilderCreateCompileUnit(
1087LLVMDIBuilderRef Builder,LLVMDWARFSourceLanguage Lang,
1088LLVMMetadataRef FileRef,constchar *Producer,size_t ProducerLen,
1089LLVMBool isOptimized,constchar *Flags,size_t FlagsLen,
1090unsigned RuntimeVer,constchar *SplitName,size_t SplitNameLen,
1091LLVMDWARFEmissionKind Kind,unsigned DWOId,LLVMBool SplitDebugInlining,
1092LLVMBool DebugInfoForProfiling,constchar *SysRoot,size_t SysRootLen,
1093constchar *SDK,size_t SDKLen) {
1094auto File = unwrapDI<DIFile>(FileRef);
1095
1096returnwrap(unwrap(Builder)->createCompileUnit(
1097map_from_llvmDWARFsourcelanguage(Lang), File,
1098StringRef(Producer, ProducerLen), isOptimized,StringRef(Flags, FlagsLen),
1099 RuntimeVer,StringRef(SplitName, SplitNameLen),
1100static_cast<DICompileUnit::DebugEmissionKind>(Kind), DWOId,
1101 SplitDebugInlining, DebugInfoForProfiling,
1102DICompileUnit::DebugNameTableKind::Default,false,
1103StringRef(SysRoot, SysRootLen),StringRef(SDK, SDKLen)));
1104}
1105
1106LLVMMetadataRef
1107LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder,constchar *Filename,
1108size_t FilenameLen,constchar *Directory,
1109size_t DirectoryLen) {
1110returnwrap(unwrap(Builder)->createFile(StringRef(Filename, FilenameLen),
1111StringRef(Directory, DirectoryLen)));
1112}
1113
1114LLVMMetadataRef
1115LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder,LLVMMetadataRef ParentScope,
1116constchar *Name,size_t NameLen,
1117constchar *ConfigMacros,size_t ConfigMacrosLen,
1118constchar *IncludePath,size_t IncludePathLen,
1119constchar *APINotesFile,size_t APINotesFileLen) {
1120returnwrap(unwrap(Builder)->createModule(
1121 unwrapDI<DIScope>(ParentScope),StringRef(Name, NameLen),
1122StringRef(ConfigMacros, ConfigMacrosLen),
1123StringRef(IncludePath, IncludePathLen),
1124StringRef(APINotesFile, APINotesFileLen)));
1125}
1126
1127LLVMMetadataRefLLVMDIBuilderCreateNameSpace(LLVMDIBuilderRef Builder,
1128LLVMMetadataRef ParentScope,
1129constchar *Name,size_t NameLen,
1130LLVMBool ExportSymbols) {
1131returnwrap(unwrap(Builder)->createNameSpace(
1132 unwrapDI<DIScope>(ParentScope),StringRef(Name, NameLen), ExportSymbols));
1133}
1134
1135LLVMMetadataRefLLVMDIBuilderCreateFunction(
1136LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,constchar *Name,
1137size_t NameLen,constchar *LinkageName,size_t LinkageNameLen,
1138LLVMMetadataRef File,unsigned LineNo,LLVMMetadataRef Ty,
1139LLVMBool IsLocalToUnit,LLVMBool IsDefinition,
1140unsigned ScopeLine,LLVMDIFlags Flags,LLVMBool IsOptimized) {
1141returnwrap(unwrap(Builder)->createFunction(
1142 unwrapDI<DIScope>(Scope), {Name, NameLen}, {LinkageName, LinkageNameLen},
1143 unwrapDI<DIFile>(File), LineNo, unwrapDI<DISubroutineType>(Ty), ScopeLine,
1144map_from_llvmDIFlags(Flags),
1145pack_into_DISPFlags(IsLocalToUnit, IsDefinition, IsOptimized),nullptr,
1146nullptr,nullptr));
1147}
1148
1149
1150LLVMMetadataRefLLVMDIBuilderCreateLexicalBlock(
1151LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,
1152LLVMMetadataRef File,unsigned Line,unsigned Col) {
1153returnwrap(unwrap(Builder)->createLexicalBlock(unwrapDI<DIScope>(Scope),
1154 unwrapDI<DIFile>(File),
1155 Line, Col));
1156}
1157
1158LLVMMetadataRef
1159LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Builder,
1160LLVMMetadataRef Scope,
1161LLVMMetadataRef File,
1162unsigned Discriminator) {
1163returnwrap(unwrap(Builder)->createLexicalBlockFile(unwrapDI<DIScope>(Scope),
1164 unwrapDI<DIFile>(File),
1165 Discriminator));
1166}
1167
1168LLVMMetadataRef
1169LLVMDIBuilderCreateImportedModuleFromNamespace(LLVMDIBuilderRef Builder,
1170LLVMMetadataRef Scope,
1171LLVMMetadataRef NS,
1172LLVMMetadataRef File,
1173unsigned Line) {
1174returnwrap(unwrap(Builder)->createImportedModule(unwrapDI<DIScope>(Scope),
1175 unwrapDI<DINamespace>(NS),
1176 unwrapDI<DIFile>(File),
1177 Line));
1178}
1179
1180LLVMMetadataRefLLVMDIBuilderCreateImportedModuleFromAlias(
1181LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,
1182LLVMMetadataRef ImportedEntity,LLVMMetadataRef File,unsigned Line,
1183LLVMMetadataRef *Elements,unsigned NumElements) {
1184auto Elts =
1185 (NumElements > 0)
1186 ?unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements})
1187 :nullptr;
1188returnwrap(unwrap(Builder)->createImportedModule(
1189 unwrapDI<DIScope>(Scope), unwrapDI<DIImportedEntity>(ImportedEntity),
1190 unwrapDI<DIFile>(File), Line, Elts));
1191}
1192
1193LLVMMetadataRefLLVMDIBuilderCreateImportedModuleFromModule(
1194LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,LLVMMetadataRef M,
1195LLVMMetadataRef File,unsigned Line,LLVMMetadataRef *Elements,
1196unsigned NumElements) {
1197auto Elts =
1198 (NumElements > 0)
1199 ?unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements})
1200 :nullptr;
1201returnwrap(unwrap(Builder)->createImportedModule(
1202 unwrapDI<DIScope>(Scope), unwrapDI<DIModule>(M), unwrapDI<DIFile>(File),
1203 Line, Elts));
1204}
1205
1206LLVMMetadataRefLLVMDIBuilderCreateImportedDeclaration(
1207LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,LLVMMetadataRef Decl,
1208LLVMMetadataRef File,unsigned Line,constchar *Name,size_t NameLen,
1209LLVMMetadataRef *Elements,unsigned NumElements) {
1210auto Elts =
1211 (NumElements > 0)
1212 ?unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements})
1213 :nullptr;
1214returnwrap(unwrap(Builder)->createImportedDeclaration(
1215 unwrapDI<DIScope>(Scope), unwrapDI<DINode>(Decl), unwrapDI<DIFile>(File),
1216 Line, {Name, NameLen}, Elts));
1217}
1218
1219LLVMMetadataRef
1220LLVMDIBuilderCreateDebugLocation(LLVMContextRef Ctx,unsigned Line,
1221unsigned Column,LLVMMetadataRef Scope,
1222LLVMMetadataRef InlinedAt) {
1223returnwrap(DILocation::get(*unwrap(Ctx), Line, Column,unwrap(Scope),
1224unwrap(InlinedAt)));
1225}
1226
1227unsignedLLVMDILocationGetLine(LLVMMetadataRef Location) {
1228return unwrapDI<DILocation>(Location)->getLine();
1229}
1230
1231unsignedLLVMDILocationGetColumn(LLVMMetadataRef Location) {
1232return unwrapDI<DILocation>(Location)->getColumn();
1233}
1234
1235LLVMMetadataRefLLVMDILocationGetScope(LLVMMetadataRef Location) {
1236returnwrap(unwrapDI<DILocation>(Location)->getScope());
1237}
1238
1239LLVMMetadataRefLLVMDILocationGetInlinedAt(LLVMMetadataRef Location) {
1240returnwrap(unwrapDI<DILocation>(Location)->getInlinedAt());
1241}
1242
1243LLVMMetadataRefLLVMDIScopeGetFile(LLVMMetadataRef Scope) {
1244returnwrap(unwrapDI<DIScope>(Scope)->getFile());
1245}
1246
1247constchar *LLVMDIFileGetDirectory(LLVMMetadataRef File,unsigned *Len) {
1248auto Dir = unwrapDI<DIFile>(File)->getDirectory();
1249 *Len = Dir.size();
1250return Dir.data();
1251}
1252
1253constchar *LLVMDIFileGetFilename(LLVMMetadataRef File,unsigned *Len) {
1254autoName = unwrapDI<DIFile>(File)->getFilename();
1255 *Len =Name.size();
1256returnName.data();
1257}
1258
1259constchar *LLVMDIFileGetSource(LLVMMetadataRef File,unsigned *Len) {
1260if (auto Src = unwrapDI<DIFile>(File)->getSource()) {
1261 *Len = Src->size();
1262return Src->data();
1263 }
1264 *Len = 0;
1265return"";
1266}
1267
1268LLVMMetadataRefLLVMDIBuilderCreateMacro(LLVMDIBuilderRef Builder,
1269LLVMMetadataRef ParentMacroFile,
1270unsigned Line,
1271LLVMDWARFMacinfoRecordTypeRecordType,
1272constchar *Name,size_t NameLen,
1273constchar *Value,size_t ValueLen) {
1274returnwrap(
1275unwrap(Builder)->createMacro(unwrapDI<DIMacroFile>(ParentMacroFile), Line,
1276static_cast<MacinfoRecordType>(RecordType),
1277 {Name, NameLen}, {Value, ValueLen}));
1278}
1279
1280LLVMMetadataRef
1281LLVMDIBuilderCreateTempMacroFile(LLVMDIBuilderRef Builder,
1282LLVMMetadataRef ParentMacroFile,unsigned Line,
1283LLVMMetadataRef File) {
1284returnwrap(unwrap(Builder)->createTempMacroFile(
1285 unwrapDI<DIMacroFile>(ParentMacroFile), Line, unwrapDI<DIFile>(File)));
1286}
1287
1288LLVMMetadataRefLLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder,
1289constchar *Name,size_t NameLen,
1290 int64_tValue,
1291LLVMBool IsUnsigned) {
1292returnwrap(unwrap(Builder)->createEnumerator({Name, NameLen},Value,
1293 IsUnsigned != 0));
1294}
1295
1296LLVMMetadataRefLLVMDIBuilderCreateEnumerationType(
1297LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,constchar *Name,
1298size_t NameLen,LLVMMetadataRef File,unsigned LineNumber,
1299uint64_t SizeInBits,uint32_t AlignInBits,LLVMMetadataRef *Elements,
1300unsigned NumElements,LLVMMetadataRef ClassTy) {
1301auto Elts =unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1302 NumElements});
1303returnwrap(unwrap(Builder)->createEnumerationType(
1304 unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
1305 LineNumber, SizeInBits, AlignInBits, Elts, unwrapDI<DIType>(ClassTy)));
1306}
1307
1308LLVMMetadataRefLLVMDIBuilderCreateUnionType(
1309LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,constchar *Name,
1310size_t NameLen,LLVMMetadataRef File,unsigned LineNumber,
1311uint64_t SizeInBits,uint32_t AlignInBits,LLVMDIFlags Flags,
1312LLVMMetadataRef *Elements,unsigned NumElements,unsigned RunTimeLang,
1313constchar *UniqueId,size_t UniqueIdLen) {
1314auto Elts =unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1315 NumElements});
1316returnwrap(unwrap(Builder)->createUnionType(
1317 unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
1318 LineNumber, SizeInBits, AlignInBits,map_from_llvmDIFlags(Flags),
1319 Elts, RunTimeLang, {UniqueId, UniqueIdLen}));
1320}
1321
1322
1323LLVMMetadataRef
1324LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Builder,uint64_tSize,
1325uint32_t AlignInBits,LLVMMetadataRef Ty,
1326LLVMMetadataRef *Subscripts,
1327unsigned NumSubscripts) {
1328auto Subs =unwrap(Builder)->getOrCreateArray({unwrap(Subscripts),
1329 NumSubscripts});
1330returnwrap(unwrap(Builder)->createArrayType(Size, AlignInBits,
1331 unwrapDI<DIType>(Ty), Subs));
1332}
1333
1334LLVMMetadataRef
1335LLVMDIBuilderCreateVectorType(LLVMDIBuilderRef Builder,uint64_tSize,
1336uint32_t AlignInBits,LLVMMetadataRef Ty,
1337LLVMMetadataRef *Subscripts,
1338unsigned NumSubscripts) {
1339auto Subs =unwrap(Builder)->getOrCreateArray({unwrap(Subscripts),
1340 NumSubscripts});
1341returnwrap(unwrap(Builder)->createVectorType(Size, AlignInBits,
1342 unwrapDI<DIType>(Ty), Subs));
1343}
1344
1345LLVMMetadataRef
1346LLVMDIBuilderCreateBasicType(LLVMDIBuilderRef Builder,constchar *Name,
1347size_t NameLen,uint64_t SizeInBits,
1348LLVMDWARFTypeEncoding Encoding,
1349LLVMDIFlags Flags) {
1350returnwrap(unwrap(Builder)->createBasicType({Name, NameLen},
1351 SizeInBits, Encoding,
1352map_from_llvmDIFlags(Flags)));
1353}
1354
1355LLVMMetadataRefLLVMDIBuilderCreatePointerType(
1356LLVMDIBuilderRef Builder,LLVMMetadataRef PointeeTy,
1357uint64_t SizeInBits,uint32_t AlignInBits,unsignedAddressSpace,
1358constchar *Name,size_t NameLen) {
1359returnwrap(unwrap(Builder)->createPointerType(
1360 unwrapDI<DIType>(PointeeTy), SizeInBits, AlignInBits,AddressSpace,
1361 {Name, NameLen}));
1362}
1363
1364LLVMMetadataRefLLVMDIBuilderCreateStructType(
1365LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,constchar *Name,
1366size_t NameLen,LLVMMetadataRef File,unsigned LineNumber,
1367uint64_t SizeInBits,uint32_t AlignInBits,LLVMDIFlags Flags,
1368LLVMMetadataRef DerivedFrom,LLVMMetadataRef *Elements,
1369unsigned NumElements,unsigned RunTimeLang,LLVMMetadataRef VTableHolder,
1370constchar *UniqueId,size_t UniqueIdLen) {
1371auto Elts =unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1372 NumElements});
1373returnwrap(unwrap(Builder)->createStructType(
1374 unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
1375 LineNumber, SizeInBits, AlignInBits,map_from_llvmDIFlags(Flags),
1376 unwrapDI<DIType>(DerivedFrom), Elts, RunTimeLang,
1377 unwrapDI<DIType>(VTableHolder), {UniqueId, UniqueIdLen}));
1378}
1379
1380LLVMMetadataRefLLVMDIBuilderCreateMemberType(
1381LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,constchar *Name,
1382size_t NameLen,LLVMMetadataRef File,unsigned LineNo,uint64_t SizeInBits,
1383uint32_t AlignInBits,uint64_t OffsetInBits,LLVMDIFlags Flags,
1384LLVMMetadataRef Ty) {
1385returnwrap(unwrap(Builder)->createMemberType(unwrapDI<DIScope>(Scope),
1386 {Name, NameLen}, unwrapDI<DIFile>(File), LineNo, SizeInBits, AlignInBits,
1387 OffsetInBits,map_from_llvmDIFlags(Flags), unwrapDI<DIType>(Ty)));
1388}
1389
1390LLVMMetadataRef
1391LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder,constchar *Name,
1392size_t NameLen) {
1393returnwrap(unwrap(Builder)->createUnspecifiedType({Name, NameLen}));
1394}
1395
1396LLVMMetadataRefLLVMDIBuilderCreateStaticMemberType(
1397LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,constchar *Name,
1398size_t NameLen,LLVMMetadataRef File,unsigned LineNumber,
1399LLVMMetadataRefType,LLVMDIFlags Flags,LLVMValueRef ConstantVal,
1400uint32_t AlignInBits) {
1401returnwrap(unwrap(Builder)->createStaticMemberType(
1402 unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
1403 LineNumber, unwrapDI<DIType>(Type),map_from_llvmDIFlags(Flags),
1404 unwrap<Constant>(ConstantVal), DW_TAG_member, AlignInBits));
1405}
1406
1407LLVMMetadataRef
1408LLVMDIBuilderCreateObjCIVar(LLVMDIBuilderRef Builder,
1409constchar *Name,size_t NameLen,
1410LLVMMetadataRef File,unsigned LineNo,
1411uint64_t SizeInBits,uint32_t AlignInBits,
1412uint64_t OffsetInBits,LLVMDIFlags Flags,
1413LLVMMetadataRef Ty,LLVMMetadataRef PropertyNode) {
1414returnwrap(unwrap(Builder)->createObjCIVar(
1415 {Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1416 SizeInBits, AlignInBits, OffsetInBits,
1417map_from_llvmDIFlags(Flags), unwrapDI<DIType>(Ty),
1418 unwrapDI<MDNode>(PropertyNode)));
1419}
1420
1421LLVMMetadataRef
1422LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
1423constchar *Name,size_t NameLen,
1424LLVMMetadataRef File,unsigned LineNo,
1425constchar *GetterName,size_t GetterNameLen,
1426constchar *SetterName,size_t SetterNameLen,
1427unsigned PropertyAttributes,
1428LLVMMetadataRef Ty) {
1429returnwrap(unwrap(Builder)->createObjCProperty(
1430 {Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1431 {GetterName, GetterNameLen}, {SetterName, SetterNameLen},
1432 PropertyAttributes, unwrapDI<DIType>(Ty)));
1433}
1434
1435LLVMMetadataRefLLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
1436LLVMMetadataRefType,
1437LLVMBool Implicit) {
1438returnwrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type),
1439 Implicit));
1440}
1441
1442LLVMMetadataRef
1443LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder,LLVMMetadataRefType,
1444constchar *Name,size_t NameLen,
1445LLVMMetadataRef File,unsigned LineNo,
1446LLVMMetadataRef Scope,uint32_t AlignInBits) {
1447returnwrap(unwrap(Builder)->createTypedef(
1448 unwrapDI<DIType>(Type), {Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1449 unwrapDI<DIScope>(Scope), AlignInBits));
1450}
1451
1452LLVMMetadataRef
1453LLVMDIBuilderCreateInheritance(LLVMDIBuilderRef Builder,
1454LLVMMetadataRef Ty,LLVMMetadataRefBaseTy,
1455uint64_t BaseOffset,uint32_t VBPtrOffset,
1456LLVMDIFlags Flags) {
1457returnwrap(unwrap(Builder)->createInheritance(
1458 unwrapDI<DIType>(Ty), unwrapDI<DIType>(BaseTy),
1459 BaseOffset, VBPtrOffset,map_from_llvmDIFlags(Flags)));
1460}
1461
1462LLVMMetadataRef
1463LLVMDIBuilderCreateForwardDecl(
1464LLVMDIBuilderRef Builder,unsignedTag,constchar *Name,
1465size_t NameLen,LLVMMetadataRef Scope,LLVMMetadataRef File,unsigned Line,
1466unsigned RuntimeLang,uint64_t SizeInBits,uint32_t AlignInBits,
1467constchar *UniqueIdentifier,size_t UniqueIdentifierLen) {
1468returnwrap(unwrap(Builder)->createForwardDecl(
1469Tag, {Name, NameLen}, unwrapDI<DIScope>(Scope),
1470 unwrapDI<DIFile>(File), Line, RuntimeLang, SizeInBits,
1471 AlignInBits, {UniqueIdentifier, UniqueIdentifierLen}));
1472}
1473
1474LLVMMetadataRef
1475LLVMDIBuilderCreateReplaceableCompositeType(
1476LLVMDIBuilderRef Builder,unsignedTag,constchar *Name,
1477size_t NameLen,LLVMMetadataRef Scope,LLVMMetadataRef File,unsigned Line,
1478unsigned RuntimeLang,uint64_t SizeInBits,uint32_t AlignInBits,
1479LLVMDIFlags Flags,constchar *UniqueIdentifier,
1480size_t UniqueIdentifierLen) {
1481returnwrap(unwrap(Builder)->createReplaceableCompositeType(
1482Tag, {Name, NameLen}, unwrapDI<DIScope>(Scope),
1483 unwrapDI<DIFile>(File), Line, RuntimeLang, SizeInBits,
1484 AlignInBits,map_from_llvmDIFlags(Flags),
1485 {UniqueIdentifier, UniqueIdentifierLen}));
1486}
1487
1488LLVMMetadataRef
1489LLVMDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder,unsignedTag,
1490LLVMMetadataRefType) {
1491returnwrap(unwrap(Builder)->createQualifiedType(Tag,
1492 unwrapDI<DIType>(Type)));
1493}
1494
1495LLVMMetadataRef
1496LLVMDIBuilderCreateReferenceType(LLVMDIBuilderRef Builder,unsignedTag,
1497LLVMMetadataRefType) {
1498returnwrap(unwrap(Builder)->createReferenceType(Tag,
1499 unwrapDI<DIType>(Type)));
1500}
1501
1502LLVMMetadataRef
1503LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder) {
1504returnwrap(unwrap(Builder)->createNullPtrType());
1505}
1506
1507LLVMMetadataRef
1508LLVMDIBuilderCreateMemberPointerType(LLVMDIBuilderRef Builder,
1509LLVMMetadataRef PointeeType,
1510LLVMMetadataRef ClassType,
1511uint64_t SizeInBits,
1512uint32_t AlignInBits,
1513LLVMDIFlags Flags) {
1514returnwrap(unwrap(Builder)->createMemberPointerType(
1515 unwrapDI<DIType>(PointeeType),
1516 unwrapDI<DIType>(ClassType), AlignInBits, SizeInBits,
1517map_from_llvmDIFlags(Flags)));
1518}
1519
1520LLVMMetadataRef
1521LLVMDIBuilderCreateBitFieldMemberType(LLVMDIBuilderRef Builder,
1522LLVMMetadataRef Scope,
1523constchar *Name,size_t NameLen,
1524LLVMMetadataRef File,unsigned LineNumber,
1525uint64_t SizeInBits,
1526uint64_t OffsetInBits,
1527uint64_t StorageOffsetInBits,
1528LLVMDIFlags Flags,LLVMMetadataRefType) {
1529returnwrap(unwrap(Builder)->createBitFieldMemberType(
1530 unwrapDI<DIScope>(Scope), {Name, NameLen},
1531 unwrapDI<DIFile>(File), LineNumber,
1532 SizeInBits, OffsetInBits, StorageOffsetInBits,
1533map_from_llvmDIFlags(Flags), unwrapDI<DIType>(Type)));
1534}
1535
1536LLVMMetadataRefLLVMDIBuilderCreateClassType(LLVMDIBuilderRef Builder,
1537LLVMMetadataRef Scope,constchar *Name,size_t NameLen,
1538LLVMMetadataRef File,unsigned LineNumber,uint64_t SizeInBits,
1539uint32_t AlignInBits,uint64_t OffsetInBits,LLVMDIFlags Flags,
1540LLVMMetadataRef DerivedFrom,
1541LLVMMetadataRef *Elements,unsigned NumElements,
1542LLVMMetadataRef VTableHolder,LLVMMetadataRef TemplateParamsNode,
1543constchar *UniqueIdentifier,size_t UniqueIdentifierLen) {
1544auto Elts =unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1545 NumElements});
1546returnwrap(unwrap(Builder)->createClassType(
1547 unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
1548 LineNumber, SizeInBits, AlignInBits, OffsetInBits,
1549map_from_llvmDIFlags(Flags), unwrapDI<DIType>(DerivedFrom), Elts,
1550/*RunTimeLang=*/0, unwrapDI<DIType>(VTableHolder),
1551 unwrapDI<MDNode>(TemplateParamsNode),
1552 {UniqueIdentifier, UniqueIdentifierLen}));
1553}
1554
1555LLVMMetadataRef
1556LLVMDIBuilderCreateArtificialType(LLVMDIBuilderRef Builder,
1557LLVMMetadataRefType) {
1558returnwrap(unwrap(Builder)->createArtificialType(unwrapDI<DIType>(Type)));
1559}
1560
1561uint16_tLLVMGetDINodeTag(LLVMMetadataRef MD) {
1562return unwrapDI<DINode>(MD)->getTag();
1563}
1564
1565constchar *LLVMDITypeGetName(LLVMMetadataRef DType,size_t *Length) {
1566StringRef Str = unwrapDI<DIType>(DType)->getName();
1567 *Length = Str.size();
1568return Str.data();
1569}
1570
1571uint64_tLLVMDITypeGetSizeInBits(LLVMMetadataRef DType) {
1572return unwrapDI<DIType>(DType)->getSizeInBits();
1573}
1574
1575uint64_tLLVMDITypeGetOffsetInBits(LLVMMetadataRef DType) {
1576return unwrapDI<DIType>(DType)->getOffsetInBits();
1577}
1578
1579uint32_tLLVMDITypeGetAlignInBits(LLVMMetadataRef DType) {
1580return unwrapDI<DIType>(DType)->getAlignInBits();
1581}
1582
1583unsignedLLVMDITypeGetLine(LLVMMetadataRef DType) {
1584return unwrapDI<DIType>(DType)->getLine();
1585}
1586
1587LLVMDIFlagsLLVMDITypeGetFlags(LLVMMetadataRef DType) {
1588returnmap_to_llvmDIFlags(unwrapDI<DIType>(DType)->getFlags());
1589}
1590
1591LLVMMetadataRefLLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder,
1592LLVMMetadataRef *Types,
1593size_tLength) {
1594returnwrap(
1595unwrap(Builder)->getOrCreateTypeArray({unwrap(Types),Length}).get());
1596}
1597
1598LLVMMetadataRef
1599LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder,
1600LLVMMetadataRef File,
1601LLVMMetadataRef *ParameterTypes,
1602unsigned NumParameterTypes,
1603LLVMDIFlags Flags) {
1604auto Elts =unwrap(Builder)->getOrCreateTypeArray({unwrap(ParameterTypes),
1605 NumParameterTypes});
1606returnwrap(unwrap(Builder)->createSubroutineType(
1607 Elts,map_from_llvmDIFlags(Flags)));
1608}
1609
1610LLVMMetadataRefLLVMDIBuilderCreateExpression(LLVMDIBuilderRef Builder,
1611uint64_t *Addr,size_tLength) {
1612returnwrap(
1613unwrap(Builder)->createExpression(ArrayRef<uint64_t>(Addr,Length)));
1614}
1615
1616LLVMMetadataRef
1617LLVMDIBuilderCreateConstantValueExpression(LLVMDIBuilderRef Builder,
1618uint64_tValue) {
1619returnwrap(unwrap(Builder)->createConstantValueExpression(Value));
1620}
1621
1622LLVMMetadataRefLLVMDIBuilderCreateGlobalVariableExpression(
1623LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,constchar *Name,
1624size_t NameLen,constchar *Linkage,size_t LinkLen,LLVMMetadataRef File,
1625unsigned LineNo,LLVMMetadataRef Ty,LLVMBool LocalToUnit,
1626LLVMMetadataRef Expr,LLVMMetadataRef Decl,uint32_t AlignInBits) {
1627returnwrap(unwrap(Builder)->createGlobalVariableExpression(
1628 unwrapDI<DIScope>(Scope), {Name, NameLen}, {Linkage, LinkLen},
1629 unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
1630true, unwrap<DIExpression>(Expr), unwrapDI<MDNode>(Decl),
1631nullptr, AlignInBits));
1632}
1633
1634LLVMMetadataRefLLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE) {
1635returnwrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getVariable());
1636}
1637
1638LLVMMetadataRefLLVMDIGlobalVariableExpressionGetExpression(
1639LLVMMetadataRef GVE) {
1640returnwrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getExpression());
1641}
1642
1643LLVMMetadataRefLLVMDIVariableGetFile(LLVMMetadataRef Var) {
1644returnwrap(unwrapDI<DIVariable>(Var)->getFile());
1645}
1646
1647LLVMMetadataRefLLVMDIVariableGetScope(LLVMMetadataRef Var) {
1648returnwrap(unwrapDI<DIVariable>(Var)->getScope());
1649}
1650
1651unsignedLLVMDIVariableGetLine(LLVMMetadataRef Var) {
1652return unwrapDI<DIVariable>(Var)->getLine();
1653}
1654
1655LLVMMetadataRefLLVMTemporaryMDNode(LLVMContextRef Ctx,LLVMMetadataRef *Data,
1656size_t Count) {
1657returnwrap(
1658MDTuple::getTemporary(*unwrap(Ctx), {unwrap(Data), Count}).release());
1659}
1660
1661voidLLVMDisposeTemporaryMDNode(LLVMMetadataRef TempNode) {
1662MDNode::deleteTemporary(unwrapDI<MDNode>(TempNode));
1663}
1664
1665voidLLVMMetadataReplaceAllUsesWith(LLVMMetadataRef TargetMetadata,
1666LLVMMetadataRef Replacement) {
1667auto *Node = unwrapDI<MDNode>(TargetMetadata);
1668Node->replaceAllUsesWith(unwrap(Replacement));
1669MDNode::deleteTemporary(Node);
1670}
1671
1672LLVMMetadataRefLLVMDIBuilderCreateTempGlobalVariableFwdDecl(
1673LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,constchar *Name,
1674size_t NameLen,constchar *Linkage,size_t LnkLen,LLVMMetadataRef File,
1675unsigned LineNo,LLVMMetadataRef Ty,LLVMBool LocalToUnit,
1676LLVMMetadataRef Decl,uint32_t AlignInBits) {
1677returnwrap(unwrap(Builder)->createTempGlobalVariableFwdDecl(
1678 unwrapDI<DIScope>(Scope), {Name, NameLen}, {Linkage, LnkLen},
1679 unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
1680 unwrapDI<MDNode>(Decl),nullptr, AlignInBits));
1681}
1682
1683LLVMDbgRecordRefLLVMDIBuilderInsertDeclareRecordBefore(
1684LLVMDIBuilderRef Builder,LLVMValueRef Storage,LLVMMetadataRef VarInfo,
1685LLVMMetadataRef Expr,LLVMMetadataRefDL,LLVMValueRef Instr) {
1686DbgInstPtr DbgInst =unwrap(Builder)->insertDeclare(
1687unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1688 unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
1689 unwrap<Instruction>(Instr));
1690// This assert will fail if the module is in the old debug info format.
1691// This function should only be called if the module is in the new
1692// debug info format.
1693// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
1694// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
1695assert(isa<DbgRecord *>(DbgInst) &&
1696"Function unexpectedly in old debug info format");
1697returnwrap(cast<DbgRecord *>(DbgInst));
1698}
1699
1700LLVMDbgRecordRefLLVMDIBuilderInsertDeclareRecordAtEnd(
1701LLVMDIBuilderRef Builder,LLVMValueRef Storage,LLVMMetadataRef VarInfo,
1702LLVMMetadataRef Expr,LLVMMetadataRefDL,LLVMBasicBlockRefBlock) {
1703DbgInstPtr DbgInst =unwrap(Builder)->insertDeclare(
1704unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1705 unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),unwrap(Block));
1706// This assert will fail if the module is in the old debug info format.
1707// This function should only be called if the module is in the new
1708// debug info format.
1709// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
1710// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
1711assert(isa<DbgRecord *>(DbgInst) &&
1712"Function unexpectedly in old debug info format");
1713returnwrap(cast<DbgRecord *>(DbgInst));
1714}
1715
1716LLVMDbgRecordRefLLVMDIBuilderInsertDbgValueRecordBefore(
1717LLVMDIBuilderRef Builder,LLVMValueRef Val,LLVMMetadataRef VarInfo,
1718LLVMMetadataRef Expr,LLVMMetadataRefDebugLoc,LLVMValueRef Instr) {
1719DbgInstPtr DbgInst =unwrap(Builder)->insertDbgValueIntrinsic(
1720unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
1721 unwrap<DILocation>(DebugLoc), unwrap<Instruction>(Instr));
1722// This assert will fail if the module is in the old debug info format.
1723// This function should only be called if the module is in the new
1724// debug info format.
1725// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
1726// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
1727assert(isa<DbgRecord *>(DbgInst) &&
1728"Function unexpectedly in old debug info format");
1729returnwrap(cast<DbgRecord *>(DbgInst));
1730}
1731
1732LLVMDbgRecordRefLLVMDIBuilderInsertDbgValueRecordAtEnd(
1733LLVMDIBuilderRef Builder,LLVMValueRef Val,LLVMMetadataRef VarInfo,
1734LLVMMetadataRef Expr,LLVMMetadataRefDebugLoc,LLVMBasicBlockRefBlock) {
1735DbgInstPtr DbgInst =unwrap(Builder)->insertDbgValueIntrinsic(
1736unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
1737 unwrap<DILocation>(DebugLoc),unwrap(Block));
1738// This assert will fail if the module is in the old debug info format.
1739// This function should only be called if the module is in the new
1740// debug info format.
1741// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
1742// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
1743assert(isa<DbgRecord *>(DbgInst) &&
1744"Function unexpectedly in old debug info format");
1745returnwrap(cast<DbgRecord *>(DbgInst));
1746}
1747
1748LLVMMetadataRefLLVMDIBuilderCreateAutoVariable(
1749LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,constchar *Name,
1750size_t NameLen,LLVMMetadataRef File,unsigned LineNo,LLVMMetadataRef Ty,
1751LLVMBool AlwaysPreserve,LLVMDIFlags Flags,uint32_t AlignInBits) {
1752returnwrap(unwrap(Builder)->createAutoVariable(
1753 unwrap<DIScope>(Scope), {Name, NameLen}, unwrap<DIFile>(File),
1754 LineNo, unwrap<DIType>(Ty), AlwaysPreserve,
1755map_from_llvmDIFlags(Flags), AlignInBits));
1756}
1757
1758LLVMMetadataRefLLVMDIBuilderCreateParameterVariable(
1759LLVMDIBuilderRef Builder,LLVMMetadataRef Scope,constchar *Name,
1760size_t NameLen,unsigned ArgNo,LLVMMetadataRef File,unsigned LineNo,
1761LLVMMetadataRef Ty,LLVMBool AlwaysPreserve,LLVMDIFlags Flags) {
1762returnwrap(unwrap(Builder)->createParameterVariable(
1763 unwrap<DIScope>(Scope), {Name, NameLen}, ArgNo, unwrap<DIFile>(File),
1764 LineNo, unwrap<DIType>(Ty), AlwaysPreserve,
1765map_from_llvmDIFlags(Flags)));
1766}
1767
1768LLVMMetadataRefLLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder,
1769 int64_tLo, int64_t Count) {
1770returnwrap(unwrap(Builder)->getOrCreateSubrange(Lo, Count));
1771}
1772
1773LLVMMetadataRefLLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder,
1774LLVMMetadataRef *Data,
1775size_tLength) {
1776Metadata **DataValue =unwrap(Data);
1777returnwrap(unwrap(Builder)->getOrCreateArray({DataValue,Length}).get());
1778}
1779
1780LLVMMetadataRefLLVMGetSubprogram(LLVMValueRef Func) {
1781returnwrap(unwrap<Function>(Func)->getSubprogram());
1782}
1783
1784voidLLVMSetSubprogram(LLVMValueRef Func,LLVMMetadataRef SP) {
1785 unwrap<Function>(Func)->setSubprogram(unwrap<DISubprogram>(SP));
1786}
1787
1788unsignedLLVMDISubprogramGetLine(LLVMMetadataRef Subprogram) {
1789return unwrapDI<DISubprogram>(Subprogram)->getLine();
1790}
1791
1792LLVMMetadataRefLLVMInstructionGetDebugLoc(LLVMValueRef Inst) {
1793returnwrap(unwrap<Instruction>(Inst)->getDebugLoc().getAsMDNode());
1794}
1795
1796voidLLVMInstructionSetDebugLoc(LLVMValueRef Inst,LLVMMetadataRef Loc) {
1797if (Loc)
1798 unwrap<Instruction>(Inst)->setDebugLoc(DebugLoc(unwrap<MDNode>(Loc)));
1799else
1800 unwrap<Instruction>(Inst)->setDebugLoc(DebugLoc());
1801}
1802
1803LLVMMetadataRefLLVMDIBuilderCreateLabel(
1804LLVMDIBuilderRef Builder,
1805LLVMMetadataRef Context,constchar *Name,size_t NameLen,
1806LLVMMetadataRef File,unsigned LineNo,LLVMBool AlwaysPreserve) {
1807returnwrap(unwrap(Builder)->createLabel(
1808 unwrapDI<DIScope>(Context),StringRef(Name, NameLen),
1809 unwrapDI<DIFile>(File), LineNo, AlwaysPreserve));
1810}
1811
1812LLVMDbgRecordRefLLVMDIBuilderInsertLabelBefore(
1813LLVMDIBuilderRef Builder,LLVMMetadataRef LabelInfo,
1814LLVMMetadataRef Location,LLVMValueRef InsertBefore) {
1815DbgInstPtr DbgInst =unwrap(Builder)->insertLabel(
1816 unwrapDI<DILabel>(LabelInfo), unwrapDI<DILocation>(Location),
1817 unwrap<Instruction>(InsertBefore));
1818// This assert will fail if the module is in the old debug info format.
1819// This function should only be called if the module is in the new
1820// debug info format.
1821// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
1822// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
1823assert(isa<DbgRecord *>(DbgInst) &&
1824"Function unexpectedly in old debug info format");
1825returnwrap(cast<DbgRecord *>(DbgInst));
1826}
1827
1828LLVMDbgRecordRefLLVMDIBuilderInsertLabelAtEnd(
1829LLVMDIBuilderRef Builder,LLVMMetadataRef LabelInfo,
1830LLVMMetadataRef Location,LLVMBasicBlockRef InsertAtEnd) {
1831DbgInstPtr DbgInst =unwrap(Builder)->insertLabel(
1832 unwrapDI<DILabel>(LabelInfo), unwrapDI<DILocation>(Location),
1833unwrap(InsertAtEnd));
1834// This assert will fail if the module is in the old debug info format.
1835// This function should only be called if the module is in the new
1836// debug info format.
1837// See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
1838// LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
1839assert(isa<DbgRecord *>(DbgInst) &&
1840"Function unexpectedly in old debug info format");
1841returnwrap(cast<DbgRecord *>(DbgInst));
1842}
1843
1844LLVMMetadataKindLLVMGetMetadataKind(LLVMMetadataRefMetadata) {
1845switch(unwrap(Metadata)->getMetadataID()) {
1846#define HANDLE_METADATA_LEAF(CLASS) \
1847 case Metadata::CLASS##Kind: \
1848 return (LLVMMetadataKind)LLVM##CLASS##MetadataKind;
1849#include "llvm/IR/Metadata.def"
1850default:
1851return (LLVMMetadataKind)LLVMGenericDINodeMetadataKind;
1852 }
1853}
1854
1855AssignmentInstRangeat::getAssignmentInsts(DIAssignID *ID) {
1856assert(ID &&"Expected non-null ID");
1857LLVMContext &Ctx =ID->getContext();
1858auto &Map = Ctx.pImpl->AssignmentIDToInstrs;
1859
1860auto MapIt = Map.find(ID);
1861if (MapIt == Map.end())
1862returnmake_range(nullptr,nullptr);
1863
1864returnmake_range(MapIt->second.begin(), MapIt->second.end());
1865}
1866
1867AssignmentMarkerRangeat::getAssignmentMarkers(DIAssignID *ID) {
1868assert(ID &&"Expected non-null ID");
1869LLVMContext &Ctx =ID->getContext();
1870
1871auto *IDAsValue =MetadataAsValue::getIfExists(Ctx,ID);
1872
1873// The ID is only used wrapped in MetadataAsValue(ID), so lets check that
1874// one of those already exists first.
1875if (!IDAsValue)
1876returnmake_range(Value::user_iterator(),Value::user_iterator());
1877
1878returnmake_range(IDAsValue->user_begin(), IDAsValue->user_end());
1879}
1880
1881voidat::deleteAssignmentMarkers(constInstruction *Inst) {
1882autoRange =getAssignmentMarkers(Inst);
1883SmallVector<DbgVariableRecord *> DVRAssigns =getDVRAssignmentMarkers(Inst);
1884if (Range.empty() && DVRAssigns.empty())
1885return;
1886SmallVector<DbgAssignIntrinsic *> ToDelete(Range.begin(),Range.end());
1887for (auto *DAI : ToDelete)
1888 DAI->eraseFromParent();
1889for (auto *DVR : DVRAssigns)
1890 DVR->eraseFromParent();
1891}
1892
1893voidat::RAUW(DIAssignID *Old,DIAssignID *New) {
1894// Replace attachments.
1895AssignmentInstRange InstRange =getAssignmentInsts(Old);
1896// Use intermediate storage for the instruction ptrs because the
1897// getAssignmentInsts range iterators will be invalidated by adding and
1898// removing DIAssignID attachments.
1899SmallVector<Instruction *> InstVec(InstRange.begin(), InstRange.end());
1900for (auto *I : InstVec)
1901I->setMetadata(LLVMContext::MD_DIAssignID, New);
1902
1903 Old->replaceAllUsesWith(New);
1904}
1905
1906voidat::deleteAll(Function *F) {
1907SmallVector<DbgAssignIntrinsic *, 12> ToDelete;
1908SmallVector<DbgVariableRecord *, 12> DPToDelete;
1909for (BasicBlock &BB : *F) {
1910for (Instruction &I : BB) {
1911for (DbgVariableRecord &DVR :filterDbgVars(I.getDbgRecordRange()))
1912if (DVR.isDbgAssign())
1913 DPToDelete.push_back(&DVR);
1914if (auto *DAI = dyn_cast<DbgAssignIntrinsic>(&I))
1915 ToDelete.push_back(DAI);
1916else
1917I.setMetadata(LLVMContext::MD_DIAssignID,nullptr);
1918 }
1919 }
1920for (auto *DAI : ToDelete)
1921 DAI->eraseFromParent();
1922for (auto *DVR : DPToDelete)
1923 DVR->eraseFromParent();
1924}
1925
1926/// FIXME: Remove this wrapper function and call
1927/// DIExpression::calculateFragmentIntersect directly.
1928template <typename T>
1929boolcalculateFragmentIntersectImpl(
1930constDataLayout &DL,constValue *Dest,uint64_t SliceOffsetInBits,
1931uint64_t SliceSizeInBits,constT *AssignRecord,
1932 std::optional<DIExpression::FragmentInfo> &Result) {
1933// No overlap if this DbgRecord describes a killed location.
1934if (AssignRecord->isKillAddress())
1935returnfalse;
1936
1937 int64_t AddrOffsetInBits;
1938 {
1939 int64_t AddrOffsetInBytes;
1940SmallVector<uint64_t> PostOffsetOps;//< Unused.
1941// Bail if we can't find a constant offset (or none) in the expression.
1942if (!AssignRecord->getAddressExpression()->extractLeadingOffset(
1943 AddrOffsetInBytes, PostOffsetOps))
1944returnfalse;
1945 AddrOffsetInBits = AddrOffsetInBytes * 8;
1946 }
1947
1948Value *Addr = AssignRecord->getAddress();
1949// FIXME: It may not always be zero.
1950 int64_t BitExtractOffsetInBits = 0;
1951DIExpression::FragmentInfo VarFrag =
1952 AssignRecord->getFragmentOrEntireVariable();
1953
1954 int64_t OffsetFromLocationInBits;//< Unused.
1955returnDIExpression::calculateFragmentIntersect(
1956DL, Dest, SliceOffsetInBits, SliceSizeInBits,Addr, AddrOffsetInBits,
1957 BitExtractOffsetInBits, VarFrag, Result, OffsetFromLocationInBits);
1958}
1959
1960/// FIXME: Remove this wrapper function and call
1961/// DIExpression::calculateFragmentIntersect directly.
1962boolat::calculateFragmentIntersect(
1963constDataLayout &DL,constValue *Dest,uint64_t SliceOffsetInBits,
1964uint64_t SliceSizeInBits,constDbgAssignIntrinsic *DbgAssign,
1965 std::optional<DIExpression::FragmentInfo> &Result) {
1966returncalculateFragmentIntersectImpl(DL, Dest, SliceOffsetInBits,
1967 SliceSizeInBits, DbgAssign, Result);
1968}
1969
1970/// FIXME: Remove this wrapper function and call
1971/// DIExpression::calculateFragmentIntersect directly.
1972boolat::calculateFragmentIntersect(
1973constDataLayout &DL,constValue *Dest,uint64_t SliceOffsetInBits,
1974uint64_t SliceSizeInBits,constDbgVariableRecord *DVRAssign,
1975 std::optional<DIExpression::FragmentInfo> &Result) {
1976returncalculateFragmentIntersectImpl(DL, Dest, SliceOffsetInBits,
1977 SliceSizeInBits, DVRAssign, Result);
1978}
1979
1980/// Update inlined instructions' DIAssignID metadata. We need to do this
1981/// otherwise a function inlined more than once into the same function
1982/// will cause DIAssignID to be shared by many instructions.
1983voidat::remapAssignID(DenseMap<DIAssignID *, DIAssignID *> &Map,
1984Instruction &I) {
1985auto GetNewID = [&Map](Metadata *Old) {
1986DIAssignID *OldID = cast<DIAssignID>(Old);
1987if (DIAssignID *NewID = Map.lookup(OldID))
1988return NewID;
1989DIAssignID *NewID =DIAssignID::getDistinct(OldID->getContext());
1990 Map[OldID] = NewID;
1991return NewID;
1992 };
1993// If we find a DIAssignID attachment or use, replace it with a new version.
1994for (DbgVariableRecord &DVR :filterDbgVars(I.getDbgRecordRange())) {
1995if (DVR.isDbgAssign())
1996 DVR.setAssignId(GetNewID(DVR.getAssignID()));
1997 }
1998if (auto *ID =I.getMetadata(LLVMContext::MD_DIAssignID))
1999I.setMetadata(LLVMContext::MD_DIAssignID, GetNewID(ID));
2000elseif (auto *DAI = dyn_cast<DbgAssignIntrinsic>(&I))
2001 DAI->setAssignId(GetNewID(DAI->getAssignID()));
2002}
2003
2004/// Collect constant properies (base, size, offset) of \p StoreDest.
2005/// Return std::nullopt if any properties are not constants or the
2006/// offset from the base pointer is negative.
2007static std::optional<AssignmentInfo>
2008getAssignmentInfoImpl(constDataLayout &DL,constValue *StoreDest,
2009TypeSize SizeInBits) {
2010if (SizeInBits.isScalable())
2011return std::nullopt;
2012APInt GEPOffset(DL.getIndexTypeSizeInBits(StoreDest->getType()), 0);
2013constValue *Base = StoreDest->stripAndAccumulateConstantOffsets(
2014DL, GEPOffset,/*AllowNonInbounds*/true);
2015
2016if (GEPOffset.isNegative())
2017return std::nullopt;
2018
2019uint64_t OffsetInBytes = GEPOffset.getLimitedValue();
2020// Check for overflow.
2021if (OffsetInBytes ==UINT64_MAX)
2022return std::nullopt;
2023if (constauto *Alloca = dyn_cast<AllocaInst>(Base))
2024returnAssignmentInfo(DL, Alloca, OffsetInBytes * 8, SizeInBits);
2025return std::nullopt;
2026}
2027
2028std::optional<AssignmentInfo>at::getAssignmentInfo(constDataLayout &DL,
2029constMemIntrinsic *I) {
2030constValue *StoreDest =I->getRawDest();
2031// Assume 8 bit bytes.
2032auto *ConstLengthInBytes = dyn_cast<ConstantInt>(I->getLength());
2033if (!ConstLengthInBytes)
2034// We can't use a non-const size, bail.
2035return std::nullopt;
2036uint64_t SizeInBits = 8 * ConstLengthInBytes->getZExtValue();
2037returngetAssignmentInfoImpl(DL, StoreDest,TypeSize::getFixed(SizeInBits));
2038}
2039
2040std::optional<AssignmentInfo>at::getAssignmentInfo(constDataLayout &DL,
2041constStoreInst *SI) {
2042TypeSize SizeInBits =DL.getTypeSizeInBits(SI->getValueOperand()->getType());
2043returngetAssignmentInfoImpl(DL, SI->getPointerOperand(), SizeInBits);
2044}
2045
2046std::optional<AssignmentInfo>at::getAssignmentInfo(constDataLayout &DL,
2047constAllocaInst *AI) {
2048TypeSize SizeInBits =DL.getTypeSizeInBits(AI->getAllocatedType());
2049returngetAssignmentInfoImpl(DL, AI, SizeInBits);
2050}
2051
2052/// Returns nullptr if the assignment shouldn't be attributed to this variable.
2053staticvoidemitDbgAssign(AssignmentInfo Info,Value *Val,Value *Dest,
2054Instruction &StoreLikeInst,constVarRecord &VarRec,
2055DIBuilder &DIB) {
2056auto *ID = StoreLikeInst.getMetadata(LLVMContext::MD_DIAssignID);
2057assert(ID &&"Store instruction must have DIAssignID metadata");
2058 (void)ID;
2059
2060constuint64_t StoreStartBit =Info.OffsetInBits;
2061constuint64_t StoreEndBit =Info.OffsetInBits +Info.SizeInBits;
2062
2063uint64_t FragStartBit = StoreStartBit;
2064uint64_t FragEndBit = StoreEndBit;
2065
2066bool StoreToWholeVariable =Info.StoreToWholeAlloca;
2067if (autoSize = VarRec.Var->getSizeInBits()) {
2068// NOTE: trackAssignments doesn't understand base expressions yet, so all
2069// variables that reach here are guaranteed to start at offset 0 in the
2070// alloca.
2071constuint64_t VarStartBit = 0;
2072constuint64_t VarEndBit = *Size;
2073
2074// FIXME: trim FragStartBit when nonzero VarStartBit is supported.
2075 FragEndBit = std::min(FragEndBit, VarEndBit);
2076
2077// Discard stores to bits outside this variable.
2078if (FragStartBit >= FragEndBit)
2079return;
2080
2081 StoreToWholeVariable = FragStartBit <= VarStartBit && FragEndBit >= *Size;
2082 }
2083
2084DIExpression *Expr =DIExpression::get(StoreLikeInst.getContext(), {});
2085if (!StoreToWholeVariable) {
2086auto R =DIExpression::createFragmentExpression(Expr, FragStartBit,
2087 FragEndBit - FragStartBit);
2088assert(R.has_value() &&"failed to create fragment expression");
2089 Expr = *R;
2090 }
2091DIExpression *AddrExpr =DIExpression::get(StoreLikeInst.getContext(), {});
2092if (StoreLikeInst.getParent()->IsNewDbgInfoFormat) {
2093auto *Assign =DbgVariableRecord::createLinkedDVRAssign(
2094 &StoreLikeInst, Val, VarRec.Var, Expr, Dest, AddrExpr, VarRec.DL);
2095 (void)Assign;
2096LLVM_DEBUG(if (Assign)errs() <<" > INSERT: " << *Assign <<"\n");
2097return;
2098 }
2099auto Assign = DIB.insertDbgAssign(&StoreLikeInst, Val, VarRec.Var, Expr, Dest,
2100 AddrExpr, VarRec.DL);
2101 (void)Assign;
2102LLVM_DEBUG(if (!Assign.isNull()) {
2103 if (const auto *Record = dyn_cast<DbgRecord *>(Assign))
2104 errs() <<" > INSERT: " << *Record <<"\n";
2105 else
2106 errs() <<" > INSERT: " << *cast<Instruction *>(Assign) <<"\n";
2107 });
2108}
2109
2110#undef DEBUG_TYPE// Silence redefinition warning (from ConstantsContext.h).
2111#define DEBUG_TYPE "assignment-tracking"
2112
2113voidat::trackAssignments(Function::iterator Start,Function::iteratorEnd,
2114constStorageToVarsMap &Vars,constDataLayout &DL,
2115bool DebugPrints) {
2116// Early-exit if there are no interesting variables.
2117if (Vars.empty())
2118return;
2119
2120auto &Ctx = Start->getContext();
2121auto &Module = *Start->getModule();
2122
2123// Undef type doesn't matter, so long as it isn't void. Let's just use i1.
2124auto *Undef =UndefValue::get(Type::getInt1Ty(Ctx));
2125DIBuilder DIB(Module,/*AllowUnresolved*/false);
2126
2127// Scan the instructions looking for stores to local variables' storage.
2128LLVM_DEBUG(errs() <<"# Scanning instructions\n");
2129for (auto BBI = Start; BBI !=End; ++BBI) {
2130for (Instruction &I : *BBI) {
2131
2132 std::optional<AssignmentInfo>Info;
2133Value *ValueComponent =nullptr;
2134Value *DestComponent =nullptr;
2135if (auto *AI = dyn_cast<AllocaInst>(&I)) {
2136// We want to track the variable's stack home from its alloca's
2137// position onwards so we treat it as an assignment (where the stored
2138// value is Undef).
2139Info =getAssignmentInfo(DL, AI);
2140 ValueComponent = Undef;
2141 DestComponent = AI;
2142 }elseif (auto *SI = dyn_cast<StoreInst>(&I)) {
2143Info =getAssignmentInfo(DL, SI);
2144 ValueComponent = SI->getValueOperand();
2145 DestComponent = SI->getPointerOperand();
2146 }elseif (auto *MI = dyn_cast<MemTransferInst>(&I)) {
2147Info =getAssignmentInfo(DL,MI);
2148// May not be able to represent this value easily.
2149 ValueComponent = Undef;
2150 DestComponent =MI->getOperand(0);
2151 }elseif (auto *MI = dyn_cast<MemSetInst>(&I)) {
2152Info =getAssignmentInfo(DL,MI);
2153// If we're zero-initing we can state the assigned value is zero,
2154// otherwise use undef.
2155auto *ConstValue = dyn_cast<ConstantInt>(MI->getOperand(1));
2156if (ConstValue && ConstValue->isZero())
2157 ValueComponent = ConstValue;
2158else
2159 ValueComponent = Undef;
2160 DestComponent =MI->getOperand(0);
2161 }else {
2162// Not a store-like instruction.
2163continue;
2164 }
2165
2166assert(ValueComponent && DestComponent);
2167LLVM_DEBUG(errs() <<"SCAN: Found store-like: " <<I <<"\n");
2168
2169// Check if getAssignmentInfo failed to understand this store.
2170if (!Info.has_value()) {
2171LLVM_DEBUG(
2172errs()
2173 <<" | SKIP: Untrackable store (e.g. through non-const gep)\n");
2174continue;
2175 }
2176LLVM_DEBUG(errs() <<" | BASE: " << *Info->Base <<"\n");
2177
2178// Check if the store destination is a local variable with debug info.
2179auto LocalIt = Vars.find(Info->Base);
2180if (LocalIt == Vars.end()) {
2181LLVM_DEBUG(
2182errs()
2183 <<" | SKIP: Base address not associated with local variable\n");
2184continue;
2185 }
2186
2187DIAssignID *ID =
2188 cast_or_null<DIAssignID>(I.getMetadata(LLVMContext::MD_DIAssignID));
2189if (!ID) {
2190ID =DIAssignID::getDistinct(Ctx);
2191I.setMetadata(LLVMContext::MD_DIAssignID,ID);
2192 }
2193
2194for (constVarRecord &R : LocalIt->second)
2195emitDbgAssign(*Info, ValueComponent, DestComponent,I, R, DIB);
2196 }
2197 }
2198}
2199
2200bool AssignmentTrackingPass::runOnFunction(Function &F) {
2201// No value in assignment tracking without optimisations.
2202if (F.hasFnAttribute(Attribute::OptimizeNone))
2203return/*Changed*/false;
2204
2205bool Changed =false;
2206auto *DL = &F.getDataLayout();
2207// Collect a map of {backing storage : dbg.declares} (currently "backing
2208// storage" is limited to Allocas). We'll use this to find dbg.declares to
2209// delete after running `trackAssignments`.
2210DenseMap<const AllocaInst *, SmallPtrSet<DbgDeclareInst *, 2>> DbgDeclares;
2211DenseMap<const AllocaInst *, SmallPtrSet<DbgVariableRecord *, 2>> DVRDeclares;
2212// Create another similar map of {storage : variables} that we'll pass to
2213// trackAssignments.
2214StorageToVarsMap Vars;
2215auto ProcessDeclare = [&](auto *Declare,auto &DeclareList) {
2216// FIXME: trackAssignments doesn't let you specify any modifiers to the
2217// variable (e.g. fragment) or location (e.g. offset), so we have to
2218// leave dbg.declares with non-empty expressions in place.
2219if (Declare->getExpression()->getNumElements() != 0)
2220return;
2221if (!Declare->getAddress())
2222return;
2223if (AllocaInst *Alloca =
2224 dyn_cast<AllocaInst>(Declare->getAddress()->stripPointerCasts())) {
2225// FIXME: Skip VLAs for now (let these variables use dbg.declares).
2226if (!Alloca->isStaticAlloca())
2227return;
2228// Similarly, skip scalable vectors (use dbg.declares instead).
2229if (auto Sz = Alloca->getAllocationSize(*DL); Sz && Sz->isScalable())
2230return;
2231 DeclareList[Alloca].insert(Declare);
2232 Vars[Alloca].insert(VarRecord(Declare));
2233 }
2234 };
2235for (auto &BB :F) {
2236for (auto &I : BB) {
2237for (DbgVariableRecord &DVR :filterDbgVars(I.getDbgRecordRange())) {
2238if (DVR.isDbgDeclare())
2239 ProcessDeclare(&DVR, DVRDeclares);
2240 }
2241if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(&I))
2242 ProcessDeclare(DDI, DbgDeclares);
2243 }
2244 }
2245
2246// FIXME: Locals can be backed by caller allocas (sret, byval).
2247// Note: trackAssignments doesn't respect dbg.declare's IR positions (as it
2248// doesn't "understand" dbg.declares). However, this doesn't appear to break
2249// any rules given this description of dbg.declare from
2250// llvm/docs/SourceLevelDebugging.rst:
2251//
2252// It is not control-dependent, meaning that if a call to llvm.dbg.declare
2253// exists and has a valid location argument, that address is considered to
2254// be the true home of the variable across its entire lifetime.
2255trackAssignments(F.begin(),F.end(), Vars, *DL);
2256
2257// Delete dbg.declares for variables now tracked with assignment tracking.
2258auto DeleteSubsumedDeclare = [&](constauto &Markers,auto &Declares) {
2259 (void)Markers;
2260for (auto *Declare : Declares) {
2261// Assert that the alloca that Declare uses is now linked to a dbg.assign
2262// describing the same variable (i.e. check that this dbg.declare has
2263// been replaced by a dbg.assign). Use DebugVariableAggregate to Discard
2264// the fragment part because trackAssignments may alter the
2265// fragment. e.g. if the alloca is smaller than the variable, then
2266// trackAssignments will create an alloca-sized fragment for the
2267// dbg.assign.
2268assert(llvm::any_of(Markers, [Declare](auto *Assign) {
2269returnDebugVariableAggregate(Assign) ==
2270DebugVariableAggregate(Declare);
2271 }));
2272// Delete Declare because the variable location is now tracked using
2273// assignment tracking.
2274 Declare->eraseFromParent();
2275 Changed =true;
2276 }
2277 };
2278for (auto &P : DbgDeclares)
2279 DeleteSubsumedDeclare(at::getAssignmentMarkers(P.first),P.second);
2280for (auto &P : DVRDeclares)
2281 DeleteSubsumedDeclare(at::getDVRAssignmentMarkers(P.first),P.second);
2282return Changed;
2283}
2284
2285staticconstchar *AssignmentTrackingModuleFlag =
2286"debug-info-assignment-tracking";
2287
2288staticvoidsetAssignmentTrackingModuleFlag(Module &M) {
2289 M.setModuleFlag(Module::ModFlagBehavior::Max,AssignmentTrackingModuleFlag,
2290ConstantAsMetadata::get(
2291 ConstantInt::get(Type::getInt1Ty(M.getContext()), 1)));
2292}
2293
2294staticboolgetAssignmentTrackingModuleFlag(constModule &M) {
2295Metadata *Value = M.getModuleFlag(AssignmentTrackingModuleFlag);
2296returnValue && !cast<ConstantAsMetadata>(Value)->getValue()->isZeroValue();
2297}
2298
2299boolllvm::isAssignmentTrackingEnabled(constModule &M) {
2300returngetAssignmentTrackingModuleFlag(M);
2301}
2302
2303PreservedAnalysesAssignmentTrackingPass::run(Function &F,
2304FunctionAnalysisManager &AM) {
2305if (!runOnFunction(F))
2306returnPreservedAnalyses::all();
2307
2308// Record that this module uses assignment tracking. It doesn't matter that
2309// some functons in the module may not use it - the debug info in those
2310// functions will still be handled properly.
2311setAssignmentTrackingModuleFlag(*F.getParent());
2312
2313// Q: Can we return a less conservative set than just CFGAnalyses? Can we
2314// return PreservedAnalyses::all()?
2315PreservedAnalyses PA;
2316 PA.preserveSet<CFGAnalyses>();
2317return PA;
2318}
2319
2320PreservedAnalysesAssignmentTrackingPass::run(Module &M,
2321ModuleAnalysisManager &AM) {
2322bool Changed =false;
2323for (auto &F : M)
2324 Changed |= runOnFunction(F);
2325
2326if (!Changed)
2327returnPreservedAnalyses::all();
2328
2329// Record that this module uses assignment tracking.
2330setAssignmentTrackingModuleFlag(M);
2331
2332// Q: Can we return a less conservative set than just CFGAnalyses? Can we
2333// return PreservedAnalyses::all()?
2334PreservedAnalyses PA;
2335 PA.preserveSet<CFGAnalyses>();
2336return PA;
2337}
2338
2339#undef DEBUG_TYPE
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Info
Analysis containing CSE Info
Definition:CSEInfo.cpp:27
Casting.h
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
getSubprogram
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
Definition:DIBuilder.cpp:856
createImportedModule
static DIImportedEntity * createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context, Metadata *NS, DIFile *File, unsigned Line, StringRef Name, DINodeArray Elements, SmallVectorImpl< TrackingMDNodeRef > &ImportedModules)
Definition:DIBuilder.cpp:161
DIBuilder.h
DebugInfoMetadata.h
setAssignmentTrackingModuleFlag
static void setAssignmentTrackingModuleFlag(Module &M)
Definition:DebugInfo.cpp:2288
pack_into_DISPFlags
static DISubprogram::DISPFlags pack_into_DISPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized)
Definition:DebugInfo.cpp:1049
stripLoopMDLoc
static Metadata * stripLoopMDLoc(const SmallPtrSetImpl< Metadata * > &AllDILocation, const SmallPtrSetImpl< Metadata * > &DIReachable, Metadata *MD)
Definition:DebugInfo.cpp:497
updateLoopMetadataDebugLocationsImpl
static MDNode * updateLoopMetadataDebugLocationsImpl(MDNode *OrigLoopID, function_ref< Metadata *(Metadata *)> Updater)
Definition:DebugInfo.cpp:415
stripDebugLocFromLoopID
static MDNode * stripDebugLocFromLoopID(MDNode *N)
Definition:DebugInfo.cpp:534
calculateFragmentIntersectImpl
bool calculateFragmentIntersectImpl(const DataLayout &DL, const Value *Dest, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const T *AssignRecord, std::optional< DIExpression::FragmentInfo > &Result)
FIXME: Remove this wrapper function and call DIExpression::calculateFragmentIntersect directly.
Definition:DebugInfo.cpp:1929
AssignmentTrackingModuleFlag
static const char * AssignmentTrackingModuleFlag
Definition:DebugInfo.cpp:2285
map_from_llvmDIFlags
static DINode::DIFlags map_from_llvmDIFlags(LLVMDIFlags Flags)
Definition:DebugInfo.cpp:1040
map_from_llvmDWARFsourcelanguage
static unsigned map_from_llvmDWARFsourcelanguage(LLVMDWARFSourceLanguage lang)
Definition:DebugInfo.cpp:1025
emitDbgAssign
static void emitDbgAssign(AssignmentInfo Info, Value *Val, Value *Dest, Instruction &StoreLikeInst, const VarRecord &VarRec, DIBuilder &DIB)
Returns nullptr if the assignment shouldn't be attributed to this variable.
Definition:DebugInfo.cpp:2053
map_to_llvmDIFlags
static LLVMDIFlags map_to_llvmDIFlags(DINode::DIFlags Flags)
Definition:DebugInfo.cpp:1044
findDbgIntrinsics
static void findDbgIntrinsics(SmallVectorImpl< IntrinsicT * > &Result, Value *V, SmallVectorImpl< DbgVariableRecord * > *DbgVariableRecords)
Definition:DebugInfo.cpp:102
getAssignmentTrackingModuleFlag
static bool getAssignmentTrackingModuleFlag(const Module &M)
Definition:DebugInfo.cpp:2294
isAllDILocation
static bool isAllDILocation(SmallPtrSetImpl< Metadata * > &Visited, SmallPtrSetImpl< Metadata * > &AllDILocation, const SmallPtrSetImpl< Metadata * > &DIReachable, Metadata *MD)
Definition:DebugInfo.cpp:471
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:450
unwrapDI
DIT * unwrapDI(LLVMMetadataRef Ref)
Definition:DebugInfo.cpp:1036
getAssignmentInfoImpl
static std::optional< AssignmentInfo > getAssignmentInfoImpl(const DataLayout &DL, const Value *StoreDest, TypeSize SizeInBits)
Collect constant properies (base, size, offset) of StoreDest.
Definition:DebugInfo.cpp:2008
DebugLoc.h
DebugProgramInstruction.h
LLVM_DEBUG
#define LLVM_DEBUG(...)
Definition:Debug.h:106
DenseMap.h
This file defines the DenseMap class.
DenseSet.h
This file defines the DenseSet and SmallDenseSet classes.
Addr
uint64_t Addr
Definition:ELFObjHandler.cpp:79
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Size
uint64_t Size
Definition:ELFObjHandler.cpp:81
End
bool End
Definition:ELF_riscv.cpp:480
GVMaterializer.h
MI
IRTranslator LLVM IR MI
Definition:IRTranslator.cpp:112
BasicBlock.h
Function.h
Instruction.h
IntrinsicInst.h
Module.h
Module.h This file contains the declarations for the Module class.
PassManager.h
This header defines various interfaces for pass management in LLVM.
LLVMContextImpl.h
LLVMContext.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
getDebugLoc
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first found DebugLoc that has a DILocation, given a range of instructions.
Definition:MachineInstrBundle.cpp:109
Metadata.h
This file contains the declarations for metadata subclasses.
Range
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
II
uint64_t IntrinsicInst * II
Definition:NVVMIntrRange.cpp:51
P
#define P(N)
Markers
R600 Emit Clause Markers
Definition:R600EmitClauseMarkers.cpp:328
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
STLExtras.h
This file contains some templates that are useful if you are working with the STL at all.
SmallPtrSet.h
This file defines the SmallPtrSet class.
SmallVector.h
This file defines the SmallVector class.
StringRef.h
getFlags
static uint32_t getFlags(const Symbol *Sym)
Definition:TapiFile.cpp:26
BaseTy
Node
Definition:ItaniumDemangle.h:163
T
llvm::APInt
Class for arbitrary precision integers.
Definition:APInt.h:78
llvm::APInt::isNegative
bool isNegative() const
Determine sign of this APInt.
Definition:APInt.h:329
llvm::APInt::getLimitedValue
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
Definition:APInt.h:475
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition:Instructions.h:63
llvm::AllocaInst::getAllocatedType
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
Definition:Instructions.h:117
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition:PassManager.h:253
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::AssignmentTrackingPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition:DebugInfo.cpp:2303
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::CFGAnalyses
Represents analyses that only rely on functions' control flow.
Definition:Analysis.h:72
llvm::ConstantAsMetadata::get
static ConstantAsMetadata * get(Constant *C)
Definition:Metadata.h:532
llvm::DIArgList
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
Definition:DebugInfoMetadata.h:3976
llvm::DIArgList::getAllDbgVariableRecordUsers
SmallVector< DbgVariableRecord * > getAllDbgVariableRecordUsers()
Definition:DebugInfoMetadata.h:4006
llvm::DIAssignID
Assignment ID.
Definition:DebugInfoMetadata.h:309
llvm::DIAssignID::getDistinct
static DIAssignID * getDistinct(LLVMContext &Context)
Definition:DebugInfoMetadata.h:331
llvm::DIBuilder
Definition:DIBuilder.h:45
llvm::DIBuilder::insertDbgAssign
DbgInstPtr insertDbgAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *SrcVar, DIExpression *ValExpr, Value *Addr, DIExpression *AddrExpr, const DILocation *DL)
Insert a new llvm.dbg.assign intrinsic call.
Definition:DIBuilder.cpp:978
llvm::DICompileUnit
Compile unit.
Definition:DebugInfoMetadata.h:1469
llvm::DICompileUnit::DebugNameTableKind::Default
@ Default
llvm::DICompileUnit::DebugEmissionKind
DebugEmissionKind
Definition:DebugInfoMetadata.h:1474
llvm::DICompileUnit::LineTablesOnly
@ LineTablesOnly
Definition:DebugInfoMetadata.h:1477
llvm::DIExpression
DWARF expression.
Definition:DebugInfoMetadata.h:2763
llvm::DIExpression::calculateFragmentIntersect
static bool calculateFragmentIntersect(const DataLayout &DL, const Value *SliceStart, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits, int64_t DbgExtractOffsetInBits, DIExpression::FragmentInfo VarFrag, std::optional< DIExpression::FragmentInfo > &Result, int64_t &OffsetFromLocationInBits)
Computes a fragment, bit-extract operation if needed, and new constant offset to describe a part of a...
Definition:DebugInfoMetadata.cpp:2099
llvm::DIExpression::createFragmentExpression
static std::optional< DIExpression * > createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
Create a DIExpression to describe one part of an aggregate variable that is fragmented across multipl...
Definition:DebugInfoMetadata.cpp:2006
llvm::DIGlobalVariableExpression
A pair of DIGlobalVariable and DIExpression.
Definition:DebugInfoMetadata.h:3761
llvm::DILocalScope::getSubprogram
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
Definition:DebugInfoMetadata.cpp:1051
llvm::DILocalVariable
Local variable.
Definition:DebugInfoMetadata.h:3460
llvm::DILocalVariable::getScope
DILocalScope * getScope() const
Get the local scope for this variable.
Definition:DebugInfoMetadata.h:3518
llvm::DILocation
Debug location.
Definition:DebugInfoMetadata.h:1988
llvm::DILocation::getMergedLocation
static DILocation * getMergedLocation(DILocation *LocA, DILocation *LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
Definition:DebugInfoMetadata.cpp:121
llvm::DINode
Tagged DWARF-like metadata node.
Definition:DebugInfoMetadata.h:135
llvm::DINode::DIFlags
DIFlags
Debug info flags.
Definition:DebugInfoMetadata.h:174
llvm::DIScope
Base class for scope-like contexts.
Definition:DebugInfoMetadata.h:519
llvm::DIScope::getName
StringRef getName() const
Definition:DebugInfoMetadata.cpp:368
llvm::DIScope::getFile
DIFile * getFile() const
Definition:DebugInfoMetadata.h:527
llvm::DIScope::getScope
DIScope * getScope() const
Definition:DebugInfoMetadata.cpp:344
llvm::DISubprogram
Subprogram description.
Definition:DebugInfoMetadata.h:1710
llvm::DISubprogram::toSPFlags
static DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, unsigned Virtuality=SPFlagNonvirtual, bool IsMainSubprogram=false)
Definition:DebugInfoMetadata.cpp:1036
llvm::DISubprogram::DISPFlags
DISPFlags
Debug info subprogram flags.
Definition:DebugInfoMetadata.h:1725
llvm::DISubroutineType
Type array for a subprogram.
Definition:DebugInfoMetadata.h:1412
llvm::DIType
Base class for types.
Definition:DebugInfoMetadata.h:710
llvm::DIVariable::getSizeInBits
std::optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
Definition:DebugInfoMetadata.cpp:1331
llvm::DIVariable::getType
DIType * getType() const
Definition:DebugInfoMetadata.h:2711
llvm::DWARFExpression::Operation
This class represents an Operation in the Expression.
Definition:DWARFExpression.h:32
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition:DataLayout.h:63
llvm::DbgAssignIntrinsic
This represents the llvm.dbg.assign instruction.
Definition:IntrinsicInst.h:492
llvm::DbgDeclareInst
This represents the llvm.dbg.declare instruction.
Definition:IntrinsicInst.h:448
llvm::DbgRecord
Base class for non-instruction debug metadata records that have positions within IR.
Definition:DebugProgramInstruction.h:134
llvm::DbgRecord::getDebugLoc
DebugLoc getDebugLoc() const
Definition:DebugProgramInstruction.h:208
llvm::DbgRecord::getContext
LLVMContext & getContext()
Definition:DebugProgramInstruction.cpp:529
llvm::DbgValueInst
This represents the llvm.dbg.value instruction.
Definition:IntrinsicInst.h:468
llvm::DbgVariableIntrinsic
This is the common base class for debug info intrinsics for variables.
Definition:IntrinsicInst.h:308
llvm::DbgVariableRecord
Record of a variable value-assignment, aka a non instruction representation of the dbg....
Definition:DebugProgramInstruction.h:270
llvm::DbgVariableRecord::createLinkedDVRAssign
static DbgVariableRecord * createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
Definition:DebugProgramInstruction.cpp:220
llvm::DebugInfoFinder::processInstruction
void processInstruction(const Module &M, const Instruction &I)
Process a single instruction and collect debug info anchors.
Definition:DebugInfo.cpp:256
llvm::DebugInfoFinder::processModule
void processModule(const Module &M)
Process entire module and collect debug info anchors.
Definition:DebugInfo.cpp:212
llvm::DebugInfoFinder::processVariable
void processVariable(const Module &M, const DILocalVariable *DVI)
Process a DILocalVariable.
Definition:DebugInfo.cpp:354
llvm::DebugInfoFinder::processSubprogram
void processSubprogram(DISubprogram *SP)
Process subprogram.
Definition:DebugInfo.cpp:331
llvm::DebugInfoFinder::processLocation
void processLocation(const Module &M, const DILocation *Loc)
Process debug info location.
Definition:DebugInfo.cpp:268
llvm::DebugInfoFinder::reset
void reset()
Clear all lists.
Definition:DebugInfo.cpp:203
llvm::DebugInfoFinder::processDbgRecord
void processDbgRecord(const Module &M, const DbgRecord &DR)
Process a DbgRecord (e.g, treat a DbgVariableRecord like a DbgVariableIntrinsic).
Definition:DebugInfo.cpp:275
llvm::DebugLoc
A debug info location.
Definition:DebugLoc.h:33
llvm::DebugLoc::get
DILocation * get() const
Get the underlying DILocation.
Definition:DebugLoc.cpp:20
llvm::DebugLoc::getScope
MDNode * getScope() const
Definition:DebugLoc.cpp:34
llvm::DebugLoc::getInlinedAt
DILocation * getInlinedAt() const
Definition:DebugLoc.cpp:39
llvm::DebugVariableAggregate
Identifies a unique instance of a whole variable (discards/ignores fragment information).
Definition:DebugInfoMetadata.h:4102
llvm::DenseMapBase::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:194
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition:DenseMap.h:156
llvm::DenseMapBase::empty
bool empty() const
Definition:DenseMap.h:98
llvm::DenseMapBase::end
iterator end()
Definition:DenseMap.h:84
llvm::DenseMapBase::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition:DenseMap.h:211
llvm::DenseMap
Definition:DenseMap.h:727
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition:DenseSet.h:278
llvm::Function
Definition:Function.h:63
llvm::Function::iterator
BasicBlockListType::iterator iterator
Definition:Function.h:68
llvm::Function::getSubprogram
DISubprogram * getSubprogram() const
Get the attached subprogram.
Definition:Metadata.cpp:1874
llvm::GVMaterializer
Definition:GVMaterializer.h:28
llvm::Instruction
Definition:Instruction.h:68
llvm::Instruction::mergeDIAssignID
void mergeDIAssignID(ArrayRef< const Instruction * > SourceInstructions)
Merge the DIAssignID metadata from this instruction and those attached to instructions in SourceInstr...
Definition:DebugInfo.cpp:953
llvm::Instruction::dropLocation
void dropLocation()
Drop the instruction's debug location.
Definition:DebugInfo.cpp:984
llvm::Instruction::getDebugLoc
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition:Instruction.h:492
llvm::Instruction::getFunction
const Function * getFunction() const
Return the function this instruction belongs to.
Definition:Instruction.cpp:72
llvm::Instruction::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition:Instruction.h:407
llvm::Instruction::setMetadata
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Definition:Metadata.cpp:1679
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:982
llvm::Instruction::applyMergedLocation
void applyMergedLocation(DILocation *LocA, DILocation *LocB)
Merge 2 debug locations and apply it to the Instruction.
Definition:DebugInfo.cpp:949
llvm::Instruction::setDebugLoc
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition:Instruction.h:489
llvm::IntrinsicInst::mayLowerToFunctionCall
static bool mayLowerToFunctionCall(Intrinsic::ID IID)
Check if the intrinsic might lower into a regular function call in the course of IR transformations.
Definition:IntrinsicInst.cpp:36
llvm::LLVMContextImpl::AssignmentIDToInstrs
DenseMap< DIAssignID *, SmallVector< Instruction *, 1 > > AssignmentIDToInstrs
Map DIAssignID -> Instructions with that attachment.
Definition:LLVMContextImpl.h:1642
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:LLVMContext.h:67
llvm::LLVMContext::pImpl
LLVMContextImpl *const pImpl
Definition:LLVMContext.h:69
llvm::LocalAsMetadata
Definition:Metadata.h:549
llvm::LocalAsMetadata::getIfExists
static LocalAsMetadata * getIfExists(Value *Local)
Definition:Metadata.h:562
llvm::MDNode
Metadata node.
Definition:Metadata.h:1073
llvm::MDNode::replaceOperandWith
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
Definition:Metadata.cpp:1077
llvm::MDNode::getDistinct
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition:Metadata.h:1557
llvm::MDNode::replaceAllUsesWith
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
Definition:Metadata.h:1270
llvm::MDNode::deleteTemporary
static void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
Definition:Metadata.cpp:1049
llvm::MDNode::getOperand
const MDOperand & getOperand(unsigned I) const
Definition:Metadata.h:1434
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition:Metadata.h:1549
llvm::MDNode::getNumOperands
unsigned getNumOperands() const
Return number of MDNode operands.
Definition:Metadata.h:1440
llvm::MDNode::isDistinct
bool isDistinct() const
Definition:Metadata.h:1256
llvm::MDNode::getContext
LLVMContext & getContext() const
Definition:Metadata.h:1237
llvm::MDOperand
Tracking metadata reference owned by Metadata.
Definition:Metadata.h:895
llvm::MDOperand::get
Metadata * get() const
Definition:Metadata.h:924
llvm::MDTuple
Tuple of metadata.
Definition:Metadata.h:1479
llvm::MDTuple::getTemporary
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a temporary node.
Definition:Metadata.h:1526
llvm::MemIntrinsic
This is the common base class for memset/memcpy/memmove.
Definition:IntrinsicInst.h:1205
llvm::MetadataAsValue::getIfExists
static MetadataAsValue * getIfExists(LLVMContext &Context, Metadata *MD)
Definition:Metadata.cpp:111
llvm::Metadata
Root of the metadata hierarchy.
Definition:Metadata.h:62
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::Module::Max
@ Max
Takes the max of the two values, which are required to be integers.
Definition:Module.h:147
llvm::NamedMDNode
A tuple of MDNodes.
Definition:Metadata.h:1737
llvm::NamedMDNode::getName
StringRef getName() const
Definition:Metadata.cpp:1442
llvm::PointerUnion
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition:PointerUnion.h:118
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition:Analysis.h:111
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition:Analysis.h:117
llvm::PreservedAnalyses::preserveSet
void preserveSet()
Mark an analysis set as preserved.
Definition:Analysis.h:146
llvm::SmallPtrSetImplBase::clear
void clear()
Definition:SmallPtrSet.h:97
llvm::SmallPtrSetImpl
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition:SmallPtrSet.h:363
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:452
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:384
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition:SmallPtrSet.h:519
llvm::SmallVectorBase::empty
bool empty() const
Definition:SmallVector.h:81
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:SmallVector.h:573
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition:SmallVector.h:663
llvm::SmallVectorTemplateBase::pop_back
void pop_back()
Definition:SmallVector.h:425
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVectorTemplateCommon::end
iterator end()
Definition:SmallVector.h:269
llvm::SmallVectorTemplateCommon::begin
iterator begin()
Definition:SmallVector.h:267
llvm::SmallVectorTemplateCommon::back
reference back()
Definition:SmallVector.h:308
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StoreInst
An instruction for storing to memory.
Definition:Instructions.h:292
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition:StringRef.h:147
llvm::TinyPtrVector
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
Definition:TinyPtrVector.h:29
llvm::TinyPtrVector::push_back
void push_back(EltTy NewVal)
Definition:TinyPtrVector.h:242
llvm::TypeSize
Definition:TypeSize.h:334
llvm::TypeSize::getFixed
static constexpr TypeSize getFixed(ScalarTy ExactSize)
Definition:TypeSize.h:345
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Type::getInt1Ty
static IntegerType * getInt1Ty(LLVMContext &C)
llvm::UndefValue::get
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition:Constants.cpp:1859
llvm::User
Definition:User.h:44
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition:Value.h:255
llvm::Value::stripAndAccumulateConstantOffsets
const Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr) const
Accumulate the constant offset this value has compared to a base pointer.
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition:Value.cpp:1075
llvm::Value::user_iterator
user_iterator_impl< User > user_iterator
Definition:Value.h:390
llvm::detail::DenseSetImpl::insert
std::pair< iterator, bool > insert(const ValueT &V)
Definition:DenseSet.h:213
llvm::detail::DenseSetImpl::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:95
llvm::details::FixedOrScalableQuantity::isScalable
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition:TypeSize.h:171
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition:STLFunctionalExtras.h:37
llvm::ilist_detail::node_parent_access::getParent
const ParentTy * getParent() const
Definition:ilist_node.h:32
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition:iterator_range.h:42
llvm::iterator_range::end
IteratorT end() const
Definition:iterator_range.h:65
llvm::iterator_range::begin
IteratorT begin() const
Definition:iterator_range.h:64
uint16_t
uint32_t
uint64_t
unsigned
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:1408
LLVMDILocationGetInlinedAt
LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location)
Get the "inline at" location associated with this debug location.
Definition:DebugInfo.cpp:1239
LLVMDIBuilderGetOrCreateArray
LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder, LLVMMetadataRef *Data, size_t NumElements)
Create an array of DI Nodes.
Definition:DebugInfo.cpp:1773
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:1296
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:1193
LLVMDITypeGetSizeInBits
uint64_t LLVMDITypeGetSizeInBits(LLVMMetadataRef DType)
Get the size of this DIType in bits.
Definition:DebugInfo.cpp:1571
LLVMDWARFMacinfoRecordType
LLVMDWARFMacinfoRecordType
Describes the kind of macro declaration used for LLVMDIBuilderCreateMacro.
Definition:DebugInfo.h:211
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:1135
LLVMDIBuilderInsertDeclareRecordAtEnd
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
Definition:DebugInfo.cpp:1700
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:1521
LLVMDIGlobalVariableExpressionGetVariable
LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE)
Retrieves the DIVariable associated with this global variable expression.
Definition:DebugInfo.cpp:1634
LLVMDIBuilderCreateArtificialType
LLVMMetadataRef LLVMDIBuilderCreateArtificialType(LLVMDIBuilderRef Builder, LLVMMetadataRef Type)
Create a uniqued DIType* clone with FlagArtificial set.
Definition:DebugInfo.cpp:1556
LLVMDIBuilderCreateObjectPointerType
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder, LLVMMetadataRef Type, LLVMBool Implicit)
Create a uniqued DIType* clone with FlagObjectPointer.
Definition:DebugInfo.cpp:1435
LLVMDIBuilderFinalize
void LLVMDIBuilderFinalize(LLVMDIBuilderRef Builder)
Construct any deferred debug info descriptors.
Definition:DebugInfo.cpp:1077
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:1159
LLVMDISubprogramGetLine
unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram)
Get the line associated with a given subprogram.
Definition:DebugInfo.cpp:1788
LLVMDIBuilderCreateUnspecifiedType
LLVMMetadataRef LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen)
Create a DWARF unspecified type.
Definition:DebugInfo.cpp:1391
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:1127
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:1220
LLVMDITypeGetAlignInBits
uint32_t LLVMDITypeGetAlignInBits(LLVMMetadataRef DType)
Get the alignment of this DIType in bits.
Definition:DebugInfo.cpp:1579
LLVMDIGlobalVariableExpressionGetExpression
LLVMMetadataRef LLVMDIGlobalVariableExpressionGetExpression(LLVMMetadataRef GVE)
Retrieves the DIExpression associated with this global variable expression.
Definition:DebugInfo.cpp:1638
LLVMDIVariableGetScope
LLVMMetadataRef LLVMDIVariableGetScope(LLVMMetadataRef Var)
Get the metadata of the scope associated with a given variable.
Definition:DebugInfo.cpp:1647
LLVMInstructionGetDebugLoc
LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst)
Get the debug location for the given instruction.
Definition:DebugInfo.cpp:1792
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:1496
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:1115
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:1057
LLVMSetSubprogram
void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP)
Set the subprogram attached to a function.
Definition:DebugInfo.cpp:1784
LLVMDWARFSourceLanguage
LLVMDWARFSourceLanguage
Source languages known by DWARF.
Definition:DebugInfo.h:78
LLVMDIBuilderGetOrCreateSubrange
LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, int64_t LowerBound, int64_t Count)
Create a descriptor for a value range.
Definition:DebugInfo.cpp:1768
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:1061
LLVMDisposeTemporaryMDNode
void LLVMDisposeTemporaryMDNode(LLVMMetadataRef TempNode)
Deallocate a temporary node.
Definition:DebugInfo.cpp:1661
LLVMDILocationGetScope
LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location)
Get the local scope associated with this debug location.
Definition:DebugInfo.cpp:1235
LLVMDIBuilderCreateImportedModuleFromNamespace
LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromNamespace(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef NS, LLVMMetadataRef File, unsigned Line)
Create a descriptor for an imported namespace.
Definition:DebugInfo.cpp:1169
LLVMDIBuilderCreateTempMacroFile
LLVMMetadataRef LLVMDIBuilderCreateTempMacroFile(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentMacroFile, unsigned Line, LLVMMetadataRef File)
Create debugging information temporary entry for a macro file.
Definition:DebugInfo.cpp:1281
LLVMInstructionSetDebugLoc
void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc)
Set the debug location for the given instruction.
Definition:DebugInfo.cpp:1796
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:1288
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:1610
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:1335
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:1508
LLVMDILocationGetColumn
unsigned LLVMDILocationGetColumn(LLVMMetadataRef Location)
Get the column number of this debug location.
Definition:DebugInfo.cpp:1231
LLVMDIFlags
LLVMDIFlags
Debug info flags.
Definition:DebugInfo.h:34
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:1748
LLVMTemporaryMDNode
LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef Ctx, LLVMMetadataRef *Data, size_t NumElements)
Create a new temporary MDNode.
Definition:DebugInfo.cpp:1655
LLVMDITypeGetFlags
LLVMDIFlags LLVMDITypeGetFlags(LLVMMetadataRef DType)
Get the flags associated with this DIType.
Definition:DebugInfo.cpp:1587
LLVMDIFileGetDirectory
const char * LLVMDIFileGetDirectory(LLVMMetadataRef File, unsigned *Len)
Get the directory of a given file.
Definition:DebugInfo.cpp:1247
LLVMMetadataReplaceAllUsesWith
void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef TempTargetMetadata, LLVMMetadataRef Replacement)
Replace all uses of temporary metadata.
Definition:DebugInfo.cpp:1665
LLVMDIFileGetFilename
const char * LLVMDIFileGetFilename(LLVMMetadataRef File, unsigned *Len)
Get the name of a given file.
Definition:DebugInfo.cpp:1253
LLVMDIBuilderCreateLabel
LLVMMetadataRef LLVMDIBuilderCreateLabel(LLVMDIBuilderRef Builder, LLVMMetadataRef Context, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMBool AlwaysPreserve)
Create a new descriptor for a label.
Definition:DebugInfo.cpp:1803
LLVMDebugMetadataVersion
unsigned LLVMDebugMetadataVersion(void)
The current debug metadata version number.
Definition:DebugInfo.cpp:1053
LLVMGetModuleDebugMetadataVersion
unsigned LLVMGetModuleDebugMetadataVersion(LLVMModuleRef Module)
The version of debug metadata that's present in the provided Module.
Definition:DebugInfo.cpp:1065
LLVMDITypeGetLine
unsigned LLVMDITypeGetLine(LLVMMetadataRef DType)
Get the source line where this DIType is declared.
Definition:DebugInfo.cpp:1583
LLVMDIVariableGetFile
LLVMMetadataRef LLVMDIVariableGetFile(LLVMMetadataRef Var)
Get the metadata of the file associated with a given variable.
Definition:DebugInfo.cpp:1643
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:1180
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:1396
LLVMGetDINodeTag
uint16_t LLVMGetDINodeTag(LLVMMetadataRef MD)
Get the dwarf::Tag of a DINode.
Definition:DebugInfo.cpp:1561
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:1622
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:1672
LLVMDIBuilderCreateQualifiedType
LLVMMetadataRef LLVMDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type)
Create debugging information entry for a qualified type, e.g.
Definition:DebugInfo.cpp:1489
LLVMGetMetadataKind
LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata)
Obtain the enumerated type of a Metadata instance.
Definition:DebugInfo.cpp:1844
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:1308
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:1463
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:1758
LLVMDIBuilderCreateSubroutineType
LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder, LLVMMetadataRef File, LLVMMetadataRef *ParameterTypes, unsigned NumParameterTypes, LLVMDIFlags Flags)
Create subroutine type.
Definition:DebugInfo.cpp:1599
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:1422
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:1268
LLVMDWARFEmissionKind
LLVMDWARFEmissionKind
The amount of debug information to emit.
Definition:DebugInfo.h:152
LLVMDIBuilderInsertLabelAtEnd
LLVMDbgRecordRef LLVMDIBuilderInsertLabelAtEnd(LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo, LLVMMetadataRef Location, LLVMBasicBlockRef InsertAtEnd)
Insert a new llvm.dbg.label intrinsic call.
Definition:DebugInfo.cpp:1828
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:1324
LLVMDIBuilderInsertDbgValueRecordAtEnd
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
Definition:DebugInfo.cpp:1732
LLVMDIScopeGetFile
LLVMMetadataRef LLVMDIScopeGetFile(LLVMMetadataRef Scope)
Get the metadata of the file associated with a given scope.
Definition:DebugInfo.cpp:1243
LLVMDIBuilderFinalizeSubprogram
void LLVMDIBuilderFinalizeSubprogram(LLVMDIBuilderRef Builder, LLVMMetadataRef Subprogram)
Finalize a specific subprogram.
Definition:DebugInfo.cpp:1081
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:1617
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:1536
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:1380
LLVMDILocationGetLine
unsigned LLVMDILocationGetLine(LLVMMetadataRef Location)
Get the line number of this debug location.
Definition:DebugInfo.cpp:1227
LLVMDIBuilderCreateNullPtrType
LLVMMetadataRef LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder)
Create C++11 nullptr type.
Definition:DebugInfo.cpp:1503
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:1453
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:1086
LLVMStripModuleDebugInfo
LLVMBool LLVMStripModuleDebugInfo(LLVMModuleRef Module)
Strip debug info in the module if it exists.
Definition:DebugInfo.cpp:1069
LLVMDIBuilderInsertDeclareRecordBefore
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
Definition:DebugInfo.cpp:1683
LLVMDIBuilderInsertLabelBefore
LLVMDbgRecordRef LLVMDIBuilderInsertLabelBefore(LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo, LLVMMetadataRef Location, LLVMValueRef InsertBefore)
Insert a new llvm.dbg.label intrinsic call.
Definition:DebugInfo.cpp:1812
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:1346
LLVMDIVariableGetLine
unsigned LLVMDIVariableGetLine(LLVMMetadataRef Var)
Get the source line where this DIVariable is declared.
Definition:DebugInfo.cpp:1651
LLVMDIBuilderInsertDbgValueRecordBefore
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
Definition:DebugInfo.cpp:1716
LLVMDWARFTypeEncoding
unsigned LLVMDWARFTypeEncoding
An LLVM DWARF type encoding.
Definition:DebugInfo.h:204
LLVMDIBuilderCreateLexicalBlock
LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned Column)
Create a descriptor for a lexical block with the specified parent context.
Definition:DebugInfo.cpp:1150
LLVMDIBuilderGetOrCreateTypeArray
LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder, LLVMMetadataRef *Data, size_t NumElements)
Create a type array.
Definition:DebugInfo.cpp:1591
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:1475
LLVMDIFileGetSource
const char * LLVMDIFileGetSource(LLVMMetadataRef File, unsigned *Len)
Get the source of a given file.
Definition:DebugInfo.cpp:1259
LLVMDITypeGetOffsetInBits
uint64_t LLVMDITypeGetOffsetInBits(LLVMMetadataRef DType)
Get the offset of this DIType in bits.
Definition:DebugInfo.cpp:1575
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:1206
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:1107
LLVMDITypeGetName
const char * LLVMDITypeGetName(LLVMMetadataRef DType, size_t *Length)
Get the name of this DIType.
Definition:DebugInfo.cpp:1565
LLVMMetadataKind
unsigned LLVMMetadataKind
Definition:DebugInfo.h:199
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:1443
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:1364
LLVMDisposeDIBuilder
void LLVMDisposeDIBuilder(LLVMDIBuilderRef Builder)
Deallocates the DIBuilder and everything it owns.
Definition:DebugInfo.cpp:1073
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:1355
LLVMGetSubprogram
LLVMMetadataRef LLVMGetSubprogram(LLVMValueRef Func)
Get the metadata of the subprogram attached to a function.
Definition:DebugInfo.cpp:1780
LLVMGenericDINodeMetadataKind
@ LLVMGenericDINodeMetadataKind
Definition:DebugInfo.h:170
LLVMValueRef
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition:Types.h:75
LLVMBool
int LLVMBool
Definition:Types.h:28
LLVMDbgRecordRef
struct LLVMOpaqueDbgRecord * LLVMDbgRecordRef
Definition:Types.h:175
LLVMContextRef
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
Definition:Types.h:53
LLVMBasicBlockRef
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
Represents a basic block of instructions in LLVM IR.
Definition:Types.h:82
LLVMMetadataRef
struct LLVMOpaqueMetadata * LLVMMetadataRef
Represents an LLVM Metadata.
Definition:Types.h:89
LLVMModuleRef
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition:Types.h:61
LLVMDIBuilderRef
struct LLVMOpaqueDIBuilder * LLVMDIBuilderRef
Represents an LLVM debug info builder.
Definition:Types.h:117
UINT64_MAX
#define UINT64_MAX
Definition:DataTypes.h:77
DebugInfo.h
DebugInfo.h
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
CU
Definition:AArch64AsmBackend.cpp:549
llvm::ARMBuildAttrs::File
@ File
Definition:ARMBuildAttributes.h:36
llvm::ARM::ProfileKind::M
@ M
llvm::CallingConv::C
@ C
The default llvm calling convention, compatible with C.
Definition:CallingConv.h:34
llvm::MipsISD::Ret
@ Ret
Definition:MipsISelLowering.h:117
llvm::NVPTXAS::AddressSpace
AddressSpace
Definition:NVPTXAddrSpace.h:20
llvm::at
Assignment Tracking (at).
Definition:DebugInfo.h:181
llvm::at::deleteAll
void deleteAll(Function *F)
Remove all Assignment Tracking related intrinsics and metadata from F.
Definition:DebugInfo.cpp:1906
llvm::at::getAssignmentInsts
AssignmentInstRange getAssignmentInsts(DIAssignID *ID)
Return a range of instructions (typically just one) that have ID as an attachment.
Definition:DebugInfo.cpp:1855
llvm::at::getAssignmentMarkers
AssignmentMarkerRange getAssignmentMarkers(DIAssignID *ID)
Return a range of dbg.assign intrinsics which use \ID as an operand.
Definition:DebugInfo.cpp:1867
llvm::at::trackAssignments
void trackAssignments(Function::iterator Start, Function::iterator End, const StorageToVarsMap &Vars, const DataLayout &DL, bool DebugPrints=false)
Track assignments to Vars between Start and End.
Definition:DebugInfo.cpp:2113
llvm::at::remapAssignID
void remapAssignID(DenseMap< DIAssignID *, DIAssignID * > &Map, Instruction &I)
Replace DIAssignID uses and attachments with IDs from Map.
Definition:DebugInfo.cpp:1983
llvm::at::getDVRAssignmentMarkers
SmallVector< DbgVariableRecord * > getDVRAssignmentMarkers(const Instruction *Inst)
Definition:DebugInfo.h:240
llvm::at::deleteAssignmentMarkers
void deleteAssignmentMarkers(const Instruction *Inst)
Delete the llvm.dbg.assign intrinsics linked to Inst.
Definition:DebugInfo.cpp:1881
llvm::at::getAssignmentInfo
std::optional< AssignmentInfo > getAssignmentInfo(const DataLayout &DL, const MemIntrinsic *I)
Definition:DebugInfo.cpp:2028
llvm::at::calculateFragmentIntersect
bool calculateFragmentIntersect(const DataLayout &DL, const Value *Dest, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const DbgAssignIntrinsic *DbgAssign, std::optional< DIExpression::FragmentInfo > &Result)
Calculate the fragment of the variable in DAI covered from (Dest + SliceOffsetInBits) to to (Dest + S...
Definition:DebugInfo.cpp:1962
llvm::at::RAUW
void RAUW(DIAssignID *Old, DIAssignID *New)
Replace all uses (and attachments) of Old with New.
Definition:DebugInfo.cpp:1893
llvm::dwarf
Calculates the starting offsets for various sections within the .debug_names section.
Definition:Dwarf.h:34
llvm::dwarf::MacinfoRecordType
MacinfoRecordType
Definition:Dwarf.h:794
llvm::dwarf::Tag
Tag
Definition:Dwarf.h:103
llvm::jitlink::prune
void prune(LinkGraph &G)
Removes dead symbols/blocks/addressables.
Definition:JITLinkGeneric.cpp:278
llvm::jitlink::Scope
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
Definition:JITLink.h:412
llvm::sampleprof::Base
@ Base
Definition:Discriminator.h:58
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::drop_begin
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Definition:STLExtras.h:329
llvm::Length
@ Length
Definition:DWP.cpp:480
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:1739
llvm::PseudoProbeType::Block
@ Block
llvm::findDbgDeclares
TinyPtrVector< DbgDeclareInst * > findDbgDeclares(Value *V)
Finds dbg.declare intrinsics declaring local variables as living in the memory that 'V' points to.
Definition:DebugInfo.cpp:47
llvm::stripDebugInfo
bool stripDebugInfo(Function &F)
Definition:DebugInfo.cpp:569
llvm::findDbgUsers
void findDbgUsers(SmallVectorImpl< DbgVariableIntrinsic * > &DbgInsts, Value *V, SmallVectorImpl< DbgVariableRecord * > *DbgVariableRecords=nullptr)
Finds the debug info intrinsics describing a value.
Definition:DebugInfo.cpp:162
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition:iterator_range.h:77
llvm::PassSummaryAction::Import
@ Import
Import information from summary.
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:657
llvm::findDbgValues
void findDbgValues(SmallVectorImpl< DbgValueInst * > &DbgValues, Value *V, SmallVectorImpl< DbgVariableRecord * > *DbgVariableRecords=nullptr)
Finds the llvm.dbg.value intrinsics describing a value.
Definition:DebugInfo.cpp:155
llvm::any_of
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1746
llvm::AtomicOrderingCABI::release
@ release
llvm::get
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
Definition:PointerIntPair.h:270
llvm::stripNonLineTableDebugInfo
bool stripNonLineTableDebugInfo(Module &M)
Downgrade the debug info in a module to contain only line table information.
Definition:DebugInfo.cpp:843
llvm::getDebugValueLoc
DebugLoc getDebugValueLoc(DbgVariableIntrinsic *DII)
Produce a DebugLoc to use for each dbg.declare that is promoted to a dbg.value.
Definition:DebugInfo.cpp:175
llvm::findDVRValues
TinyPtrVector< DbgVariableRecord * > findDVRValues(Value *V)
As above, for DVRValues.
Definition:DebugInfo.cpp:83
llvm::getDebugMetadataVersionFromModule
unsigned getDebugMetadataVersionFromModule(const Module &M)
Return Debug Info Metadata Version by checking module flags.
Definition:DebugInfo.cpp:942
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition:raw_ostream.cpp:907
llvm::PackElem::Lo
@ Lo
llvm::StripDebugInfo
bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
Definition:DebugInfo.cpp:608
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition:Attributes.h:335
llvm::isAssignmentTrackingEnabled
bool isAssignmentTrackingEnabled(const Module &M)
Return true if assignment tracking is enabled for module M.
Definition:DebugInfo.cpp:2299
llvm::DINameKind::LinkageName
@ LinkageName
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:1945
llvm::wrap
LLVMAttributeRef wrap(Attribute Attr)
Definition:Attributes.h:330
llvm::findDVRDeclares
TinyPtrVector< DbgVariableRecord * > findDVRDeclares(Value *V)
As above, for DVRDeclares.
Definition:DebugInfo.cpp:66
llvm::Data
@ Data
Definition:SIMachineScheduler.h:55
llvm::filterDbgVars
static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DbgVariableRecord types only and downcast.
Definition:DebugProgramInstruction.h:555
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:439
llvm::DEBUG_METADATA_VERSION
@ DEBUG_METADATA_VERSION
Definition:Metadata.h:52
llvm::getDISubprogram
DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Definition:DebugInfo.cpp:169
N
#define N
llvm::DbgVariableFragmentInfo
Definition:DbgVariableFragmentInfo.h:18
llvm::FunctionLoweringInfo::StatepointRelocationRecord
Helper object to track which of three possible relocation mechanisms are used for a particular value ...
Definition:FunctionLoweringInfo.h:100
llvm::at::AssignmentInfo
Describes properties of a store that has a static size and offset into a some base storage.
Definition:DebugInfo.h:338
llvm::at::VarRecord
Helper struct for trackAssignments, below.
Definition:DebugInfo.h:283
llvm::at::VarRecord::DL
DILocation * DL
Definition:DebugInfo.h:285
llvm::at::VarRecord::Var
DILocalVariable * Var
Definition:DebugInfo.h:284

Generated on Thu Jul 17 2025 12:28:17 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp