[llvm] r307113 - [profiledata] Avoid creating a temporary vector in getNumValueData
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 4 18:20:52 PDT 2017
Author: alexshap
Date: Tue Jul 4 18:20:52 2017
New Revision: 307113
URL: http://llvm.org/viewvc/llvm-project?rev=307113&view=rev
Log:
[profiledata] Avoid creating a temporary vector in getNumValueData
getValueSitesForKind returns ArrayRef which has a cast operator
to std::vector, as a result a temporary vector is created
if the type of the variable is const std::vector&
that is suboptimal in this case.
Differential revision: https://reviews.llvm.org/D34970
Test plan: make check-all
Modified:
llvm/trunk/include/llvm/ProfileData/InstrProf.h
Modified: llvm/trunk/include/llvm/ProfileData/InstrProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=307113&r1=307112&r2=307113&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Tue Jul 4 18:20:52 2017
@@ -753,11 +753,8 @@ uint32_t InstrProfRecord::getNumValueKin
uint32_t InstrProfRecord::getNumValueData(uint32_t ValueKind) const {
uint32_t N = 0;
- const std::vector<InstrProfValueSiteRecord> &SiteRecords =
- getValueSitesForKind(ValueKind);
- for (auto &SR : SiteRecords) {
+ for (auto &SR : getValueSitesForKind(ValueKind))
N += SR.ValueData.size();
- }
return N;
}
More information about the llvm-commits
mailing list