[llvm] [InlineCost] Use a const reference (NFC) (PR #95687)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 15 20:19:17 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/95687
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.
>From c2d7b0b57eac367c24d8f09189c35aed43f9f2f5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 21 Jan 2024 20:08:44 -0800
Subject: [PATCH] [InlineCost] Use a const reference (NFC)
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.
---
llvm/lib/Analysis/InlineCost.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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,
More information about the llvm-commits
mailing list