[llvm] [InlineCost] Use a const reference (NFC) (PR #95687)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 15 20:19:44 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
The use of a const reference here saves 0.18% of heap allocations
during the compilation of a large preprocessed file, namely
X86ISelLowering.cpp, for the X86 target.
Note that GetTLI returns a const reference, so we don't have to worry
about a dangling reference.
---
Full diff: https://github.com/llvm/llvm-project/pull/95687.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/InlineCost.cpp (+1-1)
``````````diff
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index f5b17dca49735..c3aeac7492804 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -2887,7 +2887,7 @@ static bool functionsHaveCompatibleAttributes(
// caches the most recently created TLI in the TargetLibraryInfoWrapperPass
// object, and always returns the same object (which is overwritten on each
// GetTLI call). Therefore we copy the first result.
- auto CalleeTLI = GetTLI(*Callee);
+ const auto &CalleeTLI = GetTLI(*Callee);
return (IgnoreTTIInlineCompatible ||
TTI.areInlineCompatible(Caller, Callee)) &&
GetTLI(*Caller).areInlineCompatible(CalleeTLI,
``````````
</details>
https://github.com/llvm/llvm-project/pull/95687
More information about the llvm-commits
mailing list