Skip to content

Commit 4ce6542

Browse files
[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.
1 parent f06f016 commit 4ce6542

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/ProfileData/InstrProfReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ IndexedMemProfReader::getMemProfRecord(const uint64_t FuncNameHash) const {
16131613
instrprof_error::unknown_function,
16141614
"memprof record not found for function hash " + Twine(FuncNameHash));
16151615

1616-
const memprof::IndexedMemProfRecord IndexedRecord = *Iter;
1616+
const memprof::IndexedMemProfRecord &IndexedRecord = *Iter;
16171617
switch (Version) {
16181618
case memprof::Version0:
16191619
case memprof::Version1:

0 commit comments

Comments
 (0)