https://github.com/AnonMiraj created https://github.com/llvm/llvm-project/pull/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 >From a62389e40c98a33e23395ea69c4dc495d8aec263 Mon Sep 17 00:00:00 2001 From: Anonmiraj <[email protected]> Date: Sun, 4 Oct 2026 15:52:24 +0300 Subject: [PATCH] [clang] Hash the main file only once for DWARF 5 checksums --- clang/lib/CodeGen/CGDebugInfo.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index c63a840dedf7c..9eb902f0e7d5c 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -621,6 +621,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
