diff options
| author | Paul Robinson <paul.robinson@sony.com> | 2023-08-18 05:21:23 -0700 |
|---|---|---|
| committer | Paul Robinson <paul.robinson@sony.com> | 2023-08-18 05:24:00 -0700 |
| commit | 2e4d2d800b9ce0924513a2f24e7a1f3d22b52383 (patch) | |
| tree | e354629ce32d33cb91aaa4749944f866a936658d /clang/lib/CodeGen/CGDebugInfo.cpp | |
| parent | d158ee576ba665840e8f55b743b78ce93d57e7dd (diff) | |
| download | llvm-2e4d2d800b9ce0924513a2f24e7a1f3d22b52383.zip llvm-2e4d2d800b9ce0924513a2f24e7a1f3d22b52383.tar.gz llvm-2e4d2d800b9ce0924513a2f24e7a1f3d22b52383.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 21e7f73494663814e0296066895dfacdebfac6d4.
I'm unable to find a reason for the memory management issues
that caused the revert, so trying again.
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 54e31be..e782b7f 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,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) { return cast<llvm::DIFile>(V); } - SmallString<64> Checksum; - - std::optional<llvm::DIFile::ChecksumKind> CSKind = + if (!CSInfo) { + SmallString<64> Checksum; + 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))); } |
