Skip to content

Commit

Permalink
[memprof] Use const ref for IndexedRecord (#94114)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kazutakahirata authored Jun 2, 2024
1 parent f06f016 commit 4ce6542
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/ProfileData/InstrProfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4ce6542

Please sign in to comment.