Author: Anonmiraj
Date: 2026-10-31T14:23:20-07:00
New Revision: 248281451c6abfac7cb565999d9b170cfdf1eea4

URL: 
https://github.com/llvm/llvm-project/commit/248281451c6abfac7cb565999d9b170cfdf1eea4
DIFF: 
https://github.com/llvm/llvm-project/commit/248281451c6abfac7cb565999d9b170cfdf1eea4.diff

LOG: [clang] Hash the main file only once for DWARF 5 checksums (#228926)

While looking for things that already has a cached result, I noticed
that the main file's DWARF 5 checksum is computed twice: once in
`CreateCompileUnit` and again in the first `getOrCreateFile()`, even
though the CU already has it.

It's a nice small win on debug builds (−0.72% on sqlite3, −0.17%
geomean) and it shouldn't change any behaviour:


https://llvm-compile-time-tracker.com/compare.php?from=018a46162a84070109760677031bcd636ed6026e&to=a62389e40c98a33e23395ea69c4dc495d8aec263&stat=instructions%3Au

Added: 
    

Modified: 
    clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index f1dec38668af0..436a949891793 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -613,6 +613,9 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation 
Loc) {
 
   // Put Checksum at a scope where it will persist past the createFile call.
   SmallString<64> Checksum;
+  // Reuse the checksum CreateCompileUnit already computed for the main file.
+  if (!CSInfo && FID == SM.getMainFileID() && TheCU)
+    CSInfo = TheCU->getFile()->getChecksum();
   if (!CSInfo) {
     std::optional<llvm::DIFile::ChecksumKind> CSKind =
       computeChecksum(FID, Checksum);


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to