50 if (!V->isUsedByMetadata())
60 for (
User *U : MDV->users())
61 if (
auto *DDI = dyn_cast<DbgDeclareInst>(U))
69 if (!V->isUsedByMetadata())
77 if (DVR->getType() == DbgVariableRecord::LocationType::Declare)
83template <
typename IntrinsicT,
bool DbgAssignAndValuesOnly>
89 if (!V->isUsedByMetadata())
102 auto AppendUsers = [&Ctx, &EncounteredIntrinsics,
103 &EncounteredDbgVariableRecords, &Result,
106 for (
User *U : MDV->users())
107 if (IntrinsicT *DVI = dyn_cast<IntrinsicT>(U))
108 if (EncounteredIntrinsics.
insert(DVI).second)
109 Result.push_back(DVI);
111 if (!DbgVariableRecords)
116 if (!DbgAssignAndValuesOnly || DVR->isDbgValue() || DVR->isDbgAssign())
117 if (EncounteredDbgVariableRecords.
insert(DVR).second)
125 for (
Metadata *AL : L->getAllArgListUsers()) {
127 if (!DbgVariableRecords)
131 if (!DbgAssignAndValuesOnly || DVR->isDbgValue() || DVR->isDbgAssign())
132 if (EncounteredDbgVariableRecords.
insert(DVR).second)
142 DbgValues, V, DbgVariableRecords);
149 DbgUsers, V, DbgVariableRecords);
153 if (
auto *LocalScope = dyn_cast_or_null<DILocalScope>(Scope))
167 return DILocation::get(DII->
getContext(), 0, 0, Scope, InlinedAt);
179 return DILocation::get(DVR->
getContext(), 0, 0, Scope, InlinedAt);
196 for (
auto *
CU : M.debug_compile_units())
197 processCompileUnit(
CU);
198 for (
auto &
F : M.functions()) {
199 if (
auto *SP = cast_or_null<DISubprogram>(
F.getSubprogram()))
210 if (!addCompileUnit(
CU))
212 for (
auto *DIG :
CU->getGlobalVariables()) {
213 if (!addGlobalVariable(DIG))
215 auto *GV = DIG->getVariable();
216 processScope(GV->getScope());
217 processType(GV->getType());
219 for (
auto *ET :
CU->getEnumTypes())
221 for (
auto *RT :
CU->getRetainedTypes())
222 if (
auto *
T = dyn_cast<DIType>(RT))
226 for (
auto *
Import :
CU->getImportedEntities()) {
227 auto *Entity =
Import->getEntity();
228 if (
auto *
T = dyn_cast<DIType>(Entity))
230 else if (
auto *SP = dyn_cast<DISubprogram>(Entity))
232 else if (
auto *NS = dyn_cast<DINamespace>(Entity))
233 processScope(NS->getScope());
234 else if (
auto *M = dyn_cast<DIModule>(Entity))
235 processScope(M->getScope());
241 if (
auto *DVI = dyn_cast<DbgVariableIntrinsic>(&
I))
244 if (
auto DbgLoc =
I.getDebugLoc())
247 for (
const DbgRecord &DPR :
I.getDbgRecordRange())
254 processScope(Loc->getScope());
264void DebugInfoFinder::processType(
DIType *DT) {
268 if (
auto *ST = dyn_cast<DISubroutineType>(DT)) {
273 if (
auto *DCT = dyn_cast<DICompositeType>(DT)) {
274 processType(DCT->getBaseType());
276 if (
auto *
T = dyn_cast<DIType>(
D))
278 else if (
auto *SP = dyn_cast<DISubprogram>(
D))
283 if (
auto *DDT = dyn_cast<DIDerivedType>(DT)) {
284 processType(DDT->getBaseType());
288void DebugInfoFinder::processScope(
DIScope *Scope) {
291 if (
auto *Ty = dyn_cast<DIType>(Scope)) {
295 if (
auto *
CU = dyn_cast<DICompileUnit>(Scope)) {
299 if (
auto *SP = dyn_cast<DISubprogram>(Scope)) {
303 if (!addScope(Scope))
305 if (
auto *LB = dyn_cast<DILexicalBlockBase>(Scope)) {
306 processScope(LB->getScope());
307 }
else if (
auto *NS = dyn_cast<DINamespace>(Scope)) {
308 processScope(NS->getScope());
309 }
else if (
auto *M = dyn_cast<DIModule>(Scope)) {
310 processScope(
M->getScope());
315 if (!addSubprogram(SP))
326 processCompileUnit(SP->getUnit());
327 processType(SP->getType());
328 for (
auto *Element : SP->getTemplateParams()) {
329 if (
auto *TType = dyn_cast<DITemplateTypeParameter>(Element)) {
330 processType(TType->getType());
331 }
else if (
auto *TVal = dyn_cast<DITemplateValueParameter>(Element)) {
332 processType(TVal->getType());
339 if (!NodesSeen.insert(DV).second)
345bool DebugInfoFinder::addType(
DIType *DT) {
349 if (!NodesSeen.insert(DT).second)
352 TYs.push_back(
const_cast<DIType *
>(DT));
359 if (!NodesSeen.insert(
CU).second)
367 if (!NodesSeen.insert(DIG).second)
378 if (!NodesSeen.insert(SP).second)
385bool DebugInfoFinder::addScope(
DIScope *Scope) {
390 if (
Scope->getNumOperands() == 0)
392 if (!NodesSeen.insert(Scope).second)
394 Scopes.push_back(Scope);
401 "Loop ID needs at least one operand");
403 "Loop ID should refer to itself");
412 else if (
Metadata *NewMD = Updater(MD))
424 MDNode *OrigLoopID =
I.getMetadata(LLVMContext::MD_loop);
428 I.setMetadata(LLVMContext::MD_loop, NewLoopID);
436 MDNode *
N = dyn_cast_or_null<MDNode>(MD);
439 if (isa<DILocation>(
N) || Reachable.
count(
N))
443 for (
auto &OpIt :
N->operands()) {
451 return Reachable.
count(
N);
458 MDNode *
N = dyn_cast_or_null<MDNode>(MD);
461 if (isa<DILocation>(
N) || AllDILocation.
count(
N))
463 if (!DIReachable.
count(
N))
467 for (
auto &OpIt :
N->operands()) {
482 if (isa<DILocation>(MD) || AllDILocation.
count(MD))
485 if (!DIReachable.
count(MD))
488 MDNode *
N = dyn_cast_or_null<MDNode>(MD);
493 bool HasSelfRef =
false;
494 for (
unsigned i = 0; i <
N->getNumOperands(); ++i) {
497 Args.push_back(
nullptr);
498 }
else if (
A == MD) {
499 assert(i == 0 &&
"expected i==0 for self-reference");
501 Args.push_back(
nullptr);
504 Args.push_back(NewArg);
507 if (Args.empty() || (HasSelfRef && Args.size() == 1))
518 assert(!
N->operands().empty() &&
"Missing self reference?");
529 [&Visited, &DILocationReachable](
const MDOperand &
Op) {
530 return isDILocationReachable(
531 Visited, DILocationReachable, Op.get());
539 [&Visited, &AllDILocation,
541 return isAllDILocation(Visited, AllDILocation,
542 DILocationReachable, Op.get());
553 bool Changed =
false;
554 if (
F.hasMetadata(LLVMContext::MD_dbg)) {
556 F.setSubprogram(
nullptr);
562 if (isa<DbgInfoIntrinsic>(&
I)) {
567 if (
I.getDebugLoc()) {
571 if (
auto *LoopID =
I.getMetadata(LLVMContext::MD_loop)) {
572 auto *NewLoopID = LoopIDsMap.
lookup(LoopID);
575 if (NewLoopID != LoopID)
576 I.setMetadata(LLVMContext::MD_loop, NewLoopID);
579 if (
I.hasMetadataOtherThanDebugLoc()) {
581 I.setMetadata(
"heapallocsite",
nullptr);
583 I.setMetadata(LLVMContext::MD_DIAssignID,
nullptr);
592 bool Changed =
false;
597 if (NMD.getName().starts_with(
"llvm.dbg.") ||
598 NMD.getName() ==
"llvm.gcov") {
599 NMD.eraseFromParent();
607 for (
auto &GV : M.globals()) {
608 Changed |= GV.eraseMetadata(LLVMContext::MD_dbg);
612 Materializer->setStripDebugInfo();
620class DebugTypeInfoRemoval {
625 MDNode *EmptySubroutineType;
649 auto Replacement = Replacements.find(M);
650 if (Replacement != Replacements.end())
651 return Replacement->second;
659 void traverseAndRemap(
MDNode *
N) { traverse(
N); }
664 auto *FileAndScope = cast_or_null<DIFile>(map(MDS->
getFile()));
667 auto *
Type = cast_or_null<DISubroutineType>(map(MDS->getType()));
669 cast_or_null<DIType>(map(MDS->getContainingType()));
670 auto *Unit = cast_or_null<DICompileUnit>(map(MDS->getUnit()));
671 auto Variables =
nullptr;
672 auto TemplateParams =
nullptr;
675 auto distinctMDSubprogram = [&]() {
676 return DISubprogram::getDistinct(
678 FileAndScope, MDS->getLine(),
Type, MDS->getScopeLine(),
679 ContainingType, MDS->getVirtualIndex(), MDS->getThisAdjustment(),
680 MDS->getFlags(), MDS->getSPFlags(), Unit, TemplateParams, Declaration,
685 return distinctMDSubprogram();
687 auto *NewMDS = DISubprogram::get(
689 FileAndScope, MDS->getLine(),
Type, MDS->getScopeLine(), ContainingType,
690 MDS->getVirtualIndex(), MDS->getThisAdjustment(), MDS->getFlags(),
691 MDS->getSPFlags(), Unit, TemplateParams, Declaration, Variables);
693 StringRef OldLinkageName = MDS->getLinkageName();
696 auto OrigLinkage = NewToLinkageName.find(NewMDS);
697 if (OrigLinkage != NewToLinkageName.end()) {
698 if (OrigLinkage->second == OldLinkageName)
704 return distinctMDSubprogram();
707 NewToLinkageName.insert({NewMDS, MDS->getLinkageName()});
717 auto *
File = cast_or_null<DIFile>(map(
CU->getFile()));
719 MDTuple *RetainedTypes =
nullptr;
720 MDTuple *GlobalVariables =
nullptr;
721 MDTuple *ImportedEntities =
nullptr;
722 return DICompileUnit::getDistinct(
723 CU->getContext(),
CU->getSourceLanguage(), File,
CU->getProducer(),
724 CU->isOptimized(),
CU->getFlags(),
CU->getRuntimeVersion(),
726 RetainedTypes, GlobalVariables, ImportedEntities,
CU->getMacros(),
727 CU->getDWOId(),
CU->getSplitDebugInlining(),
728 CU->getDebugInfoForProfiling(),
CU->getNameTableKind(),
729 CU->getRangesBaseAddress(),
CU->getSysRoot(),
CU->getSDK());
733 auto *
Scope = map(MLD->getScope());
734 auto *InlinedAt = map(MLD->getInlinedAt());
736 return DILocation::getDistinct(MLD->
getContext(), MLD->getLine(),
737 MLD->getColumn(), Scope, InlinedAt);
738 return DILocation::get(MLD->
getContext(), MLD->getLine(), MLD->getColumn(),
746 for (
auto &
I :
N->operands())
755 if (Replacements.count(
N))
761 if (
auto *MDSub = dyn_cast<DISubprogram>(
N)) {
762 remap(MDSub->getUnit());
763 return getReplacementSubprogram(MDSub);
765 if (isa<DISubroutineType>(
N))
766 return EmptySubroutineType;
767 if (
auto *
CU = dyn_cast<DICompileUnit>(
N))
768 return getReplacementCU(
CU);
771 if (
auto *MDLB = dyn_cast<DILexicalBlockBase>(
N))
773 return mapNode(MDLB->getScope());
774 if (
auto *MLD = dyn_cast<DILocation>(
N))
775 return getReplacementMDLocation(MLD);
782 return getReplacementMDNode(
N);
784 Replacements[
N] = doRemap(
N);
793void DebugTypeInfoRemoval::traverse(
MDNode *
N) {
794 if (!
N || Replacements.count(
N))
800 if (
auto *MDS = dyn_cast<DISubprogram>(Parent))
801 return Child == MDS->getRetainedNodes().
get();
810 while (!ToVisit.
empty()) {
811 auto *
N = ToVisit.
back();
812 if (!Opened.
insert(
N).second) {
818 for (
auto &
I :
N->operands())
819 if (
auto *MDN = dyn_cast_or_null<MDNode>(
I))
820 if (!Opened.
count(MDN) && !Replacements.count(MDN) && !
prune(
N, MDN) &&
821 !isa<DICompileUnit>(MDN))
827 bool Changed =
false;
831 if (
auto *DbgVal = M.getFunction(
Name)) {
832 while (!DbgVal->use_empty())
833 cast<Instruction>(DbgVal->user_back())->eraseFromParent();
834 DbgVal->eraseFromParent();
838 RemoveUses(
"llvm.dbg.declare");
839 RemoveUses(
"llvm.dbg.label");
840 RemoveUses(
"llvm.dbg.value");
843 for (
auto NMI = M.named_metadata_begin(), NME = M.named_metadata_end();
848 if (NMD->
getName() ==
"llvm.dbg.cu")
853 for (
auto &GV : M.globals())
854 GV.eraseMetadata(LLVMContext::MD_dbg);
856 DebugTypeInfoRemoval Mapper(M.getContext());
860 Mapper.traverseAndRemap(Node);
861 auto *NewNode = Mapper.mapNode(Node);
862 Changed |= Node != NewNode;
870 if (
auto *SP =
F.getSubprogram()) {
871 Mapper.traverseAndRemap(SP);
872 auto *NewSP = cast<DISubprogram>(Mapper.mapNode(SP));
873 Changed |= SP != NewSP;
874 F.setSubprogram(NewSP);
879 auto *Scope =
DL.getScope();
880 MDNode *InlinedAt =
DL.getInlinedAt();
881 Scope = remap(Scope);
882 InlinedAt = remap(InlinedAt);
888 I.setDebugLoc(remapDebugLoc(
I.getDebugLoc()));
892 if (
auto *Loc = dyn_cast_or_null<DILocation>(MD))
893 return remapDebugLoc(Loc).
get();
898 if (
I.hasMetadataOtherThanDebugLoc())
899 I.setMetadata(
"heapallocsite",
nullptr);
909 for (
auto &NMD : M.named_metadata()) {
926 if (
auto *Val = mdconst::dyn_extract_or_null<ConstantInt>(
927 M.getModuleFlag(
"Debug Info Version")))
928 return Val->getZExtValue();
944 if (
auto *MD =
I->getMetadata(LLVMContext::MD_DIAssignID))
947 "Merging with instruction from another function not allowed");
951 if (
auto *MD =
getMetadata(LLVMContext::MD_DIAssignID))
958 for (
auto It = std::next(IDs.
begin()),
End = IDs.
end(); It !=
End; ++It) {
974 bool MayLowerToCall =
false;
975 if (isa<CallBase>(
this)) {
976 auto *
II = dyn_cast<IntrinsicInst>(
this);
981 if (!MayLowerToCall) {
1010#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
1011 case LLVMDWARFSourceLanguage##NAME: \
1013#include "llvm/BinaryFormat/Dwarf.def"
1014#undef HANDLE_DW_LANG
1020 return (DIT *)(
Ref ? unwrap<MDNode>(
Ref) :
nullptr);
1061 unwrap(Builder)->finalize();
1066 unwrap(Builder)->finalizeSubprogram(unwrapDI<DISubprogram>(subprogram));
1072 LLVMBool isOptimized,
const char *Flags,
size_t FlagsLen,
1073 unsigned RuntimeVer,
const char *SplitName,
size_t SplitNameLen,
1075 LLVMBool DebugInfoForProfiling,
const char *SysRoot,
size_t SysRootLen,
1076 const char *SDK,
size_t SDKLen) {
1077 auto File = unwrapDI<DIFile>(FileRef);
1079 return wrap(
unwrap(Builder)->createCompileUnit(
1082 RuntimeVer,
StringRef(SplitName, SplitNameLen),
1084 SplitDebugInlining, DebugInfoForProfiling,
1091 size_t FilenameLen,
const char *Directory,
1092 size_t DirectoryLen) {
1099 const char *
Name,
size_t NameLen,
1100 const char *ConfigMacros,
size_t ConfigMacrosLen,
1101 const char *IncludePath,
size_t IncludePathLen,
1102 const char *APINotesFile,
size_t APINotesFileLen) {
1105 StringRef(ConfigMacros, ConfigMacrosLen),
1107 StringRef(APINotesFile, APINotesFileLen)));
1112 const char *
Name,
size_t NameLen,
1114 return wrap(
unwrap(Builder)->createNameSpace(
1115 unwrapDI<DIScope>(ParentScope),
StringRef(
Name, NameLen), ExportSymbols));
1120 size_t NameLen,
const char *
LinkageName,
size_t LinkageNameLen,
1125 unwrapDI<DIScope>(Scope), {
Name, NameLen}, {
LinkageName, LinkageNameLen},
1126 unwrapDI<DIFile>(File), LineNo, unwrapDI<DISubroutineType>(Ty), ScopeLine,
1136 return wrap(
unwrap(Builder)->createLexicalBlock(unwrapDI<DIScope>(Scope),
1137 unwrapDI<DIFile>(File),
1145 unsigned Discriminator) {
1146 return wrap(
unwrap(Builder)->createLexicalBlockFile(unwrapDI<DIScope>(Scope),
1147 unwrapDI<DIFile>(File),
1158 unwrapDI<DINamespace>(NS),
1159 unwrapDI<DIFile>(File),
1169 ?
unwrap(Builder)->getOrCreateArray({
unwrap(Elements), NumElements})
1172 unwrapDI<DIScope>(Scope), unwrapDI<DIImportedEntity>(ImportedEntity),
1173 unwrapDI<DIFile>(File), Line, Elts));
1179 unsigned NumElements) {
1182 ?
unwrap(Builder)->getOrCreateArray({
unwrap(Elements), NumElements})
1185 unwrapDI<DIScope>(Scope), unwrapDI<DIModule>(M), unwrapDI<DIFile>(File),
1195 ?
unwrap(Builder)->getOrCreateArray({
unwrap(Elements), NumElements})
1197 return wrap(
unwrap(Builder)->createImportedDeclaration(
1198 unwrapDI<DIScope>(Scope), unwrapDI<DINode>(Decl), unwrapDI<DIFile>(File),
1199 Line, {
Name, NameLen}, Elts));
1211 return unwrapDI<DILocation>(Location)->getLine();
1215 return unwrapDI<DILocation>(Location)->getColumn();
1219 return wrap(unwrapDI<DILocation>(Location)->
getScope());
1223 return wrap(unwrapDI<DILocation>(Location)->getInlinedAt());
1227 return wrap(unwrapDI<DIScope>(Scope)->getFile());
1231 auto Dir = unwrapDI<DIFile>(File)->getDirectory();
1237 auto Name = unwrapDI<DIFile>(File)->getFilename();
1243 if (
auto Src = unwrapDI<DIFile>(File)->getSource()) {
1255 const char *
Name,
size_t NameLen,
1256 const char *
Value,
size_t ValueLen) {
1258 unwrap(Builder)->createMacro(unwrapDI<DIMacroFile>(ParentMacroFile), Line,
1267 return wrap(
unwrap(Builder)->createTempMacroFile(
1268 unwrapDI<DIMacroFile>(ParentMacroFile), Line, unwrapDI<DIFile>(File)));
1272 const char *
Name,
size_t NameLen,
1284auto Elts =
unwrap(Builder)->getOrCreateArray({
unwrap(Elements),
1286return wrap(
unwrap(Builder)->createEnumerationType(
1287 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File),
1288 LineNumber, SizeInBits, AlignInBits, Elts, unwrapDI<DIType>(ClassTy)));
1295 LLVMMetadataRef *Elements,
unsigned NumElements,
unsigned RunTimeLang,
1296 const char *UniqueId,
size_t UniqueIdLen) {
1297 auto Elts =
unwrap(Builder)->getOrCreateArray({
unwrap(Elements),
1299 return wrap(
unwrap(Builder)->createUnionType(
1300 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File),
1302 Elts, RunTimeLang, {UniqueId, UniqueIdLen}));
1310 unsigned NumSubscripts) {
1311 auto Subs =
unwrap(Builder)->getOrCreateArray({
unwrap(Subscripts),
1314 unwrapDI<DIType>(Ty), Subs));
1321 unsigned NumSubscripts) {
1322 auto Subs =
unwrap(Builder)->getOrCreateArray({
unwrap(Subscripts),
1325 unwrapDI<DIType>(Ty), Subs));
1330 size_t NameLen,
uint64_t SizeInBits,
1334 SizeInBits, Encoding,
1341 const char *
Name,
size_t NameLen) {
1342 return wrap(
unwrap(Builder)->createPointerType(
1343 unwrapDI<DIType>(PointeeTy), SizeInBits, AlignInBits,
AddressSpace,
1352 unsigned NumElements,
unsigned RunTimeLang,
LLVMMetadataRef VTableHolder,
1353 const char *UniqueId,
size_t UniqueIdLen) {
1354 auto Elts =
unwrap(Builder)->getOrCreateArray({
unwrap(Elements),
1356 return wrap(
unwrap(Builder)->createStructType(
1357 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File),
1359 unwrapDI<DIType>(DerivedFrom), Elts, RunTimeLang,
1360 unwrapDI<DIType>(VTableHolder), {UniqueId, UniqueIdLen}));
1368 return wrap(
unwrap(Builder)->createMemberType(unwrapDI<DIScope>(Scope),
1369 {
Name, NameLen}, unwrapDI<DIFile>(File), LineNo, SizeInBits, AlignInBits,
1376 return wrap(
unwrap(Builder)->createUnspecifiedType({
Name, NameLen}));
1384 return wrap(
unwrap(Builder)->createStaticMemberType(
1385 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File),
1387 unwrap<Constant>(ConstantVal), DW_TAG_member, AlignInBits));
1392 const char *
Name,
size_t NameLen,
1398 {
Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1399 SizeInBits, AlignInBits, OffsetInBits,
1401 unwrapDI<MDNode>(PropertyNode)));
1406 const char *
Name,
size_t NameLen,
1408 const char *GetterName,
size_t GetterNameLen,
1409 const char *SetterName,
size_t SetterNameLen,
1410 unsigned PropertyAttributes,
1412 return wrap(
unwrap(Builder)->createObjCProperty(
1413 {
Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1414 {GetterName, GetterNameLen}, {SetterName, SetterNameLen},
1415 PropertyAttributes, unwrapDI<DIType>(Ty)));
1421 return wrap(
unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(
Type)));
1426 const char *
Name,
size_t NameLen,
1430 unwrapDI<DIType>(
Type), {
Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1431 unwrapDI<DIScope>(Scope), AlignInBits));
1439 return wrap(
unwrap(Builder)->createInheritance(
1440 unwrapDI<DIType>(Ty), unwrapDI<DIType>(
BaseTy),
1449 const char *UniqueIdentifier,
size_t UniqueIdentifierLen) {
1450 return wrap(
unwrap(Builder)->createForwardDecl(
1451 Tag, {
Name, NameLen}, unwrapDI<DIScope>(Scope),
1452 unwrapDI<DIFile>(File), Line, RuntimeLang, SizeInBits,
1453 AlignInBits, {UniqueIdentifier, UniqueIdentifierLen}));
1462 size_t UniqueIdentifierLen) {
1463 return wrap(
unwrap(Builder)->createReplaceableCompositeType(
1464 Tag, {
Name, NameLen}, unwrapDI<DIScope>(Scope),
1465 unwrapDI<DIFile>(File), Line, RuntimeLang, SizeInBits,
1467 {UniqueIdentifier, UniqueIdentifierLen}));
1474 unwrapDI<DIType>(
Type)));
1481 unwrapDI<DIType>(
Type)));
1486 return wrap(
unwrap(Builder)->createNullPtrType());
1496 return wrap(
unwrap(Builder)->createMemberPointerType(
1497 unwrapDI<DIType>(PointeeType),
1498 unwrapDI<DIType>(ClassType), AlignInBits, SizeInBits,
1505 const char *
Name,
size_t NameLen,
1511 return wrap(
unwrap(Builder)->createBitFieldMemberType(
1512 unwrapDI<DIScope>(Scope), {
Name, NameLen},
1513 unwrapDI<DIFile>(File), LineNumber,
1514 SizeInBits, OffsetInBits, StorageOffsetInBits,
1525 const char *UniqueIdentifier,
size_t UniqueIdentifierLen) {
1526 auto Elts =
unwrap(Builder)->getOrCreateArray({
unwrap(Elements),
1528 return wrap(
unwrap(Builder)->createClassType(
1529 unwrapDI<DIScope>(Scope), {
Name, NameLen}, unwrapDI<DIFile>(File),
1530 LineNumber, SizeInBits, AlignInBits, OffsetInBits,
1532 0, unwrapDI<DIType>(VTableHolder),
1533 unwrapDI<MDNode>(TemplateParamsNode),
1534 {UniqueIdentifier, UniqueIdentifierLen}));
1540 return wrap(
unwrap(Builder)->createArtificialType(unwrapDI<DIType>(
Type)));
1544 return unwrapDI<DINode>(MD)->getTag();
1548 StringRef Str = unwrapDI<DIType>(DType)->getName();
1554 return unwrapDI<DIType>(DType)->getSizeInBits();
1558 return unwrapDI<DIType>(DType)->getOffsetInBits();
1562 return unwrapDI<DIType>(DType)->getAlignInBits();
1566 return unwrapDI<DIType>(DType)->getLine();
1584 unsigned NumParameterTypes,
1586 auto Elts =
unwrap(Builder)->getOrCreateTypeArray({
unwrap(ParameterTypes),
1587 NumParameterTypes});
1588 return wrap(
unwrap(Builder)->createSubroutineType(
1606 size_t NameLen,
const char *Linkage,
size_t LinkLen,
LLVMMetadataRef File,
1609 return wrap(
unwrap(Builder)->createGlobalVariableExpression(
1610 unwrapDI<DIScope>(Scope), {
Name, NameLen}, {Linkage, LinkLen},
1611 unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
1612 true, unwrap<DIExpression>(Expr), unwrapDI<MDNode>(Decl),
1613 nullptr, AlignInBits));
1617 return wrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getVariable());
1622 return wrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getExpression());
1626 return wrap(unwrapDI<DIVariable>(Var)->getFile());
1634 return unwrapDI<DIVariable>(Var)->getLine();
1649 auto *
Node = unwrapDI<MDNode>(TargetMetadata);
1650 Node->replaceAllUsesWith(
unwrap(Replacement));
1656 size_t NameLen,
const char *Linkage,
size_t LnkLen,
LLVMMetadataRef File,
1659 return wrap(
unwrap(Builder)->createTempGlobalVariableFwdDecl(
1660 unwrapDI<DIScope>(Scope), {
Name, NameLen}, {Linkage, LnkLen},
1661 unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), LocalToUnit,
1662 unwrapDI<MDNode>(Decl),
nullptr, AlignInBits));
1669 unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1670 unwrap<DIExpression>(Expr), unwrap<DILocation>(
DL),
1671 unwrap<Instruction>(Instr));
1677 assert(isa<DbgRecord *>(DbgInst) &&
1678 "Function unexpectedly in old debug info format");
1679 return wrap(cast<DbgRecord *>(DbgInst));
1686 unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
1687 unwrap<DIExpression>(Expr), unwrap<DILocation>(
DL),
unwrap(
Block));
1693 assert(isa<DbgRecord *>(DbgInst) &&
1694 "Function unexpectedly in old debug info format");
1695 return wrap(cast<DbgRecord *>(DbgInst));
1702 unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
1703 unwrap<DILocation>(
DebugLoc), unwrap<Instruction>(Instr));
1709 assert(isa<DbgRecord *>(DbgInst) &&
1710 "Function unexpectedly in old debug info format");
1711 return wrap(cast<DbgRecord *>(DbgInst));
1718 unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
1725 assert(isa<DbgRecord *>(DbgInst) &&
1726 "Function unexpectedly in old debug info format");
1727 return wrap(cast<DbgRecord *>(DbgInst));
1734 return wrap(
unwrap(Builder)->createAutoVariable(
1735 unwrap<DIScope>(Scope), {
Name, NameLen}, unwrap<DIFile>(File),
1736 LineNo, unwrap<DIType>(Ty), AlwaysPreserve,
1742 size_t NameLen,
unsigned ArgNo,
LLVMMetadataRef File,
unsigned LineNo,
1744 return wrap(
unwrap(Builder)->createParameterVariable(
1745 unwrap<DIScope>(Scope), {
Name, NameLen}, ArgNo, unwrap<DIFile>(File),
1746 LineNo, unwrap<DIType>(Ty), AlwaysPreserve,
1751 int64_t
Lo, int64_t Count) {
1752 return wrap(
unwrap(Builder)->getOrCreateSubrange(
Lo, Count));
1767 unwrap<Function>(Func)->setSubprogram(unwrap<DISubprogram>(SP));
1771 return unwrapDI<DISubprogram>(Subprogram)->getLine();
1780 unwrap<Instruction>(Inst)->setDebugLoc(
DebugLoc(unwrap<MDNode>(Loc)));
1782 unwrap<Instruction>(Inst)->setDebugLoc(
DebugLoc());
1787#define HANDLE_METADATA_LEAF(CLASS) \
1788 case Metadata::CLASS##Kind: \
1789 return (LLVMMetadataKind)LLVM##CLASS##MetadataKind;
1790#include "llvm/IR/Metadata.def"
1797 assert(
ID &&
"Expected non-null ID");
1801 auto MapIt = Map.find(
ID);
1802 if (MapIt == Map.end())
1805 return make_range(MapIt->second.begin(), MapIt->second.end());
1809 assert(
ID &&
"Expected non-null ID");
1819 return make_range(IDAsValue->user_begin(), IDAsValue->user_end());
1828 for (
auto *DAI : ToDelete)
1829 DAI->eraseFromParent();
1830 for (
auto *DVR : DVRAssigns)
1831 DVR->eraseFromParent();
1841 for (
auto *
I : InstVec)
1842 I->setMetadata(LLVMContext::MD_DIAssignID, New);
1853 if (DVR.isDbgAssign())
1855 if (
auto *DAI = dyn_cast<DbgAssignIntrinsic>(&
I))
1858 I.setMetadata(LLVMContext::MD_DIAssignID,
nullptr);
1861 for (
auto *DAI : ToDelete)
1862 DAI->eraseFromParent();
1863 for (
auto *DVR : DPToDelete)
1864 DVR->eraseFromParent();
1869template <
typename T>
1872 uint64_t SliceSizeInBits,
const T *AssignRecord,
1873 std::optional<DIExpression::FragmentInfo> &Result) {
1875 if (AssignRecord->isKillAddress())
1878 int64_t AddrOffsetInBits;
1880 int64_t AddrOffsetInBytes;
1883 if (!AssignRecord->getAddressExpression()->extractLeadingOffset(
1884 AddrOffsetInBytes, PostOffsetOps))
1886 AddrOffsetInBits = AddrOffsetInBytes * 8;
1889 Value *
Addr = AssignRecord->getAddress();
1891 int64_t BitExtractOffsetInBits = 0;
1893 AssignRecord->getFragmentOrEntireVariable();
1895 int64_t OffsetFromLocationInBits;
1897 DL, Dest, SliceOffsetInBits, SliceSizeInBits,
Addr, AddrOffsetInBits,
1898 BitExtractOffsetInBits, VarFrag, Result, OffsetFromLocationInBits);
1906 std::optional<DIExpression::FragmentInfo> &Result) {
1908 SliceSizeInBits, DbgAssign, Result);
1916 std::optional<DIExpression::FragmentInfo> &Result) {
1918 SliceSizeInBits, DVRAssign, Result);
1926 auto GetNewID = [&Map](
Metadata *Old) {
1936 if (DVR.isDbgAssign())
1937 DVR.setAssignId(GetNewID(DVR.getAssignID()));
1939 if (
auto *
ID =
I.getMetadata(LLVMContext::MD_DIAssignID))
1940 I.setMetadata(LLVMContext::MD_DIAssignID, GetNewID(
ID));
1941 else if (
auto *DAI = dyn_cast<DbgAssignIntrinsic>(&
I))
1942 DAI->setAssignId(GetNewID(DAI->getAssignID()));
1948static std::optional<AssignmentInfo>
1952 return std::nullopt;
1953 APInt GEPOffset(
DL.getIndexTypeSizeInBits(StoreDest->
getType()), 0);
1955 DL, GEPOffset,
true);
1958 return std::nullopt;
1963 return std::nullopt;
1964 if (
const auto *Alloca = dyn_cast<AllocaInst>(
Base))
1966 return std::nullopt;
1971 const Value *StoreDest =
I->getRawDest();
1973 auto *ConstLengthInBytes = dyn_cast<ConstantInt>(
I->getLength());
1974 if (!ConstLengthInBytes)
1976 return std::nullopt;
1977 uint64_t SizeInBits = 8 * ConstLengthInBytes->getZExtValue();
1983 TypeSize SizeInBits =
DL.getTypeSizeInBits(SI->getValueOperand()->getType());
1997 auto *
ID = StoreLikeInst.
getMetadata(LLVMContext::MD_DIAssignID);
1998 assert(
ID &&
"Store instruction must have DIAssignID metadata");
2004 uint64_t FragStartBit = StoreStartBit;
2007 bool StoreToWholeVariable =
Info.StoreToWholeAlloca;
2016 FragEndBit = std::min(FragEndBit, VarEndBit);
2019 if (FragStartBit >= FragEndBit)
2022 StoreToWholeVariable = FragStartBit <= VarStartBit && FragEndBit >= *
Size;
2027 if (!StoreToWholeVariable) {
2029 FragEndBit - FragStartBit);
2030 assert(R.has_value() &&
"failed to create fragment expression");
2035 if (StoreLikeInst.
getParent()->IsNewDbgInfoFormat) {
2037 &StoreLikeInst, Val, VarRec.
Var, Expr, Dest, AddrExpr, VarRec.
DL);
2039 LLVM_DEBUG(
if (Assign)
errs() <<
" > INSERT: " << *Assign <<
"\n");
2043 AddrExpr, VarRec.
DL);
2046 if (Assign.is<DbgRecord *>())
2047 errs() <<
" > INSERT: " << *Assign.get<DbgRecord *>() <<
"\n";
2049 errs() <<
" > INSERT: " << *Assign.get<Instruction *>() <<
"\n";
2054#define DEBUG_TYPE "assignment-tracking"
2063 auto &Ctx = Start->getContext();
2064 auto &
Module = *Start->getModule();
2072 for (
auto BBI = Start; BBI !=
End; ++BBI) {
2075 std::optional<AssignmentInfo>
Info;
2076 Value *ValueComponent =
nullptr;
2077 Value *DestComponent =
nullptr;
2078 if (
auto *AI = dyn_cast<AllocaInst>(&
I)) {
2083 ValueComponent = Undef;
2085 }
else if (
auto *SI = dyn_cast<StoreInst>(&
I)) {
2087 ValueComponent = SI->getValueOperand();
2088 DestComponent = SI->getPointerOperand();
2089 }
else if (
auto *
MI = dyn_cast<MemTransferInst>(&
I)) {
2092 ValueComponent = Undef;
2093 DestComponent =
MI->getOperand(0);
2094 }
else if (
auto *
MI = dyn_cast<MemSetInst>(&
I)) {
2098 auto *ConstValue = dyn_cast<ConstantInt>(
MI->getOperand(1));
2099 if (ConstValue && ConstValue->isZero())
2100 ValueComponent = ConstValue;
2102 ValueComponent = Undef;
2103 DestComponent =
MI->getOperand(0);
2109 assert(ValueComponent && DestComponent);
2113 if (!
Info.has_value()) {
2116 <<
" | SKIP: Untrackable store (e.g. through non-const gep)\n");
2122 auto LocalIt = Vars.
find(
Info->Base);
2123 if (LocalIt == Vars.
end()) {
2126 <<
" | SKIP: Base address not associated with local variable\n");
2131 cast_or_null<DIAssignID>(
I.getMetadata(LLVMContext::MD_DIAssignID));
2134 I.setMetadata(LLVMContext::MD_DIAssignID,
ID);
2137 for (
const VarRecord &R : LocalIt->second)
2143bool AssignmentTrackingPass::runOnFunction(
Function &
F) {
2145 if (
F.hasFnAttribute(Attribute::OptimizeNone))
2148 bool Changed =
false;
2149 auto *
DL = &
F.getDataLayout();
2158 auto ProcessDeclare = [&](
auto *Declare,
auto &DeclareList) {
2162 if (Declare->getExpression()->getNumElements() != 0)
2164 if (!Declare->getAddress())
2167 dyn_cast<AllocaInst>(Declare->getAddress()->stripPointerCasts())) {
2169 if (!Alloca->isStaticAlloca())
2172 if (
auto Sz = Alloca->getAllocationSize(*
DL); Sz && Sz->isScalable())
2174 DeclareList[Alloca].
insert(Declare);
2178 for (
auto &BB :
F) {
2179 for (
auto &
I : BB) {
2181 if (DVR.isDbgDeclare())
2182 ProcessDeclare(&DVR, DVRDeclares);
2185 ProcessDeclare(DDI, DbgDeclares);
2201 auto DeleteSubsumedDeclare = [&](
const auto &
Markers,
auto &Declares) {
2203 for (
auto *Declare : Declares) {
2217 Declare->eraseFromParent();
2221 for (
auto &
P : DbgDeclares)
2223 for (
auto &
P : DVRDeclares)
2229 "debug-info-assignment-tracking";
2239 return Value && !cast<ConstantAsMetadata>(
Value)->getValue()->isZeroValue();
2248 if (!runOnFunction(
F))
2265 bool Changed =
false;
2267 Changed |= runOnFunction(
F);
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 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)
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.
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 void findDbgIntrinsics(SmallVectorImpl< IntrinsicT * > &Result, Value *V, SmallVectorImpl< DbgVariableRecord * > *DbgVariableRecords)
static bool getAssignmentTrackingModuleFlag(const Module &M)
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.
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.
Module.h This file contains the declarations for the Module class.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
This header defines various interfaces for pass management in LLVM.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static SPIRV::Scope::Scope getScope(SyncScope::ID Ord, const SyncScopeIDs &SSIDs)
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 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),...
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)
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.
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...
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...
A pair of DIGlobalVariable and DIExpression.
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
DILocalScope * getScope() const
Get the local scope for this variable.
static DILocation * getMergedLocation(DILocation *LocA, DILocation *LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
Tagged DWARF-like metadata node.
Base class for scope-like contexts.
StringRef getName() const
DIScope * getScope() const
static DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, unsigned Virtuality=SPFlagNonvirtual, bool IsMainSubprogram=false)
DISPFlags
Debug info subprogram flags.
Type array for a subprogram.
DIScope * getScope() const
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.
This represents the llvm.dbg.assign instruction.
This represents the llvm.dbg.declare instruction.
Base class for non-instruction debug metadata records that have positions within IR.
DebugLoc getDebugLoc() const
LLVMContext & getContext()
This represents the llvm.dbg.value instruction.
This is the common base class for debug info intrinsics for variables.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
static DbgVariableRecord * createLinkedDVRAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *Variable, DIExpression *Expression, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
void processInstruction(const Module &M, const Instruction &I)
Process a single instruction and collect debug info anchors.
void processModule(const Module &M)
Process entire module and collect debug info anchors.
void processVariable(const Module &M, const DILocalVariable *DVI)
Process a DILocalVariable.
void processSubprogram(DISubprogram *SP)
Process subprogram.
void processLocation(const Module &M, const DILocation *Loc)
Process debug info location.
void reset()
Clear all lists.
void processDbgRecord(const Module &M, const DbgRecord &DR)
Process a DbgRecord (e.g, treat a DbgVariableRecord like a DbgVariableIntrinsic).
DILocation * get() const
Get the underlying DILocation.
MDNode * getScope() const
DILocation * getInlinedAt() const
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.
void mergeDIAssignID(ArrayRef< const Instruction * > SourceInstructions)
Merge the DIAssignID metadata from this instruction and those attached to instructions in SourceInstr...
void dropLocation()
Drop the instruction's debug location.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
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.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
void updateLocationAfterHoist()
Updates the debug location given that the instruction has been hoisted from a block to a predecessor ...
void applyMergedLocation(DILocation *LocA, DILocation *LocB)
Merge 2 debug locations and apply it to the Instruction.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
static 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
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 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.
StringRef getName() const
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
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.
void 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 IntegerType * getInt1Ty(LLVMContext &C)
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
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.
LLVMContext & getContext() const
All values hold a context through their type.
user_iterator_impl< User > user_iterator
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.
const ParentTy * getParent() const
A range adaptor for a pair of iterators.
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.
LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location)
Get the "inline at" location associated with this debug location.
LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder, LLVMMetadataRef *Data, size_t NumElements)
Create an array of DI Nodes.
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.
LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromModule(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef M, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef *Elements, unsigned NumElements)
Create a descriptor for an imported module.
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder, LLVMMetadataRef Type)
Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
uint64_t LLVMDITypeGetSizeInBits(LLVMMetadataRef DType)
Get the size of this DIType in bits.
LLVMDWARFMacinfoRecordType
Describes the kind of macro declaration used for LLVMDIBuilderCreateMacro.
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.
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
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.
LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE)
Retrieves the DIVariable associated with this global variable expression.
LLVMMetadataRef LLVMDIBuilderCreateArtificialType(LLVMDIBuilderRef Builder, LLVMMetadataRef Type)
Create a uniqued DIType* clone with FlagArtificial set.
void LLVMDIBuilderFinalize(LLVMDIBuilderRef Builder)
Construct any deferred debug info descriptors.
LLVMMetadataRef LLVMDIBuilderCreateLexicalBlockFile(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Discriminator)
Create a descriptor for a lexical block with a new file attached.
unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram)
Get the line associated with a given subprogram.
LLVMMetadataRef LLVMDIBuilderCreateUnspecifiedType(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen)
Create a DWARF unspecified type.
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.
LLVMMetadataRef LLVMDIBuilderCreateDebugLocation(LLVMContextRef Ctx, unsigned Line, unsigned Column, LLVMMetadataRef Scope, LLVMMetadataRef InlinedAt)
Creates a new DebugLocation that describes a source location.
uint32_t LLVMDITypeGetAlignInBits(LLVMMetadataRef DType)
Get the alignment of this DIType in bits.
LLVMMetadataRef LLVMDIGlobalVariableExpressionGetExpression(LLVMMetadataRef GVE)
Retrieves the DIExpression associated with this global variable expression.
LLVMMetadataRef LLVMDIVariableGetScope(LLVMMetadataRef Var)
Get the metadata of the scope associated with a given variable.
LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst)
Get the debug location for the given instruction.
LLVMMetadataRef LLVMDIBuilderCreateReferenceType(LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type)
Create debugging information entry for a c++ style reference or rvalue reference type.
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.
LLVMDIBuilderRef LLVMCreateDIBuilderDisallowUnresolved(LLVMModuleRef M)
Construct a builder for a module, and do not allow for unresolved nodes attached to the module.
void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP)
Set the subprogram attached to a function.
LLVMDWARFSourceLanguage
Source languages known by DWARF.
LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, int64_t LowerBound, int64_t Count)
Create a descriptor for a value range.
LLVMDIBuilderRef LLVMCreateDIBuilder(LLVMModuleRef M)
Construct a builder for a module and collect unresolved nodes attached to the module in order to reso...
void LLVMDisposeTemporaryMDNode(LLVMMetadataRef TempNode)
Deallocate a temporary node.
LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location)
Get the local scope associated with this debug location.
LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromNamespace(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef NS, LLVMMetadataRef File, unsigned Line)
Create a descriptor for an imported namespace.
LLVMMetadataRef LLVMDIBuilderCreateTempMacroFile(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentMacroFile, unsigned Line, LLVMMetadataRef File)
Create debugging information temporary entry for a macro file.
void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc)
Set the debug location for the given instruction.
LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, int64_t Value, LLVMBool IsUnsigned)
Create debugging information entry for an enumerator.
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...
LLVMMetadataRef LLVMDIBuilderCreateVectorType(LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts)
Create debugging information entry for a vector type.
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.
unsigned LLVMDILocationGetColumn(LLVMMetadataRef Location)
Get the column number of this debug location.
LLVMDIFlags
Debug info flags.
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.
LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef Ctx, LLVMMetadataRef *Data, size_t NumElements)
Create a new temporary MDNode.
LLVMDIFlags LLVMDITypeGetFlags(LLVMMetadataRef DType)
Get the flags associated with this DIType.
const char * LLVMDIFileGetDirectory(LLVMMetadataRef File, unsigned *Len)
Get the directory of a given file.
void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef TempTargetMetadata, LLVMMetadataRef Replacement)
Replace all uses of temporary metadata.
const char * LLVMDIFileGetFilename(LLVMMetadataRef File, unsigned *Len)
Get the name of a given file.
unsigned LLVMDebugMetadataVersion(void)
The current debug metadata version number.
unsigned LLVMGetModuleDebugMetadataVersion(LLVMModuleRef Module)
The version of debug metadata that's present in the provided Module.
unsigned LLVMDITypeGetLine(LLVMMetadataRef DType)
Get the source line where this DIType is declared.
LLVMMetadataRef LLVMDIVariableGetFile(LLVMMetadataRef Var)
Get the metadata of the file associated with a given variable.
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.
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.
uint16_t LLVMGetDINodeTag(LLVMMetadataRef MD)
Get the dwarf::Tag of a DINode.
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.
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.
LLVMMetadataRef LLVMDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type)
Create debugging information entry for a qualified type, e.g.
LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata)
Obtain the enumerated type of a Metadata instance.
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.
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.
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.
LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder, LLVMMetadataRef File, LLVMMetadataRef *ParameterTypes, unsigned NumParameterTypes, LLVMDIFlags Flags)
Create subroutine type.
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.
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.
LLVMDWARFEmissionKind
The amount of debug information to emit.
LLVMMetadataRef LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts)
Create debugging information entry for an array.
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
LLVMMetadataRef LLVMDIScopeGetFile(LLVMMetadataRef Scope)
Get the metadata of the file associated with a given scope.
void LLVMDIBuilderFinalizeSubprogram(LLVMDIBuilderRef Builder, LLVMMetadataRef Subprogram)
Finalize a specific subprogram.
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...
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.
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.
unsigned LLVMDILocationGetLine(LLVMMetadataRef Location)
Get the line number of this debug location.
LLVMMetadataRef LLVMDIBuilderCreateNullPtrType(LLVMDIBuilderRef Builder)
Create C++11 nullptr type.
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.
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...
LLVMBool LLVMStripModuleDebugInfo(LLVMModuleRef Module)
Strip debug info in the module if it exists.
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
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.
unsigned LLVMDIVariableGetLine(LLVMMetadataRef Var)
Get the source line where this DIVariable is declared.
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr)
Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
unsigned LLVMDWARFTypeEncoding
An LLVM DWARF type encoding.
LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock(LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned Column)
Create a descriptor for a lexical block with the specified parent context.
LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder, LLVMMetadataRef *Data, size_t NumElements)
Create a type array.
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.
const char * LLVMDIFileGetSource(LLVMMetadataRef File, unsigned *Len)
Get the source of a given file.
uint64_t LLVMDITypeGetOffsetInBits(LLVMMetadataRef DType)
Get the offset of this DIType in bits.
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.
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.
const char * LLVMDITypeGetName(LLVMMetadataRef DType, size_t *Length)
Get the name of this DIType.
unsigned LLVMMetadataKind
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.
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.
void LLVMDisposeDIBuilder(LLVMDIBuilderRef Builder)
Deallocates the DIBuilder and everything it owns.
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.
LLVMMetadataRef LLVMGetSubprogram(LLVMValueRef Func)
Get the metadata of the subprogram attached to a function.
@ 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).
void deleteAll(Function *F)
Remove all Assignment Tracking related intrinsics and metadata from F.
AssignmentInstRange getAssignmentInsts(DIAssignID *ID)
Return a range of instructions (typically just one) that have ID as an attachment.
AssignmentMarkerRange getAssignmentMarkers(DIAssignID *ID)
Return a range of dbg.assign intrinsics which use \ID as an operand.
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.
void remapAssignID(DenseMap< DIAssignID *, DIAssignID * > &Map, Instruction &I)
Replace DIAssignID uses and attachments with IDs from Map.
SmallVector< DbgVariableRecord * > getDVRAssignmentMarkers(const Instruction *Inst)
void deleteAssignmentMarkers(const Instruction *Inst)
Delete the llvm.dbg.assign intrinsics linked to Inst.
std::optional< AssignmentInfo > getAssignmentInfo(const DataLayout &DL, const MemIntrinsic *I)
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...
void RAUW(DIAssignID *Old, DIAssignID *New)
Replace all uses (and attachments) of Old with New.
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.
TinyPtrVector< DbgDeclareInst * > findDbgDeclares(Value *V)
Finds dbg.declare intrinsics declaring local variables as living in the memory that 'V' points to.
bool stripDebugInfo(Function &F)
void findDbgUsers(SmallVectorImpl< DbgVariableIntrinsic * > &DbgInsts, Value *V, SmallVectorImpl< DbgVariableRecord * > *DbgVariableRecords=nullptr)
Finds the debug info intrinsics describing a value.
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...
void findDbgValues(SmallVectorImpl< DbgValueInst * > &DbgValues, Value *V, SmallVectorImpl< DbgVariableRecord * > *DbgVariableRecords=nullptr)
Finds the llvm.dbg.value intrinsics describing a value.
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)
bool stripNonLineTableDebugInfo(Module &M)
Downgrade the debug info in a module to contain only line table information.
DebugLoc getDebugValueLoc(DbgVariableIntrinsic *DII)
Produce a DebugLoc to use for each dbg.declare that is promoted to a dbg.value.
unsigned getDebugMetadataVersionFromModule(const Module &M)
Return Debug Info Metadata Version by checking module flags.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
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)
bool isAssignmentTrackingEnabled(const Module &M)
Return true if assignment tracking is enabled for module M.
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)
TinyPtrVector< DbgVariableRecord * > findDVRDeclares(Value *V)
As above, for DVRDeclares.
static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DbgVariableRecord types only and downcast.
void updateLoopMetadataDebugLocations(Instruction &I, function_ref< Metadata *(Metadata *)> Updater)
Update the debug locations contained within the MD_loop metadata attached to the instruction I,...
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.