llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Anonmiraj (AnonMiraj)

<details>
<summary>Changes</summary>

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&amp;to=a62389e40c98a33e23395ea69c4dc495d8aec263&amp;stat=instructions%3Au


---
Full diff: https://github.com/llvm/llvm-project/pull/228926.diff


1 Files Affected:

- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+3) 


``````````diff
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);

``````````

</details>


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

Reply via email to