[llvm] r253994 - Minor refactor to make VP writing more efficient
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 24 09:03:24 PST 2015
Author: davidxl
Date: Tue Nov 24 11:03:24 2015
New Revision: 253994
URL: http://llvm.org/viewvc/llvm-project?rev=253994&view=rev
Log:
Minor refactor to make VP writing more efficient
Modified:
llvm/trunk/include/llvm/ProfileData/InstrProf.h
llvm/trunk/lib/ProfileData/InstrProf.cpp
Modified: llvm/trunk/include/llvm/ProfileData/InstrProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=253994&r1=253993&r2=253994&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Tue Nov 24 11:03:24 2015
@@ -259,8 +259,11 @@ struct InstrProfRecord {
/// site: Site.
inline uint32_t getNumValueDataForSite(uint32_t ValueKind,
uint32_t Site) const;
+ /// Return the array of profiled values at \p Site.
inline std::unique_ptr<InstrProfValueData[]>
getValueForSite(uint32_t ValueKind, uint32_t Site) const;
+ inline void getValueForSite(InstrProfValueData Dest[], uint32_t ValueKind,
+ uint32_t Site) const;
/// Reserve space for NumValueSites sites.
inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites);
/// Add ValueData for ValueKind at value Site.
@@ -369,14 +372,17 @@ InstrProfRecord::getValueForSite(uint32_
return std::unique_ptr<InstrProfValueData[]>(nullptr);
auto VD = llvm::make_unique<InstrProfValueData[]>(N);
+ getValueForSite(VD.get(), ValueKind, Site);
+
+ return VD;
+}
+void InstrProfRecord::getValueForSite(InstrProfValueData Dest[],
+ uint32_t ValueKind, uint32_t Site) const {
uint32_t I = 0;
for (auto V : getValueSitesForKind(ValueKind)[Site].ValueData) {
- VD[I] = V;
+ Dest[I] = V;
I++;
}
- assert(I == N);
-
- return VD;
}
void InstrProfRecord::addValueData(uint32_t ValueKind, uint32_t Site,
Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=253994&r1=253993&r2=253994&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProf.cpp Tue Nov 24 11:03:24 2015
@@ -166,10 +166,8 @@ void ValueProfRecord::serializeFrom(cons
for (uint32_t S = 0; S < NumValueSites; S++) {
uint32_t ND = Record.getNumValueDataForSite(ValueKind, S);
SiteCountArray[S] = ND;
- std::unique_ptr<InstrProfValueData[]> SrcVD =
- Record.getValueForSite(ValueKind, S);
+ Record.getValueForSite(DstVD, ValueKind, S);
for (uint32_t I = 0; I < ND; I++) {
- DstVD[I] = SrcVD[I];
switch (ValueKind) {
case IPVK_IndirectCallTarget:
DstVD[I].Value = IndexedInstrProf::ComputeHash(
More information about the llvm-commits
mailing list