summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-11-24 23:36:52 +0000
committerXinliang David Li <davidxl@google.com>2015-11-24 23:36:52 +0000
commit28b700373e158ac53cdcd3026b2781d96f130625 (patch)
treefac412e50aa4e8042ef21019f78c6d5d87623ad6 /llvm/lib/ProfileData
parent933626229bd6fe8215fdb7414c1991e2d25ef8ca (diff)
downloadbcm5719-llvm-28b700373e158ac53cdcd3026b2781d96f130625.tar.gz
bcm5719-llvm-28b700373e158ac53cdcd3026b2781d96f130625.zip
[PGO] Add mapper callback to interfaces retrieving value data for site (NFC)
This allows cleaner implementation and merging retrieving/mapping in one pass. llvm-svn: 254038
Diffstat (limited to 'llvm/lib/ProfileData')
-rw-r--r--llvm/lib/ProfileData/InstrProf.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 256a98f3650..1d2896c8583 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -131,6 +131,18 @@ GlobalVariable *createPGOFuncNameVar(Function &F, StringRef FuncName) {
return createPGOFuncNameVar(*F.getParent(), F.getLinkage(), FuncName);
}
+uint64_t StringToHash(uint32_t ValueKind, uint64_t Value) {
+ switch (ValueKind) {
+ case IPVK_IndirectCallTarget:
+ return IndexedInstrProf::ComputeHash(IndexedInstrProf::HashType,
+ (const char *)Value);
+ break;
+ default:
+ llvm_unreachable("value kind not handled !");
+ }
+ return Value;
+}
+
void ValueProfRecord::deserializeTo(InstrProfRecord &Record,
InstrProfRecord::ValueMapType *VMap) {
Record.reserveSites(Kind, NumValueSites);
@@ -152,17 +164,7 @@ void ValueProfRecord::serializeFrom(const InstrProfRecord &Record,
for (uint32_t S = 0; S < NumValueSites; S++) {
uint32_t ND = Record.getNumValueDataForSite(ValueKind, S);
SiteCountArray[S] = ND;
- Record.getValueForSite(DstVD, ValueKind, S);
- for (uint32_t I = 0; I < ND; I++) {
- switch (ValueKind) {
- case IPVK_IndirectCallTarget:
- DstVD[I].Value = IndexedInstrProf::ComputeHash(
- IndexedInstrProf::HashType, (const char *)DstVD[I].Value);
- break;
- default:
- llvm_unreachable("value kind not handled !");
- }
- }
+ Record.getValueForSite(DstVD, ValueKind, S, StringToHash);
DstVD += ND;
}
}
OpenPOWER on IntegriCloud