[PATCH] D156571: [DebugInfo] Alternate MD5 fix, NFC
Paul Robinson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 28 13:23:42 PDT 2023
probinson created this revision.
probinson added reviewers: dblaikie, nikic.
probinson added a project: debug-info.
Herald added a subscriber: StephenFan.
Herald added a project: All.
probinson requested review of this revision.
Should have lower memory and time cost than D155991 <https://reviews.llvm.org/D155991>.
https://reviews.llvm.org/D156571
Files:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
Index: clang/lib/CodeGen/CGDebugInfo.h
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -148,7 +148,7 @@
llvm::BumpPtrAllocator DebugInfoNames;
StringRef CWDName;
- llvm::StringMap<llvm::TrackingMDRef> DIFileCache;
+ llvm::DenseMap<const char *, llvm::TrackingMDRef> DIFileCache;
llvm::DenseMap<const FunctionDecl *, llvm::TrackingMDRef> SPCache;
/// Cache declarations relevant to DW_TAG_imported_declarations (C++
/// using declarations and global alias variables) that aren't covered
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -397,6 +397,17 @@
// createFile() below for canonicalization if the source file was specified
// with an absolute path.
FileName = TheCU->getFile()->getFilename();
+ for (auto It : DIFileCache) {
+ // StringRef operator== does a content comparison.
+ if (FileName == It.first) {
+ // Got a string match, use the existing DIFile if possible.
+ if (llvm::Metadata *V = It.second)
+ return cast<llvm::DIFile>(V);
+ // Fall through to create the DIFile but use the original string.
+ FileName = It.first;
+ break;
+ }
+ }
} else {
PresumedLoc PLoc = SM.getPresumedLoc(Loc);
FileName = PLoc.getFilename();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156571.545257.patch
Type: text/x-patch
Size: 1482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230728/2e4ce33e/attachment.bin>
More information about the cfe-commits
mailing list