51 if (!V->isUsedByMetadata())
59 if (DVR->getType() == DbgVariableRecord::LocationType::Declare)
68 if (!V->isUsedByMetadata())
76 if (DVR->isValueOfVariable())
82template <
bool DbgAssignAndValuesOnly>
88 if (!V->isUsedByMetadata())
99 auto AppendUsers = [&EncounteredDbgVariableRecords,
100 &DbgVariableRecords](
Metadata *MD) {
104 if (!DbgAssignAndValuesOnly || DVR->isDbgValue() || DVR->isDbgAssign())
105 if (EncounteredDbgVariableRecords.
insert(DVR).second)
113 for (
Metadata *AL : L->getAllArgListUsers()) {
117 if (!DbgAssignAndValuesOnly || DVR->isDbgValue() || DVR->isDbgAssign())
118 if (EncounteredDbgVariableRecords.
insert(DVR).second)
135 if (
auto *LocalScope = dyn_cast_or_null<DILocalScope>(Scope))
149 return DILocation::get(DVR->
getContext(), 0, 0, Scope, InlinedAt);
166 for (
auto *
CU : M.debug_compile_units())
167 processCompileUnit(
CU);
168 for (
auto &
F : M.functions()) {
169 if (
auto *SP = cast_or_null<DISubprogram>(
F.getSubprogram()))
180 if (!addCompileUnit(
CU))
182 for (
auto *DIG :
CU->getGlobalVariables()) {
183 if (!addGlobalVariable(DIG))
185 auto *GV = DIG->getVariable();
186 processScope(GV->getScope());
187 processType(GV->getType());
189 for (
auto *ET :
CU->getEnumTypes())
191 for (
auto *RT :
CU->getRetainedTypes())
192 if (
auto *
T = dyn_cast<DIType>(RT))
196 for (
auto *
Import :
CU->getImportedEntities())
197 processImportedEntity(
Import);
202 if (
auto *DVI = dyn_cast<DbgVariableIntrinsic>(&
I))
205 if (
auto DbgLoc =
I.getDebugLoc())
208 for (
const DbgRecord &DPR :
I.getDbgRecordRange())
215 processScope(Loc->getScope());
225void DebugInfoFinder::processType(
DIType *DT) {
228 processScope(DT->getScope());
229 if (
auto *ST = dyn_cast<DISubroutineType>(DT)) {
234 if (
auto *DCT = dyn_cast<DICompositeType>(DT)) {
235 processType(DCT->getBaseType());
237 if (
auto *
T = dyn_cast<DIType>(
D))
239 else if (
auto *SP = dyn_cast<DISubprogram>(
D))
244 if (
auto *DDT = dyn_cast<DIDerivedType>(DT)) {
245 processType(DDT->getBaseType());
250 auto *Entity =
Import->getEntity();
251 if (
auto *
T = dyn_cast<DIType>(Entity))
253 else if (
auto *SP = dyn_cast<DISubprogram>(Entity))
255 else if (
auto *NS = dyn_cast<DINamespace>(Entity))
256 processScope(NS->getScope());
257 else if (
auto *M = dyn_cast<DIModule>(Entity))
258 processScope(
M->getScope());
261void DebugInfoFinder::processScope(
DIScope *Scope) {
264 if (
auto *Ty = dyn_cast<DIType>(Scope)) {
268 if (
auto *
CU = dyn_cast<DICompileUnit>(Scope)) {
272 if (
auto *SP = dyn_cast<DISubprogram>(Scope)) {
276 if (!addScope(Scope))
278 if (
auto *LB = dyn_cast<DILexicalBlockBase>(Scope)) {
279 processScope(LB->getScope());
280 }
else if (
auto *NS = dyn_cast<DINamespace>(Scope)) {
281 processScope(NS->getScope());
282 }
else if (
auto *M = dyn_cast<DIModule>(Scope)) {
283 processScope(
M->getScope());
288 if (!addSubprogram(SP))
290 processScope(SP->getScope());
299 processCompileUnit(SP->getUnit());
300 processType(SP->getType());
301 for (
auto *Element : SP->getTemplateParams()) {
302 if (
auto *TType = dyn_cast<DITemplateTypeParameter>(Element)) {
303 processType(TType->getType());
304 }
else if (
auto *TVal = dyn_cast<DITemplateValueParameter>(Element)) {
305 processType(TVal->getType());
309 for (
auto *
N : SP->getRetainedNodes()) {
310 if (
auto *Var = dyn_cast_or_null<DILocalVariable>(
N))
312 else if (
auto *
Import = dyn_cast_or_null<DIImportedEntity>(
N))
313 processImportedEntity(
Import);
318 if (!NodesSeen.insert(DV).second)
324bool DebugInfoFinder::addType(
DIType *DT) {
328 if (!NodesSeen.insert(DT).second)
338 if (!NodesSeen.insert(
CU).second)
346 if (!NodesSeen.insert(DIG).second)
357 if (!NodesSeen.insert(SP).second)
364bool DebugInfoFinder::addScope(
DIScope *Scope) {
369 if (
Scope->getNumOperands() == 0)
371 if (!NodesSeen.insert(Scope).second)
373 Scopes.push_back(Scope);
380 "Loop ID needs at least one operand");
382 "Loop ID should refer to itself");
391 else if (
Metadata *NewMD = Updater(MD))
403 MDNode *OrigLoopID =
I.getMetadata(LLVMContext::MD_loop);
407 I.setMetadata(LLVMContext::MD_loop, NewLoopID);
415 MDNode *
N = dyn_cast_or_null<MDNode>(MD);
418 if (isa<DILocation>(
N) || Reachable.
count(
N))
422 for (
auto &OpIt :
N->operands()) {
430 return Reachable.
count(
N);
437 MDNode *
N = dyn_cast_or_null<MDNode>(MD);
440 if (isa<DILocation>(
N) || AllDILocation.
count(
N))
442 if (!DIReachable.
count(
N))
446 for (
auto &OpIt :
N->operands()) {
461 if (isa<DILocation>(MD) || AllDILocation.
count(MD))
464 if (!DIReachable.
count(MD))
467 MDNode *
N = dyn_cast_or_null<MDNode>(MD);
472 bool HasSelfRef =
false;
473 for (
unsigned i = 0; i <
N->getNumOperands(); ++i) {
476 Args.push_back(
nullptr);
477 }
else if (
A == MD) {
478 assert(i == 0 &&
"expected i==0 for self-reference");
480 Args.push_back(
nullptr);
483 Args.push_back(NewArg);
486 if (Args.empty() || (HasSelfRef && Args.size() == 1))
497 assert(!
N->operands().empty() &&
"Missing self reference?");
508 [&Visited, &DILocationReachable](
const MDOperand &
Op) {
509 return isDILocationReachable(
510 Visited, DILocationReachable, Op.get());
518 [&Visited, &AllDILocation,
520 return isAllDILocation(Visited, AllDILocation,
521 DILocationReachable, Op.get());
532 bool Changed =
false;
533 if (
F.hasMetadata(LLVMContext::MD_dbg)) {
535 F.setSubprogram(
nullptr);
541 if (
I.getDebugLoc()) {
545 if (
auto *LoopID =
I.getMetadata(LLVMContext::MD_loop)) {
546 auto *NewLoopID = LoopIDsMap.
lookup(LoopID);
549 if (NewLoopID != LoopID)
550 I.setMetadata(LLVMContext::MD_loop, NewLoopID);
553 if (
I.hasMetadataOtherThanDebugLoc()) {
555 I.setMetadata(
"heapallocsite",
nullptr);
557 I.setMetadata(LLVMContext::MD_DIAssignID,
nullptr);
566 bool Changed =
false;
571 if (NMD.getName().starts_with(
"llvm.dbg.") ||
572 NMD.getName() ==
"llvm.gcov") {
573 NMD.eraseFromParent();
581 for (
auto &GV : M.globals()) {
582 Changed |= GV.eraseMetadata(LLVMContext::MD_dbg);
586 Materializer->setStripDebugInfo();
594class DebugTypeInfoRemoval {
599 MDNode *EmptySubroutineType;
623 auto Replacement = Replacements.find(M);
624 if (Replacement != Replacements.end())
625 return Replacement->second;
633 void traverseAndRemap(
MDNode *
N) { traverse(
N); }
638 auto *FileAndScope = cast_or_null<DIFile>(map(MDS->
getFile()));
641 auto *
Type = cast_or_null<DISubroutineType>(map(MDS->getType()));
643 cast_or_null<DIType>(map(MDS->getContainingType()));
644 auto *Unit = cast_or_null<DICompileUnit>(map(MDS->getUnit()));
645 auto Variables =
nullptr;
646 auto TemplateParams =
nullptr;
649 auto distinctMDSubprogram = [&]() {
650 return DISubprogram::getDistinct(
652 FileAndScope, MDS->getLine(),
Type, MDS->getScopeLine(),
653 ContainingType, MDS->getVirtualIndex(), MDS->getThisAdjustment(),
654 MDS->getFlags(), MDS->getSPFlags(), Unit, TemplateParams, Declaration,
659 return distinctMDSubprogram();
661 auto *NewMDS = DISubprogram::get(
663 FileAndScope, MDS->getLine(),
Type, MDS->getScopeLine(), ContainingType,
664 MDS->getVirtualIndex(), MDS->getThisAdjustment(), MDS->getFlags(),
665 MDS->getSPFlags(), Unit, TemplateParams, Declaration, Variables);
667 StringRef OldLinkageName = MDS->getLinkageName();
670 auto OrigLinkage = NewToLinkageName.find(NewMDS);
671 if (OrigLinkage != NewToLinkageName.end()) {
672 if (OrigLinkage->second == OldLinkageName)
678 return distinctMDSubprogram();
681 NewToLinkageName.insert({NewMDS, MDS->getLinkageName()});
691 auto *
File = cast_or_null<DIFile>(map(
CU->getFile()));
693 MDTuple *RetainedTypes =
nullptr;
694 MDTuple *GlobalVariables =
nullptr;
695 MDTuple *ImportedEntities =
nullptr;
696 return DICompileUnit::getDistinct(
697 CU->getContext(),
CU->getSourceLanguage(), File,
CU->getProducer(),
698 CU->isOptimized(),
CU->getFlags(),
CU->getRuntimeVersion(),
700 RetainedTypes, GlobalVariables, ImportedEntities,
CU->getMacros(),
701 CU->getDWOId(),
CU->getSplitDebugInlining(),
702 CU->getDebugInfoForProfiling(),
CU->getNameTableKind(),
703 CU->getRangesBaseAddress(),
CU->getSysRoot(),
CU->getSDK());
707 auto *
Scope = map(MLD->getScope());
708 auto *InlinedAt = map(MLD->getInlinedAt());
710 return DILocation::getDistinct(MLD->
getContext(), MLD->getLine(),
711 MLD->getColumn(), Scope, InlinedAt);
712 return DILocation::get(MLD->
getContext(), MLD->getLine(), MLD->getColumn(),
720 for (
auto &
I :
N->operands())
729 if (Replacements.count(
N))
735 if (
auto *MDSub = dyn_cast<DISubprogram>(
N)) {
736 remap(MDSub->getUnit());
737 return getReplacementSubprogram(MDSub);
739 if (isa<DISubroutineType>(
N))
740 return EmptySubroutineType;
741 if (
auto *
CU = dyn_cast<DICompileUnit>(
N))
742 return getReplacementCU(
CU);
745 if (
auto *MDLB = dyn_cast<DILexicalBlockBase>(
N))
747 return mapNode(MDLB->getScope());
748 if (
auto *MLD = dyn_cast<DILocation>(
N))
749 return getReplacementMDLocation(MLD);
756 return getReplacementMDNode(
N);
771void DebugTypeInfoRemoval::traverse(
MDNode *
N) {
772 if (!
N || Replacements.count(
N))
778 if (
auto *MDS = dyn_cast<DISubprogram>(Parent))
779 return Child == MDS->getRetainedNodes().
get();
788 while (!ToVisit.
empty()) {
789 auto *
N = ToVisit.
back();
790 if (!Opened.
insert(
N).second) {
796 for (
auto &
I :
N->operands())
797 if (
auto *MDN = dyn_cast_or_null<MDNode>(
I))
798 if (!Opened.
count(MDN) && !Replacements.count(MDN) && !
prune(
N, MDN) &&
799 !isa<DICompileUnit>(MDN))
805 bool Changed =
false;
808 for (
auto NMI = M.named_metadata_begin(), NME = M.named_metadata_end();
813 if (NMD->
getName() ==
"llvm.dbg.cu")
818 for (
auto &GV : M.globals())
819 GV.eraseMetadata(LLVMContext::MD_dbg);
821 DebugTypeInfoRemoval Mapper(M.getContext());
825 Mapper.traverseAndRemap(Node);
826 auto *NewNode = Mapper.mapNode(Node);
827 Changed |= Node != NewNode;
835 if (
auto *SP =
F.getSubprogram()) {
836 Mapper.traverseAndRemap(SP);
837 auto *NewSP = cast<DISubprogram>(Mapper.mapNode(SP));
838 Changed |= SP != NewSP;
839 F.setSubprogram(NewSP);
844 auto *Scope =
DL.getScope();
845 MDNode *InlinedAt =
DL.getInlinedAt();
846 Scope = remap(Scope);
847 InlinedAt = remap(InlinedAt);
853 I.setDebugLoc(remapDebugLoc(
I.getDebugLoc()));
857 if (
auto *Loc = dyn_cast_or_null<DILocation>(MD))
858 return remapDebugLoc(Loc).
get();
863 if (
I.hasMetadataOtherThanDebugLoc())
864 I.setMetadata(
"heapallocsite",
nullptr);
874 for (
auto &NMD : M.named_metadata()) {
891 if (
auto *Val = mdconst::dyn_extract_or_null<ConstantInt>(
892 M.getModuleFlag(
"Debug Info Version")))
893 return Val->getZExtValue();
909 if (
auto *MD =
I->getMetadata(LLVMContext::MD_DIAssignID))
912 "Merging with instruction from another function not allowed");
916 if (
auto *MD =
getMetadata(LLVMContext::MD_DIAssignID))
924 if (AssignID != MergeID)
941 bool MayLowerToCall =
false;
942 if (isa<CallBase>(
this)) {
943 auto *
II = dyn_cast<IntrinsicInst>(
this);
948 if (!MayLowerToCall) {
977#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
978 case LLVMDWARFSourceLanguage##NAME: \
980#include "llvm/BinaryFormat/Dwarf.def"
987 return (DIT *)(
Ref ? unwrap<MDNode>(
Ref) :
nullptr);
1028 unwrap(Builder)->finalize();
1033 unwrap(Builder)->finalizeSubprogram(unwrapDI<DISubprogram>(subprogram));
1039 LLVMBool isOptimized,
const char *Flags,
size_t FlagsLen,
1040 unsigned RuntimeVer,
const char *SplitName,
size_t SplitNameLen,
1042 LLVMBool DebugInfoForProfiling,
const char *SysRoot,
size_t SysRootLen,
1043 const char *SDK,
size_t SDKLen) {
1044 auto File = unwrapDI<DIFile>(FileRef);
1046 return wrap(
unwrap(Builder)->createCompileUnit(
1049 RuntimeVer,
StringRef(SplitName, SplitNameLen),
1051 SplitDebugInlining, DebugInfoForProfiling,
1058 size_t FilenameLen,
const char *Directory,
1059 size_t DirectoryLen) {
1066 const char *
Name,
size_t NameLen,
1067 const char *ConfigMacros,
size_t ConfigMacrosLen,
1068 const char *IncludePath,
size_t IncludePathLen,
1069 const char *APINotesFile,
size_t APINotesFileLen) {
1072 StringRef(ConfigMacros, ConfigMacrosLen),
1074 StringRef(APINotesFile, APINotesFileLen)));
1079 const char *
Name,
size_t NameLen,
1081 return wrap(
unwrap(Builder)->createNameSpace(
1082 unwrapDI<DIScope>(ParentScope),
StringRef(
Name, NameLen), ExportSymbols));
1087 size_t NameLen,
const char *
LinkageName,
size_t LinkageNameLen,
1092 unwrapDI<DIScope>(Scope), {
Name, NameLen}, {
LinkageName, LinkageNameLen},
1093 unwrapDI<DIFile>(File), LineNo, unwrapDI<DISubroutineType>(Ty), ScopeLine,
1103 return wrap(
unwrap(Builder)->createLexicalBlock(unwrapDI<DIScope>(Scope),
1104 unwrapDI<DIFile>(File),
1112 unsigned Discriminator) {
1113 return wrap(
unwrap(Builder)->createLexicalBlockFile(unwrapDI<DIScope>(Scope),
1114 unwrapDI<DIFile>(File),
1125 unwrapDI<DINamespace>(NS),
1126 unwrapDI<DIFile>(File),
1136 ?
unwrap(Builder)->getOrCreateArray({
unwrap(Elements), NumElements})
1139 unwrapDI<DIScope>(Scope), unwrapDI<DIImportedEntity>(ImportedEntity),
1140 unwrapDI<DIFile>(File), Line, Elts));
1146 unsigned NumElements) {
1149 ?
unwrap(Builder)->getOrCreateArray({
unwrap(Elements), NumElements})
1152 unwrapDI<DIScope>(Scope), unwrapDI<DIModule>(M), unwrapDI<DIFile>(File),
1162 ?
unwrap(Builder)->getOrCreateArray({
unwrap(Elements), NumElements})
1164 return wrap(
unwrap(Builder)->createImportedDeclaration(
1165 unwrapDI<DIScope>(Scope), unwrapDI<DINode>(Decl), unwrapDI<DIFile>(File),
1166 Line, {
Name, NameLen}, Elts));
1178 return unwrapDI<DILocation>(Location)->getLine();
1182 return unwrapDI<DILocation>(Location)->getColumn();
1186 return wrap(unwrapDI<DILocation>(Location)->getScope());
1190 return wrap(unwrapDI<DILocation>(Location)->getInlinedAt());
1194 return wrap(unwrapDI<DIScope>(Scope)->getFile());
1198 auto Dir = unwrapDI<DIFile>(File)->getDirectory();
1204 auto Name = unwrapDI<DIFile>(File)->getFilename();
1210 if (
auto Src = unwrapDI<DIFile>(File)->getSource()) {
1222 const char *
Name,
size_t NameLen,
1223 const char *
Value,
size_t ValueLen) {
1225 unwrap(Builder)->createMacro(unwrapDI<DIMacroFile>(ParentMacroFile), Line,
1234 return wrap(
unwrap(Builder)->createTempMacroFile(
1235 unwrapDI<DIMacroFile>(ParentMacroFile), Line, unwrapDI<DIFile>(File)));
1239 const char *
Name,
size_t NameLen,
1249 uint64_t NumWords = (SizeInBits + 63) / 64;
1250 return wrap(
unwrap(Builder)->createEnumerator(
1260auto Elts =
unwrap(Builder)->getOrCreateArray({
unwrap(Elements),
1262return wrap(
unwrap(Builder)->createEnumerationType(
1263 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File),
1264 LineNumber, SizeInBits, AlignInBits, Elts, unwrapDI<DIType>(ClassTy)));
1272 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File),
1273 LineNumber, SizeInBits, AlignInBits, unwrapDI<DIType>(
BaseTy)));
1282 return wrap(
unwrap(Builder)->createSubrangeType(
1283 {
Name, NameLen}, unwrapDI<DIFile>(File), LineNo, unwrapDI<DIScope>(Scope),
1293 MDNode *MDN = unwrapDI<MDNode>(MD);
1294 if (
auto *E = dyn_cast<DIExpression>(MDN))
1296 assert(isa<DIVariable>(MDN) &&
"Expected DIExpression or DIVariable");
1297 return cast<DIVariable>(MDN);
1308 unwrap(Builder)->getOrCreateArray({
unwrap(Subscripts), NumSubscripts});
1309 return wrap(
unwrap(Builder)->createArrayType(
1310 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1311 Size, AlignInBits, unwrapDI<DIType>(Ty), Subs,
1318 auto CT = unwrap<DICompositeType>(*
T);
1320 unwrap(Builder)->getOrCreateArray({
unwrap(Elements), NumElements});
1321 unwrap(Builder)->replaceArrays(CT, Elts);
1328 LLVMMetadataRef *Elements,
unsigned NumElements,
unsigned RunTimeLang,
1329 const char *UniqueId,
size_t UniqueIdLen) {
1330 auto Elts =
unwrap(Builder)->getOrCreateArray({
unwrap(Elements),
1332 return wrap(
unwrap(Builder)->createUnionType(
1333 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File),
1335 Elts, RunTimeLang, {UniqueId, UniqueIdLen}));
1343 unsigned NumSubscripts) {
1344 auto Subs =
unwrap(Builder)->getOrCreateArray({
unwrap(Subscripts),
1347 unwrapDI<DIType>(Ty), Subs));
1354 unsigned NumSubscripts) {
1355 auto Subs =
unwrap(Builder)->getOrCreateArray({
unwrap(Subscripts),
1358 unwrapDI<DIType>(Ty), Subs));
1363 size_t NameLen,
uint64_t SizeInBits,
1367 SizeInBits, Encoding,
1374 const char *
Name,
size_t NameLen) {
1375 return wrap(
unwrap(Builder)->createPointerType(
1376 unwrapDI<DIType>(PointeeTy), SizeInBits, AlignInBits,
AddressSpace,
1385 unsigned NumElements,
unsigned RunTimeLang,
LLVMMetadataRef VTableHolder,
1386 const char *UniqueId,
size_t UniqueIdLen) {
1387 auto Elts =
unwrap(Builder)->getOrCreateArray({
unwrap(Elements),
1389 return wrap(
unwrap(Builder)->createStructType(
1390 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File),
1392 unwrapDI<DIType>(DerivedFrom), Elts, RunTimeLang,
1393 unwrapDI<DIType>(VTableHolder), {UniqueId, UniqueIdLen}));
1401 return wrap(
unwrap(Builder)->createMemberType(unwrapDI<DIScope>(Scope),
1402 {
Name, NameLen}, unwrapDI<DIFile>(File), LineNo, SizeInBits, AlignInBits,
1409 return wrap(
unwrap(Builder)->createUnspecifiedType({
Name, NameLen}));
1417 return wrap(
unwrap(Builder)->createStaticMemberType(
1418 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File),
1420 unwrap<Constant>(ConstantVal), DW_TAG_member, AlignInBits));
1425 const char *
Name,
size_t NameLen,
1431 {
Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1432 SizeInBits, AlignInBits, OffsetInBits,
1434 unwrapDI<MDNode>(PropertyNode)));
1439 const char *
Name,
size_t NameLen,
1441 const char *GetterName,
size_t GetterNameLen,
1442 const char *SetterName,
size_t SetterNameLen,
1443 unsigned PropertyAttributes,
1445 return wrap(
unwrap(Builder)->createObjCProperty(
1446 {
Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1447 {GetterName, GetterNameLen}, {SetterName, SetterNameLen},
1448 PropertyAttributes, unwrapDI<DIType>(Ty)));
1454 return wrap(
unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(
Type),
1460 const char *
Name,
size_t NameLen,
1464 unwrapDI<DIType>(
Type), {
Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1465 unwrapDI<DIScope>(Scope), AlignInBits));
1473 return wrap(
unwrap(Builder)->createInheritance(
1474 unwrapDI<DIType>(Ty), unwrapDI<DIType>(
BaseTy),
1483 const char *UniqueIdentifier,
size_t UniqueIdentifierLen) {
1484 return wrap(
unwrap(Builder)->createForwardDecl(
1485 Tag, {
Name, NameLen}, unwrapDI<DIScope>(Scope),
1486 unwrapDI<DIFile>(File), Line, RuntimeLang, SizeInBits,
1487 AlignInBits, {UniqueIdentifier, UniqueIdentifierLen}));
1496 size_t UniqueIdentifierLen) {
1497 return wrap(
unwrap(Builder)->createReplaceableCompositeType(
1498 Tag, {
Name, NameLen}, unwrapDI<DIScope>(Scope),
1499 unwrapDI<DIFile>(File), Line, RuntimeLang, SizeInBits,
1501 {UniqueIdentifier, UniqueIdentifierLen}));
1508 unwrapDI<DIType>(
Type)));
1515 unwrapDI<DIType>(
Type)));
1520 return wrap(
unwrap(Builder)->createNullPtrType());
1530 return wrap(
unwrap(Builder)->createMemberPointerType(
1531 unwrapDI<DIType>(PointeeType),
1532 unwrapDI<DIType>(ClassType), AlignInBits, SizeInBits,
1539 const char *
Name,
size_t NameLen,
1545 return wrap(
unwrap(Builder)->createBitFieldMemberType(
1546 unwrapDI<DIScope>(Scope), {
Name, NameLen},
1547 unwrapDI<DIFile>(File), LineNumber,
1548 SizeInBits, OffsetInBits, StorageOffsetInBits,
1559 const char *UniqueIdentifier,
size_t UniqueIdentifierLen) {
1560 auto Elts =
unwrap(Builder)->getOrCreateArray({
unwrap(Elements),
1562 return wrap(
unwrap(Builder)->createClassType(
1563 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File),
1564 LineNumber, SizeInBits, AlignInBits, OffsetInBits,
1566 0, unwrapDI<DIType>(VTableHolder),
1567 unwrapDI<MDNode>(TemplateParamsNode),
1568 {UniqueIdentifier, UniqueIdentifierLen}));
1574 return wrap(
unwrap(Builder)->createArtificialType(unwrapDI<DIType>(
Type)));
1578 return unwrapDI<DINode>(MD)->getTag();
1582 StringRef Str = unwrapDI<DIType>(DType)->getName();
1588 return unwrapDI<DIType>(DType)->getSizeInBits();
1592 return unwrapDI<DIType>(DType)->getOffsetInBits();
1596 return unwrapDI<DIType>(DType)->getAlignInBits();
1600 return unwrapDI<DIType>(DType)->getLine();
1618 unsigned NumParameterTypes,
1620 auto Elts =
unwrap(Builder)->getOrCreateTypeArray({
unwrap(ParameterTypes),
1621 NumParameterTypes});
1622 return wrap(
unwrap(Builder)->createSubroutineType(
1640 size_t NameLen,
const char *Linkage,
size_t LinkLen,
LLVMMetadataRef File,
1643 return wrap(
unwrap(Builder)->createGlobalVariableExpression(
1644 unwrapDI<DIScope>(Scope), {
Name, NameLen}, {Linkage, LinkLen},
1645 unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
1646 true, unwrap<DIExpression>(Expr), unwrapDI<MDNode>(Decl),
1647 nullptr, AlignInBits));
1651 return wrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getVariable());
1656 return wrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getExpression());
1660 return wrap(unwrapDI<DIVariable>(Var)->getFile());
1664 return wrap(unwrapDI<DIVariable>(Var)->getScope());
1668 return unwrapDI<DIVariable>(Var)->getLine();
1683 auto *
Node = unwrapDI<MDNode>(TargetMetadata);
1684 Node->replaceAllUsesWith(
unwrap(Replacement));
1690 size_t NameLen,
const char *Linkage,
size_t LnkLen,
LLVMMetadataRef File,
1693 return wrap(
unwrap(Builder)->createTempGlobalVariableFwdDecl(
1694 unwrapDI<DIScope>(Scope), {
Name, NameLen}, {Linkage, LnkLen},
1695 unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
1696 unwrapDI<MDNode>(Decl),
nullptr, AlignInBits));
1703 unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1704 unwrap<DIExpression>(Expr), unwrap<DILocation>(
DL),
1705 Instr ?
InsertPosition(unwrap<Instruction>(Instr)->getIterator())
1712 assert(isa<DbgRecord *>(DbgInst) &&
1713 "Function unexpectedly in old debug info format");
1714 return wrap(cast<DbgRecord *>(DbgInst));
1721 unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1722 unwrap<DIExpression>(Expr), unwrap<DILocation>(
DL),
unwrap(
Block));
1728 assert(isa<DbgRecord *>(DbgInst) &&
1729 "Function unexpectedly in old debug info format");
1730 return wrap(cast<DbgRecord *>(DbgInst));
1737 unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
1739 Instr ?
InsertPosition(unwrap<Instruction>(Instr)->getIterator())
1746 assert(isa<DbgRecord *>(DbgInst) &&
1747 "Function unexpectedly in old debug info format");
1748 return wrap(cast<DbgRecord *>(DbgInst));
1755 unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
1763 assert(isa<DbgRecord *>(DbgInst) &&
1764 "Function unexpectedly in old debug info format");
1765 return wrap(cast<DbgRecord *>(DbgInst));
1772 return wrap(
unwrap(Builder)->createAutoVariable(
1773 unwrap<DIScope>(Scope), {
Name, NameLen}, unwrap<DIFile>(File),
1774 LineNo, unwrap<DIType>(Ty), AlwaysPreserve,
1780 size_t NameLen,
unsigned ArgNo,
LLVMMetadataRef File,
unsigned LineNo,
1782 return wrap(
unwrap(Builder)->createParameterVariable(
1783 unwrap<DIScope>(Scope), {
Name, NameLen}, ArgNo, unwrap<DIFile>(File),
1784 LineNo, unwrap<DIType>(Ty), AlwaysPreserve,
1789 int64_t
Lo, int64_t Count) {
1790 return wrap(
unwrap(Builder)->getOrCreateSubrange(
Lo, Count));
1805 unwrap<Function>(Func)->setSubprogram(unwrap<DISubprogram>(SP));
1809 return unwrapDI<DISubprogram>(Subprogram)->getLine();
1814 unwrapDI<DISubprogram>(Subprogram)
1815 ->replaceType(unwrapDI<DISubroutineType>(SubroutineType));
1824 unwrap<Instruction>(Inst)->setDebugLoc(
DebugLoc(unwrap<MDNode>(Loc)));
1826 unwrap<Instruction>(Inst)->setDebugLoc(
DebugLoc());
1831 const char *
Name,
size_t NameLen,
1836 unwrapDI<DIFile>(File), LineNo, 0,
false,
1837 std::nullopt, AlwaysPreserve));
1845 unwrapDI<DILabel>(LabelInfo), unwrapDI<DILocation>(Location),
1847 ?
InsertPosition(unwrap<Instruction>(InsertBefore)->getIterator())
1854 assert(isa<DbgRecord *>(DbgInst) &&
1855 "Function unexpectedly in old debug info format");
1856 return wrap(cast<DbgRecord *>(DbgInst));
1864 unwrapDI<DILabel>(LabelInfo), unwrapDI<DILocation>(Location),
1871 assert(isa<DbgRecord *>(DbgInst) &&
1872 "Function unexpectedly in old debug info format");
1873 return wrap(cast<DbgRecord *>(DbgInst));
1878#define HANDLE_METADATA_LEAF(CLASS) \
1879 case Metadata::CLASS##Kind: \
1880 return (LLVMMetadataKind)LLVM##CLASS##MetadataKind;
1881#include "llvm/IR/Metadata.def"
1888 assert(
ID &&
"Expected non-null ID");
1892 auto MapIt = Map.find(
ID);
1893 if (MapIt == Map.end())
1896 return make_range(MapIt->second.begin(), MapIt->second.end());
1901 DVR->eraseFromParent();
1911 for (
auto *
I : InstVec)
1912 I->setMetadata(LLVMContext::MD_DIAssignID, New);
1922 if (DVR.isDbgAssign())
1923 DVR.eraseFromParent();
1925 I.setMetadata(LLVMContext::MD_DIAssignID,
nullptr);
1933 std::optional<DIExpression::FragmentInfo> &Result) {
1938 int64_t AddrOffsetInBits;
1940 int64_t AddrOffsetInBytes;
1944 AddrOffsetInBytes, PostOffsetOps))
1946 AddrOffsetInBits = AddrOffsetInBytes * 8;
1951 int64_t BitExtractOffsetInBits = 0;
1955 int64_t OffsetFromLocationInBits;
1957 DL, Dest, SliceOffsetInBits, SliceSizeInBits,
Addr, AddrOffsetInBits,
1958 BitExtractOffsetInBits, VarFrag, Result, OffsetFromLocationInBits);
1966 auto GetNewID = [&Map](
Metadata *Old) {
1976 if (DVR.isDbgAssign())
1977 DVR.setAssignId(GetNewID(DVR.getAssignID()));
1979 if (
auto *
ID =
I.getMetadata(LLVMContext::MD_DIAssignID))
1980 I.setMetadata(LLVMContext::MD_DIAssignID, GetNewID(
ID));
1986static std::optional<AssignmentInfo>
1990 return std::nullopt;
1991 APInt GEPOffset(
DL.getIndexTypeSizeInBits(StoreDest->
getType()), 0);
1993 DL, GEPOffset,
true);
1996 return std::nullopt;
2001 return std::nullopt;
2002 if (
const auto *Alloca = dyn_cast<AllocaInst>(
Base))
2004 return std::nullopt;
2009 const Value *StoreDest =
I->getRawDest();
2011 auto *ConstLengthInBytes = dyn_cast<ConstantInt>(
I->getLength());
2012 if (!ConstLengthInBytes)
2014 return std::nullopt;
2015 uint64_t SizeInBits = 8 * ConstLengthInBytes->getZExtValue();
2021 TypeSize SizeInBits =
DL.getTypeSizeInBits(SI->getValueOperand()->getType());
2035 auto *
ID = StoreLikeInst.
getMetadata(LLVMContext::MD_DIAssignID);
2036 assert(
ID &&
"Store instruction must have DIAssignID metadata");
2042 uint64_t FragStartBit = StoreStartBit;
2045 bool StoreToWholeVariable =
Info.StoreToWholeAlloca;
2054 FragEndBit = std::min(FragEndBit, VarEndBit);
2057 if (FragStartBit >= FragEndBit)
2060 StoreToWholeVariable = FragStartBit <= VarStartBit && FragEndBit >= *
Size;
2064 if (!StoreToWholeVariable) {
2066 FragEndBit - FragStartBit);
2067 assert(R.has_value() &&
"failed to create fragment expression");
2072 &StoreLikeInst, Val, VarRec.
Var, Expr, Dest, AddrExpr, VarRec.
DL);
2074 LLVM_DEBUG(
if (Assign)
errs() <<
" > INSERT: " << *Assign <<
"\n");
2078#define DEBUG_TYPE "assignment-tracking"
2087 auto &Ctx = Start->getContext();
2088 auto &
Module = *Start->getModule();
2096 for (
auto BBI = Start; BBI !=
End; ++BBI) {
2099 std::optional<AssignmentInfo>
Info;
2100 Value *ValueComponent =
nullptr;
2101 Value *DestComponent =
nullptr;
2102 if (
auto *AI = dyn_cast<AllocaInst>(&
I)) {
2109 }
else if (
auto *SI = dyn_cast<StoreInst>(&
I)) {
2111 ValueComponent = SI->getValueOperand();
2112 DestComponent = SI->getPointerOperand();
2113 }
else if (
auto *
MI = dyn_cast<MemTransferInst>(&
I)) {
2117 DestComponent =
MI->getOperand(0);
2118 }
else if (
auto *
MI = dyn_cast<MemSetInst>(&
I)) {
2122 auto *ConstValue = dyn_cast<ConstantInt>(
MI->getOperand(1));
2123 if (ConstValue && ConstValue->isZero())
2124 ValueComponent = ConstValue;
2127 DestComponent =
MI->getOperand(0);
2133 assert(ValueComponent && DestComponent);
2137 if (!
Info.has_value()) {
2140 <<
" | SKIP: Untrackable store (e.g. through non-const gep)\n");
2146 auto LocalIt = Vars.
find(
Info->Base);
2147 if (LocalIt == Vars.
end()) {
2150 <<
" | SKIP: Base address not associated with local variable\n");
2155 cast_or_null<DIAssignID>(
I.getMetadata(LLVMContext::MD_DIAssignID));
2158 I.setMetadata(LLVMContext::MD_DIAssignID,
ID);
2161 for (
const VarRecord &R : LocalIt->second)
2167bool AssignmentTrackingPass::runOnFunction(
Function &
F) {
2169 if (
F.hasFnAttribute(Attribute::OptimizeNone))
2172 bool Changed =
false;
2173 auto *
DL = &
F.getDataLayout();
2185 if (Declare.getExpression()->getNumElements() != 0)
2187 if (!Declare.getAddress())
2190 dyn_cast<AllocaInst>(Declare.getAddress()->stripPointerCasts())) {
2192 if (!Alloca->isStaticAlloca())
2195 if (
auto Sz = Alloca->getAllocationSize(*
DL); Sz && Sz->isScalable())
2197 DVRDeclares[Alloca].
insert(&Declare);
2201 for (
auto &BB :
F) {
2202 for (
auto &
I : BB) {
2204 if (DVR.isDbgDeclare())
2205 ProcessDeclare(DVR);
2222 for (
auto &[Insts, Declares] : DVRDeclares) {
2224 for (
auto *Declare : Declares) {
2238 Declare->eraseFromParent();
2246 "debug-info-assignment-tracking";
2256 return Value && !cast<ConstantAsMetadata>(
Value)->getValue()->isZeroValue();
2265 if (!runOnFunction(
F))
2282 bool Changed =
false;
2284 Changed |= runOnFunction(
F);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
static DIImportedEntity * createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context, Metadata *NS, DIFile *File, unsigned Line, StringRef Name, DINodeArray Elements, SmallVectorImpl< TrackingMDNodeRef > &ImportedModules)
static void setAssignmentTrackingModuleFlag(Module &M)
static DISubprogram::DISPFlags pack_into_DISPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized)
static void findDbgIntrinsics(Value *V, SmallVectorImpl< DbgVariableRecord * > &DbgVariableRecords)
static Metadata * stripLoopMDLoc(const SmallPtrSetImpl< Metadata * > &AllDILocation, const SmallPtrSetImpl< Metadata * > &DIReachable, Metadata *MD)
static MDNode * updateLoopMetadataDebugLocationsImpl(MDNode *OrigLoopID, function_ref< Metadata *(Metadata *)> Updater)
static MDNode * stripDebugLocFromLoopID(MDNode *N)
static const char * AssignmentTrackingModuleFlag
static DINode::DIFlags map_from_llvmDIFlags(LLVMDIFlags Flags)
static unsigned map_from_llvmDWARFsourcelanguage(LLVMDWARFSourceLanguage lang)
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.
static LLVMDIFlags map_to_llvmDIFlags(DINode::DIFlags Flags)
static bool getAssignmentTrackingModuleFlag(const Module &M)
PointerUnion< DIExpression *, DIVariable * > unwrapExprVar(LLVMMetadataRef MD)
MD may be nullptr, a DIExpression or DIVariable.
static bool isAllDILocation(SmallPtrSetImpl< Metadata * > &Visited, SmallPtrSetImpl< Metadata * > &AllDILocation, const SmallPtrSetImpl< Metadata * > &DIReachable, Metadata *MD)
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'...
DIT * unwrapDI(LLVMMetadataRef Ref)
static std::optional< AssignmentInfo > getAssignmentInfoImpl(const DataLayout &DL, const Value *StoreDest, TypeSize SizeInBits)
Collect constant properies (base, size, offset) of StoreDest.
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
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.
uint64_t IntrinsicInst * II
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static uint32_t getFlags(const Symbol *Sym)
Class for arbitrary precision integers.
bool isNegative() const
Determine sign of this APInt.
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.
An arbitrary precision integer that knows its signedness.
an instruction to allocate memory on the stack
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
A container for analyses that lazily runs them and caches their results.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
LLVM Basic Block Representation.
Represents analyses that only rely on functions' control flow.
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
SmallVector< DbgVariableRecord * > getAllDbgVariableRecordUsers()
static DIAssignID * getDistinct(LLVMContext &Context)
static LLVM_ABI 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...
static LLVM_ABI 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...
LLVM_ABI bool extractLeadingOffset(int64_t &OffsetInBytes, SmallVectorImpl< uint64_t > &RemainingOps) const
Assuming that the expression operates on an address, extract a constant offset and the successive ops...
A pair of DIGlobalVariable and DIExpression.
An imported module (C++ using directive or similar).
LLVM_ABI DISubprogram * getSubprogram() const
Get the subprogram for this scope.
DILocalScope * getScope() const
Get the local scope for this variable.
Tagged DWARF-like metadata node.
Base class for scope-like contexts.
LLVM_ABI StringRef getName() const
Subprogram description. Uses SubclassData1.
static LLVM_ABI DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, unsigned Virtuality=SPFlagNonvirtual, bool IsMainSubprogram=false)
DISPFlags
Debug info subprogram flags.
Type array for a subprogram.
LLVM_ABI std::optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Base class for non-instruction debug metadata records that have positions within IR.
DebugLoc getDebugLoc() const
LLVM_ABI LLVMContext & getContext()
Record of a variable value-assignment, aka a non instruction representation of the dbg....
LLVM_ABI bool isKillAddress() const
Check whether this kills the address component.
DbgVariableFragmentInfo getFragmentOrEntireVariable() const
Get the FragmentInfo for the variable if it exists, otherwise return a FragmentInfo that covers the e...
LLVM_ABI Value * getAddress() const
static LLVM_ABI DbgVariableRecord * createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
DIExpression * getAddressExpression() const
LLVM_ABI void processInstruction(const Module &M, const Instruction &I)
Process a single instruction and collect debug info anchors.
LLVM_ABI void processModule(const Module &M)
Process entire module and collect debug info anchors.
LLVM_ABI void processVariable(DILocalVariable *DVI)
Process a DILocalVariable.
LLVM_ABI void processSubprogram(DISubprogram *SP)
Process subprogram.
LLVM_ABI void processLocation(const Module &M, const DILocation *Loc)
Process debug info location.
LLVM_ABI void reset()
Clear all lists.
LLVM_ABI void processDbgRecord(const Module &M, const DbgRecord &DR)
Process a DbgRecord.
LLVM_ABI DILocation * get() const
Get the underlying DILocation.
LLVM_ABI MDNode * getScope() const
static LLVM_ABI DebugLoc getMergedLocation(DebugLoc LocA, DebugLoc LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
LLVM_ABI DILocation * getInlinedAt() const
static DebugLoc getDropped()
Identifies a unique instance of a whole variable (discards/ignores fragment information).
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...
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Implements a dense probed hash-table based set.
BasicBlockListType::iterator iterator
DISubprogram * getSubprogram() const
Get the attached subprogram.
LLVM_ABI void mergeDIAssignID(ArrayRef< const Instruction * > SourceInstructions)
Merge the DIAssignID metadata from this instruction and those attached to instructions in SourceInstr...
LLVM_ABI void dropLocation()
Drop the instruction's debug location.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
LLVM_ABI void updateLocationAfterHoist()
Updates the debug location given that the instruction has been hoisted from a block to a predecessor ...
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
LLVM_ABI void applyMergedLocation(DebugLoc LocA, DebugLoc LocB)
Merge 2 debug locations and apply it to the Instruction.
static LLVM_ABI bool mayLowerToFunctionCall(Intrinsic::ID IID)
Check if the intrinsic might lower into a regular function call in the course of IR transformations.
DenseMap< DIAssignID *, SmallVector< Instruction *, 1 > > AssignmentIDToInstrs
Map DIAssignID -> Instructions with that attachment.
This is an important class for using LLVM in a threaded context.
LLVMContextImpl *const pImpl
LLVM_ABI void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
static LLVM_ABI void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
const MDOperand & getOperand(unsigned I) const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumOperands() const
Return number of MDNode operands.
LLVMContext & getContext() const
Tracking metadata reference owned by Metadata.
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a temporary node.
This is the common base class for memset/memcpy/memmove.
A Module instance is used to store all the information related to an LLVM module.
@ Max
Takes the max of the two values, which are required to be integers.
LLVM_ABI StringRef getName() const
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
void push_back(EltTy NewVal)
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI const Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr, bool LookThroughIntToPtr=false) const
Accumulate the constant offset this value has compared to a base pointer.
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
LLVM_C_ABI 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.
LLVM_C_ABI LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location)
Get the "inline at" location associated with this debug location.
LLVM_C_ABI 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.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts)
Create debugging information entry for an array.
LLVM_C_ABI unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram)
Get the line associated with a given subprogram.
LLVM_C_ABI LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location)
Get the local scope associated with this debug location.
LLVM_C_ABI unsigned LLVMDITypeGetLine(LLVMMetadataRef DType)
Get the source line where this DIType is declared.
LLVMDWARFMacinfoRecordType
Describes the kind of macro declaration used for LLVMDIBuilderCreateMacro.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, int64_t Value, LLVMBool IsUnsigned)
Create debugging information entry for an enumerator.
LLVM_C_ABI 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...
LLVM_C_ABI void LLVMDIBuilderFinalize(LLVMDIBuilderRef Builder)
Construct any deferred debug info descriptors.
LLVM_C_ABI void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP)
Set the subprogram attached to a function.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateSetType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef BaseTy)
Create debugging information entry for a set.
LLVM_C_ABI void LLVMDIBuilderFinalizeSubprogram(LLVMDIBuilderRef Builder, LLVMMetadataRef Subprogram)
Finalize a specific subprogram.
LLVM_C_ABI 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.
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen)
Create a DWARF unspecified type.
LLVM_C_ABI LLVMDIBuilderRef LLVMCreateDIBuilderDisallowUnresolved(LLVMModuleRef M)
Construct a builder for a module, and do not allow for unresolved nodes attached to the module.
LLVM_C_ABI LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef Ctx, LLVMMetadataRef *Data, size_t NumElements)
Create a new temporary MDNode.
LLVM_C_ABI LLVMMetadataRef LLVMDIScopeGetFile(LLVMMetadataRef Scope)
Get the metadata of the file associated with a given scope.
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
LLVM_C_ABI LLVMDIBuilderRef LLVMCreateDIBuilder(LLVMModuleRef M)
Construct a builder for a module and collect unresolved nodes attached to the module in order to reso...
LLVM_C_ABI 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.
LLVM_C_ABI const char * LLVMDIFileGetSource(LLVMMetadataRef File, unsigned *Len)
Get the source of a given file.
LLVM_C_ABI unsigned LLVMDILocationGetColumn(LLVMMetadataRef Location)
Get the column number of this debug location.
LLVM_C_ABI 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...
LLVM_C_ABI const char * LLVMDIFileGetFilename(LLVMMetadataRef File, unsigned *Len)
Get the name of a given file.
LLVM_C_ABI LLVMMetadataRef LLVMGetSubprogram(LLVMValueRef Func)
Get the metadata of the subprogram attached to a function.
LLVMDWARFSourceLanguage
Source languages known by DWARF.
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertLabelAtEnd(LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo, LLVMMetadataRef Location, LLVMBasicBlockRef InsertAtEnd)
Insert a new llvm.dbg.label intrinsic call.
LLVM_C_ABI LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst)
Get the debug location for the given instruction.
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
LLVM_C_ABI void LLVMDisposeDIBuilder(LLVMDIBuilderRef Builder)
Deallocates the DIBuilder and everything it owns.
LLVM_C_ABI 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.
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
LLVM_C_ABI LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE)
Retrieves the DIVariable associated with this global variable expression.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder, LLVMMetadataRef *Data, size_t NumElements)
Create an array of DI Nodes.
LLVM_C_ABI 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.
LLVM_C_ABI 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.
LLVM_C_ABI uint64_t LLVMDITypeGetSizeInBits(LLVMMetadataRef DType)
Get the size of this DIType in bits.
LLVM_C_ABI void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef TempTargetMetadata, LLVMMetadataRef Replacement)
Replace all uses of temporary metadata.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder, LLVMMetadataRef *Data, size_t NumElements)
Create a type array.
LLVM_C_ABI LLVMMetadataRef LLVMDIGlobalVariableExpressionGetExpression(LLVMMetadataRef GVE)
Retrieves the DIExpression associated with this global variable expression.
LLVM_C_ABI 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.
LLVMDIFlags
Debug info flags.
LLVM_C_ABI 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.
LLVM_C_ABI unsigned LLVMDebugMetadataVersion(void)
The current debug metadata version number.
LLVM_C_ABI unsigned LLVMGetModuleDebugMetadataVersion(LLVMModuleRef Module)
The version of debug metadata that's present in the provided Module.
LLVM_C_ABI 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.
LLVM_C_ABI 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.
LLVM_C_ABI void LLVMDISubprogramReplaceType(LLVMMetadataRef Subprogram, LLVMMetadataRef SubroutineType)
Replace the subprogram subroutine type.
LLVM_C_ABI 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.
LLVM_C_ABI LLVMMetadataRef LLVMDIVariableGetScope(LLVMMetadataRef Var)
Get the metadata of the scope associated with a given variable.
LLVM_C_ABI 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.
LLVM_C_ABI 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...
LLVM_C_ABI 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.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromModule(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef M, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef *Elements, unsigned NumElements)
Create a descriptor for an imported module.
LLVM_C_ABI LLVMMetadataRef LLVMDIVariableGetFile(LLVMMetadataRef Var)
Get the metadata of the file associated with a given variable.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, int64_t LowerBound, int64_t Count)
Create a descriptor for a value range.
LLVM_C_ABI unsigned LLVMDILocationGetLine(LLVMMetadataRef Location)
Get the line number of this debug location.
LLVM_C_ABI LLVMDbgRecordRef LLVMDIBuilderInsertLabelBefore(LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo, LLVMMetadataRef Location, LLVMValueRef InsertBefore)
Insert a new llvm.dbg.label intrinsic call.
LLVM_C_ABI unsigned LLVMDIVariableGetLine(LLVMMetadataRef Var)
Get the source line where this DIVariable is declared.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type)
Create debugging information entry for a qualified type, e.g.
LLVM_C_ABI 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.
LLVM_C_ABI LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata)
Obtain the enumerated type of a Metadata instance.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateDynamicArrayType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, unsigned LineNo, LLVMMetadataRef File, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts, LLVMMetadataRef DataLocation, LLVMMetadataRef Associated, LLVMMetadataRef Allocated, LLVMMetadataRef Rank, LLVMMetadataRef BitStride)
Create debugging information entry for a dynamic array.
LLVMDWARFEmissionKind
The amount of debug information to emit.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateSubrangeType(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, unsigned LineNo, LLVMMetadataRef File, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags, LLVMMetadataRef BaseTy, LLVMMetadataRef LowerBound, LLVMMetadataRef UpperBound, LLVMMetadataRef Stride, LLVMMetadataRef Bias)
Create a descriptor for a subrange with dynamic bounds.
LLVM_C_ABI 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.
LLVM_C_ABI const char * LLVMDITypeGetName(LLVMMetadataRef DType, size_t *Length)
Get the name of this DIType.
LLVM_C_ABI uint64_t LLVMDITypeGetOffsetInBits(LLVMMetadataRef DType)
Get the offset of this DIType in bits.
LLVM_C_ABI 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.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateTempMacroFile(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentMacroFile, unsigned Line, LLVMMetadataRef File)
Create debugging information temporary entry for a macro file.
LLVM_C_ABI LLVMDIFlags LLVMDITypeGetFlags(LLVMMetadataRef DType)
Get the flags associated with this DIType.
LLVM_C_ABI 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.
LLVM_C_ABI 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.
LLVM_C_ABI uint16_t LLVMGetDINodeTag(LLVMMetadataRef MD)
Get the dwarf::Tag of a DINode.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateEnumeratorOfArbitraryPrecision(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, uint64_t SizeInBits, const uint64_t Words[], LLVMBool IsUnsigned)
Create debugging information entry for an enumerator of arbitrary precision.
LLVM_C_ABI void LLVMReplaceArrays(LLVMDIBuilderRef Builder, LLVMMetadataRef *T, LLVMMetadataRef *Elements, unsigned NumElements)
Replace arrays.
LLVM_C_ABI 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.
LLVM_C_ABI 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.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Discriminator)
Create a descriptor for a lexical block with a new file attached.
LLVM_C_ABI void LLVMDisposeTemporaryMDNode(LLVMMetadataRef TempNode)
Deallocate a temporary node.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder, LLVMMetadataRef Type, LLVMBool Implicit)
Create a uniqued DIType* clone with FlagObjectPointer.
LLVM_C_ABI 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.
unsigned LLVMDWARFTypeEncoding
An LLVM DWARF type encoding.
LLVM_C_ABI 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.
LLVM_C_ABI void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc)
Set the debug location for the given instruction.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder, LLVMMetadataRef File, LLVMMetadataRef *ParameterTypes, unsigned NumParameterTypes, LLVMDIFlags Flags)
Create subroutine type.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateVectorType(LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts)
Create debugging information entry for a vector type.
LLVM_C_ABI 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.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder)
Create C++11 nullptr type.
LLVM_C_ABI 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.
LLVM_C_ABI 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.
LLVM_C_ABI 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.
unsigned LLVMMetadataKind
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateReferenceType(LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type)
Create debugging information entry for a c++ style reference or rvalue reference type.
LLVM_C_ABI LLVMBool LLVMStripModuleDebugInfo(LLVMModuleRef Module)
Strip debug info in the module if it exists.
LLVM_C_ABI 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.
LLVM_C_ABI uint32_t LLVMDITypeGetAlignInBits(LLVMMetadataRef DType)
Get the alignment of this DIType in bits.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned Column)
Create a descriptor for a lexical block with the specified parent context.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateArtificialType(LLVMDIBuilderRef Builder, LLVMMetadataRef Type)
Create a uniqued DIType* clone with FlagArtificial set.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateDebugLocation(LLVMContextRef Ctx, unsigned Line, unsigned Column, LLVMMetadataRef Scope, LLVMMetadataRef InlinedAt)
Creates a new DebugLocation that describes a source location.
LLVM_C_ABI const char * LLVMDIFileGetDirectory(LLVMMetadataRef File, unsigned *Len)
Get the directory of a given file.
LLVM_C_ABI LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromNamespace(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef NS, LLVMMetadataRef File, unsigned Line)
Create a descriptor for an imported namespace.
@ LLVMGenericDINodeMetadataKind
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
struct LLVMOpaqueDbgRecord * LLVMDbgRecordRef
struct LLVMOpaqueContext * LLVMContextRef
The top-level container for all LLVM global data.
struct LLVMOpaqueBasicBlock * LLVMBasicBlockRef
Represents a basic block of instructions in LLVM IR.
struct LLVMOpaqueMetadata * LLVMMetadataRef
Represents an LLVM Metadata.
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
struct LLVMOpaqueDIBuilder * LLVMDIBuilderRef
Represents an LLVM debug info builder.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Assignment Tracking (at).
LLVM_ABI void deleteAll(Function *F)
Remove all Assignment Tracking related intrinsics and metadata from F.
LLVM_ABI AssignmentInstRange getAssignmentInsts(DIAssignID *ID)
Return a range of instructions (typically just one) that have ID as an attachment.
LLVM_ABI 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.
LLVM_ABI void remapAssignID(DenseMap< DIAssignID *, DIAssignID * > &Map, Instruction &I)
Replace DIAssignID uses and attachments with IDs from Map.
SmallVector< DbgVariableRecord * > getDVRAssignmentMarkers(const Instruction *Inst)
Return a range of dbg_assign records for which Inst performs the assignment they encode.
LLVM_ABI void deleteAssignmentMarkers(const Instruction *Inst)
Delete the llvm.dbg.assign intrinsics linked to Inst.
LLVM_ABI std::optional< AssignmentInfo > getAssignmentInfo(const DataLayout &DL, const MemIntrinsic *I)
LLVM_ABI void RAUW(DIAssignID *Old, DIAssignID *New)
Replace all uses (and attachments) of Old with New.
LLVM_ABI bool calculateFragmentIntersect(const DataLayout &DL, const Value *Dest, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const DbgVariableRecord *DVRAssign, std::optional< DIExpression::FragmentInfo > &Result)
Calculate the fragment of the variable in DAI covered from (Dest + SliceOffsetInBits) to to (Dest + S...
Calculates the starting offsets for various sections within the .debug_names section.
void prune(LinkGraph &G)
Removes dead symbols/blocks/addressables.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void findDbgValues(Value *V, SmallVectorImpl< DbgVariableRecord * > &DbgVariableRecords)
Finds the dbg.values describing a value.
LLVM_ABI bool stripDebugInfo(Function &F)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
@ Import
Import information from summary.
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...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
LLVM_ABI bool stripNonLineTableDebugInfo(Module &M)
Downgrade the debug info in a module to contain only line table information.
LLVM_ABI TinyPtrVector< DbgVariableRecord * > findDVRValues(Value *V)
As above, for DVRValues.
LLVM_ABI unsigned getDebugMetadataVersionFromModule(const Module &M)
Return Debug Info Metadata Version by checking module flags.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_ABI bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
@ Ref
The access may reference the value stored in memory.
Attribute unwrap(LLVMAttributeRef Attr)
LLVM_ABI bool isAssignmentTrackingEnabled(const Module &M)
Return true if assignment tracking is enabled for module M.
LLVM_ABI DebugLoc getDebugValueLoc(DbgVariableRecord *DVR)
Produce a DebugLoc to use for each dbg.declare that is promoted to a dbg.value.
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...
LLVMAttributeRef wrap(Attribute Attr)
LLVM_ABI TinyPtrVector< DbgVariableRecord * > findDVRDeclares(Value *V)
Finds dbg.declare records declaring local variables as living in the memory that 'V' points to.
static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DbgVariableRecord types only and downcast.
LLVM_ABI void updateLoopMetadataDebugLocations(Instruction &I, function_ref< Metadata *(Metadata *)> Updater)
Update the debug locations contained within the MD_loop metadata attached to the instruction I,...
LLVM_ABI void findDbgUsers(Value *V, SmallVectorImpl< DbgVariableRecord * > &DbgVariableRecords)
Finds the debug info records describing a value.
LLVM_ABI DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Helper object to track which of three possible relocation mechanisms are used for a particular value ...
Describes properties of a store that has a static size and offset into a some base storage.
Helper struct for trackAssignments, below.