diff options
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 9601a8a..5883606 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -294,9 +294,9 @@ void DebugInfoFinder::processSubprogram(DISubprogram *SP) { // just DISubprogram's, referenced from anywhere within the Function being // cloned prior to calling MapMetadata / RemapInstruction to avoid their // duplication later as DICompileUnit's are also directly referenced by - // llvm.dbg.cu list. Thefore we need to collect DICompileUnit's here as well. - // Also, DICompileUnit's may reference DISubprogram's too and therefore need - // to be at least looked through. + // llvm.dbg.cu list. Therefore we need to collect DICompileUnit's here as + // well. Also, DICompileUnit's may reference DISubprogram's too and therefore + // need to be at least looked through. processCompileUnit(SP->getUnit()); processType(SP->getType()); for (auto *Element : SP->getTemplateParams()) { @@ -377,7 +377,7 @@ bool DebugInfoFinder::addScope(DIScope *Scope) { /// Recursively handle DILocations in followup metadata etc. /// -/// TODO: If for example a followup loop metadata would refence itself this +/// TODO: If for example a followup loop metadata would reference itself this /// function would go into infinite recursion. We do not expect such cycles in /// the loop metadata (except for the self-referencing first element /// "LoopID"). However, we could at least handle such situations more gracefully @@ -679,7 +679,7 @@ private: auto Variables = nullptr; auto TemplateParams = nullptr; - // Make a distinct DISubprogram, for situations that warrent it. + // Make a distinct DISubprogram, for situations that warrant it. auto distinctMDSubprogram = [&]() { return DISubprogram::getDistinct( MDS->getContext(), FileAndScope, MDS->getName(), LinkageName, @@ -1095,6 +1095,35 @@ LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const char *Filename, StringRef(Directory, DirectoryLen))); } +static llvm::DIFile::ChecksumKind +map_from_llvmChecksumKind(LLVMChecksumKind CSKind) { + switch (CSKind) { + case LLVMChecksumKind::CSK_MD5: + return llvm::DIFile::CSK_MD5; + case LLVMChecksumKind::CSK_SHA1: + return llvm::DIFile::CSK_SHA1; + case LLVMChecksumKind::CSK_SHA256: + return llvm::DIFile::CSK_SHA256; + } + llvm_unreachable("Unhandled Checksum Kind"); +} + +LLVMMetadataRef LLVMDIBuilderCreateFileWithChecksum( + LLVMDIBuilderRef Builder, const char *Filename, size_t FilenameLen, + const char *Directory, size_t DirectoryLen, LLVMChecksumKind ChecksumKind, + const char *Checksum, size_t ChecksumLen, const char *Source, + size_t SourceLen) { + StringRef ChkSum = StringRef(Checksum, ChecksumLen); + auto CSK = map_from_llvmChecksumKind(ChecksumKind); + llvm::DIFile::ChecksumInfo<StringRef> CSInfo(CSK, ChkSum); + std::optional<StringRef> Src; + if (SourceLen > 0) + Src = StringRef(Source, SourceLen); + return wrap(unwrap(Builder)->createFile(StringRef(Filename, FilenameLen), + StringRef(Directory, DirectoryLen), + CSInfo, Src)); +} + LLVMMetadataRef LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope, const char *Name, size_t NameLen, @@ -2014,7 +2043,7 @@ void at::remapAssignID(DenseMap<DIAssignID *, DIAssignID *> &Map, I.setMetadata(LLVMContext::MD_DIAssignID, GetNewID(ID)); } -/// Collect constant properies (base, size, offset) of \p StoreDest. +/// Collect constant properties (base, size, offset) of \p StoreDest. /// Return std::nullopt if any properties are not constants or the /// offset from the base pointer is negative. static std::optional<AssignmentInfo> @@ -2300,7 +2329,7 @@ PreservedAnalyses AssignmentTrackingPass::run(Function &F, return PreservedAnalyses::all(); // Record that this module uses assignment tracking. It doesn't matter that - // some functons in the module may not use it - the debug info in those + // some functions in the module may not use it - the debug info in those // functions will still be handled properly. setAssignmentTrackingModuleFlag(*F.getParent()); |