summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-11-24 18:15:46 +0000
committerXinliang David Li <davidxl@google.com>2015-11-24 18:15:46 +0000
commit759dc628c0aa44960d5327dd7e5171e22117b944 (patch)
tree34c2ad8defc1fc7e846b16861843bcd6b3fb5d62
parent3868a72d4c97b91a2ddc2895e02854da7fde7682 (diff)
downloadbcm5719-llvm-759dc628c0aa44960d5327dd7e5171e22117b944.tar.gz
bcm5719-llvm-759dc628c0aa44960d5327dd7e5171e22117b944.zip
[PGO] Small interface change to be profile rt ready
Convert two C++ static member functions to be C APIs. This is one of the many steps to get ready to share VP writer code with profiler runtime. llvm-svn: 253999
-rw-r--r--llvm/include/llvm/ProfileData/InstrProf.h39
-rw-r--r--llvm/lib/ProfileData/InstrProf.cpp20
2 files changed, 31 insertions, 28 deletions
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index 872cc764bc0..5ec7d65773c 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -83,7 +83,7 @@ inline StringRef getInstrProfCountersVarPrefix() {
/// associated with a COMDAT function.
inline StringRef getInstrProfComdatPrefix() { return "__llvm_profile_vars_"; }
-/// Return the name of a covarage mapping variable (internal linkage)
+/// Return the name of a covarage mapping variable (internal linkage)
/// for each instrumented source module. Such variables are allocated
/// in the __llvm_covmap section.
inline StringRef getCoverageMappingVarName() {
@@ -440,9 +440,15 @@ inline support::endianness getHostEndianness() {
return sys::IsLittleEndianHost ? support::little : support::big;
}
+/// Return the \c ValueProfRecord header size including the padding bytes.
+uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites);
+/// Return the total size of the value profile record including the
+/// header and the value data.
+uint32_t getValueProfRecordSize(uint32_t NumValueSites, uint32_t NumValueData);
+
/// This is the header of the data structure that defines the on-disk
/// layout of the value profile data of a particular kind for one function.
-struct ValueProfRecord {
+typedef struct ValueProfRecord {
// The kind of the value profile record.
uint32_t Kind;
// The number of value profile sites. It is guaranteed to be non-zero;
@@ -462,14 +468,11 @@ struct ValueProfRecord {
// of all elements in SiteCountArray[].
// InstrProfValueData ValueData[];
- /// Return the \c ValueProfRecord header size including the padding bytes.
- static uint32_t getHeaderSize(uint32_t NumValueSites);
- /// Return the total size of the value profile record including the
- /// header and the value data.
- static uint32_t getSize(uint32_t NumValueSites, uint32_t NumValueData);
/// Return the total size of the value profile record including the
/// header and the value data.
- uint32_t getSize() const { return getSize(NumValueSites, getNumValueData()); }
+ uint32_t getSize() const {
+ return getValueProfRecordSize(NumValueSites, getNumValueData());
+ }
/// Use this method to advance to the next \c ValueProfRecord.
ValueProfRecord *getNext();
/// Return the pointer to the first value profile data.
@@ -488,11 +491,11 @@ struct ValueProfRecord {
/// Do byte swap for this instance. \c Old is the original order before
/// the swap, and \c New is the New byte order.
void swapBytes(support::endianness Old, support::endianness New);
-};
+} ValueProfRecord;
/// Per-function header/control data structure for value profiling
/// data in indexed format.
-struct ValueProfData {
+typedef struct ValueProfData {
// Total size in bytes including this field. It must be a multiple
// of sizeof(uint64_t).
uint32_t TotalSize;
@@ -533,7 +536,21 @@ struct ValueProfData {
InstrProfRecord::ValueMapType *VMap);
/// Return the first \c ValueProfRecord instance.
ValueProfRecord *getFirstValueProfRecord();
-};
+} ValueProfData;
+
+inline uint32_t getValueProfRecordHeaderSize(uint32_t NumValueSites) {
+ uint32_t Size = offsetof(ValueProfRecord, SiteCountArray) +
+ sizeof(uint8_t) * NumValueSites;
+ // Round the size to multiple of 8 bytes.
+ Size = (Size + 7) & ~7;
+ return Size;
+}
+
+inline uint32_t getValueProfRecordSize(uint32_t NumValueSites,
+ uint32_t NumValueData) {
+ return getValueProfRecordHeaderSize(NumValueSites) +
+ sizeof(InstrProfValueData) * NumValueData;
+}
namespace IndexedInstrProf {
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index b670902f3f9..256a98f3650 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -131,20 +131,6 @@ GlobalVariable *createPGOFuncNameVar(Function &F, StringRef FuncName) {
return createPGOFuncNameVar(*F.getParent(), F.getLinkage(), FuncName);
}
-uint32_t ValueProfRecord::getHeaderSize(uint32_t NumValueSites) {
- uint32_t Size = offsetof(ValueProfRecord, SiteCountArray) +
- sizeof(uint8_t) * NumValueSites;
- // Round the size to multiple of 8 bytes.
- Size = (Size + 7) & ~7;
- return Size;
-}
-
-uint32_t ValueProfRecord::getSize(uint32_t NumValueSites,
- uint32_t NumValueData) {
- return getHeaderSize(NumValueSites) +
- sizeof(InstrProfValueData) * NumValueData;
-}
-
void ValueProfRecord::deserializeTo(InstrProfRecord &Record,
InstrProfRecord::ValueMapType *VMap) {
Record.reserveSites(Kind, NumValueSites);
@@ -228,7 +214,7 @@ uint32_t ValueProfData::getSize(const InstrProfRecord &Record) {
if (!NumValueSites)
continue;
TotalSize +=
- ValueProfRecord::getSize(NumValueSites, Record.getNumValueData(Kind));
+ getValueProfRecordSize(NumValueSites, Record.getNumValueData(Kind));
}
return TotalSize;
}
@@ -355,7 +341,7 @@ ValueProfRecord *ValueProfRecord::getNext() {
}
InstrProfValueData *ValueProfRecord::getValueData() {
- return reinterpret_cast<InstrProfValueData *>((char *)this +
- getHeaderSize(NumValueSites));
+ return reinterpret_cast<InstrProfValueData *>(
+ (char *)this + getValueProfRecordHeaderSize(NumValueSites));
}
}
OpenPOWER on IntegriCloud