[llvm] 4ce6542 - [memprof] Use const ref for IndexedRecord (#94114)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 2 13:30:36 PDT 2024
Author: Kazu Hirata
Date: 2024-06-02T13:30:32-07:00
New Revision: 4ce65423be0ba1d90c11b6a79981d6314e1cf36d
URL: https://github.com/llvm/llvm-project/commit/4ce65423be0ba1d90c11b6a79981d6314e1cf36d
DIFF: https://github.com/llvm/llvm-project/commit/4ce65423be0ba1d90c11b6a79981d6314e1cf36d.diff
LOG: [memprof] Use const ref for IndexedRecord (#94114)
The type of *Iter here is "const IndexedMemProfRecord &" as defined in
RecordLookupTrait. Assigning *Iter to a variable of type
"const IndexedMemProfRecord &" avoids a copy, reducing the cycle and
instruction counts by 1.8% and 0.2%, respectively, with
"llvm-profdata show" modified to deserialize all MemProfRecords.
Note that RecordLookupTrait has an internal copy of
IndexedMemProfRecord, so we don't have to worry about a dangling
reference to a temporary.
Added:
Modified:
llvm/lib/ProfileData/InstrProfReader.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 1e66716294689..8298d3d372951 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -1613,7 +1613,7 @@ IndexedMemProfReader::getMemProfRecord(const uint64_t FuncNameHash) const {
instrprof_error::unknown_function,
"memprof record not found for function hash " + Twine(FuncNameHash));
- const memprof::IndexedMemProfRecord IndexedRecord = *Iter;
+ const memprof::IndexedMemProfRecord &IndexedRecord = *Iter;
switch (Version) {
case memprof::Version0:
case memprof::Version1:
More information about the llvm-commits
mailing list