aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorPaul Robinson <paul.robinson@sony.com>2023-08-18 07:33:27 -0700
committerPaul Robinson <paul.robinson@sony.com>2023-08-18 09:20:42 -0700
commit1fcc2bc31bb9352a13445ff4a5cccb0bebb8ea5b (patch)
tree3b4d3f061cd2abc099af6bc7b581e26ce033ccf6 /clang/lib
parent1c66d08b0137cef7761b8220d3b7cb7833f57cdb (diff)
downloadllvm-1fcc2bc31bb9352a13445ff4a5cccb0bebb8ea5b.zip
llvm-1fcc2bc31bb9352a13445ff4a5cccb0bebb8ea5b.tar.gz
llvm-1fcc2bc31bb9352a13445ff4a5cccb0bebb8ea5b.tar.bz2
Reapply "[DebugInfo] Alternate (more efficient) MD5 fix"
D155991 changed the file lookup to do a full string compare on the filename; however, this added ~0.5% to compile time with -g. Go back to the previous pointer-based lookup, but capture the main file's checksum as well as its name to use when creating the extra DIFile entry. This causes all entries to be consistent and also avoids computing the checksum twice. This reverts commit 5956648fc3ba11dd6b0d0f2d1d9b923e7f80f247. There was a string lifetime issue that is now corrected. Differential Revision: https://reviews.llvm.org/D156571
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp13
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 54e31be..36e2928 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -391,12 +391,14 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
SourceManager &SM = CGM.getContext().getSourceManager();
StringRef FileName;
FileID FID;
+ std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
if (Loc.isInvalid()) {
// The DIFile used by the CU is distinct from the main source file. Call
// createFile() below for canonicalization if the source file was specified
// with an absolute path.
FileName = TheCU->getFile()->getFilename();
+ CSInfo = TheCU->getFile()->getChecksum();
} else {
PresumedLoc PLoc = SM.getPresumedLoc(Loc);
FileName = PLoc.getFilename();
@@ -417,13 +419,14 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
return cast<llvm::DIFile>(V);
}
+ // Put Checksum at a scope where it will persist past the createFile call.
SmallString<64> Checksum;
-
- std::optional<llvm::DIFile::ChecksumKind> CSKind =
+ if (!CSInfo) {
+ std::optional<llvm::DIFile::ChecksumKind> CSKind =
computeChecksum(FID, Checksum);
- std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
- if (CSKind)
- CSInfo.emplace(*CSKind, Checksum);
+ if (CSKind)
+ CSInfo.emplace(*CSKind, Checksum);
+ }
return createFile(FileName, CSInfo, getSource(SM, SM.getFileID(Loc)));
}
diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index ec84379..b47a493 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -148,7 +148,7 @@ class CGDebugInfo {
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