[clang] [clang] Call getOrCreateFile() just once in AddStringLiteralDebugInfo() (PR #240382)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 9 06:08:07 PST 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-debuginfo

Author: Nico Weber (nico)

<details>
<summary>Changes</summary>

getOrCreateFile(Loc) is stored in a variable `File` 3 lines up,
so use that variable instead of calling the function again.

Mostly for code cleanliness, but for usb_ids_gen.cc (from #<!-- -->229808)
this is also a small (0.4%) reduction in retired instructions.

No behavior change.

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


1 Files Affected:

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


``````````diff
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 63cf4110d9d0a..3aa7eccb433cc 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -6619,8 +6619,8 @@ void CGDebugInfo::AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
   llvm::DIFile *File = getOrCreateFile(Loc);
   llvm::DIGlobalVariableExpression *Debug =
       DBuilder.createGlobalVariableExpression(
-          nullptr, StringRef(), StringRef(), getOrCreateFile(Loc),
-          getLineNumber(Loc), getOrCreateType(S->getType(), File), true);
+          nullptr, StringRef(), StringRef(), File, getLineNumber(Loc),
+          getOrCreateType(S->getType(), File), true);
   GV->addDebugInfo(Debug);
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/240382


More information about the cfe-commits mailing list