Code style fix (caused by wrongly default clang-format style) (NFC)

llvm-svn: 252276
This commit is contained in:
Xinliang David Li 2015-11-06 07:54:21 +00:00
parent 191780e941
commit ce5e3364a9
3 changed files with 42 additions and 33 deletions

View File

@ -191,7 +191,8 @@ struct InstrProfValueSiteRecord {
auto IE = ValueData.end();
for (auto J = Input.ValueData.begin(), JE = Input.ValueData.end(); J != JE;
++J) {
while (I != IE && I->Value < J->Value) ++I;
while (I != IE && I->Value < J->Value)
++I;
if (I != IE && I->Value == J->Value) {
I->Count += J->Count;
++I;
@ -224,8 +225,8 @@ struct InstrProfRecord {
/// site: Site.
inline uint32_t getNumValueDataForSite(uint32_t ValueKind,
uint32_t Site) const;
inline std::unique_ptr<InstrProfValueData[]> getValueForSite(
uint32_t ValueKind, uint32_t Site) const;
inline std::unique_ptr<InstrProfValueData[]>
getValueForSite(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.
@ -240,7 +241,7 @@ struct InstrProfRecord {
/// the writer instance.
inline void updateStrings(InstrProfStringTable *StrTab);
private:
private:
std::vector<InstrProfValueSiteRecord> IndirectCallSites;
const std::vector<InstrProfValueSiteRecord> &
getValueSitesForKind(uint32_t ValueKind) const {
@ -262,18 +263,19 @@ struct InstrProfRecord {
// Map indirect call target name hash to name string.
uint64_t remapValue(uint64_t Value, uint32_t ValueKind,
ValueMapType *HashKeys) {
if (!HashKeys) return Value;
if (!HashKeys)
return Value;
switch (ValueKind) {
case IPVK_IndirectCallTarget: {
auto Result =
std::lower_bound(HashKeys->begin(), HashKeys->end(), Value,
[](const std::pair<uint64_t, const char *> &LHS,
uint64_t RHS) { return LHS.first < RHS; });
assert(Result != HashKeys->end() &&
"Hash does not match any known keys\n");
Value = (uint64_t)Result->second;
break;
}
case IPVK_IndirectCallTarget: {
auto Result =
std::lower_bound(HashKeys->begin(), HashKeys->end(), Value,
[](const std::pair<uint64_t, const char *> &LHS,
uint64_t RHS) { return LHS.first < RHS; });
assert(Result != HashKeys->end() &&
"Hash does not match any known keys\n");
Value = (uint64_t)Result->second;
break;
}
}
return Value;
}
@ -295,10 +297,11 @@ uint32_t InstrProfRecord::getNumValueDataForSite(uint32_t ValueKind,
return getValueSitesForKind(ValueKind)[Site].ValueData.size();
}
std::unique_ptr<InstrProfValueData[]> InstrProfRecord::getValueForSite(
uint32_t ValueKind, uint32_t Site) const {
std::unique_ptr<InstrProfValueData[]>
InstrProfRecord::getValueForSite(uint32_t ValueKind, uint32_t Site) const {
uint32_t N = getNumValueDataForSite(ValueKind, Site);
if (N == 0) return std::unique_ptr<InstrProfValueData[]>(nullptr);
if (N == 0)
return std::unique_ptr<InstrProfValueData[]>(nullptr);
std::unique_ptr<InstrProfValueData[]> VD(new InstrProfValueData[N]);
uint32_t I = 0;
@ -347,7 +350,8 @@ instrprof_error InstrProfRecord::mergeValueProfData(uint32_t ValueKind,
}
void InstrProfRecord::updateStrings(InstrProfStringTable *StrTab) {
if (!StrTab) return;
if (!StrTab)
return;
Name = StrTab->insertString(Name);
for (auto &VSite : IndirectCallSites)
@ -429,8 +433,7 @@ inline uint64_t getMagic<uint32_t>() {
// It should also match the synthesized type in
// Transforms/Instrumentation/InstrProfiling.cpp:getOrCreateRegionCounters.
template <class IntPtrT>
struct ProfileData {
template <class IntPtrT> struct ProfileData {
#define INSTR_PROF_DATA(Type, LLVMType, Name, Init) Type Name;
#include "llvm/ProfileData/InstrProfData.inc"
};
@ -454,8 +457,7 @@ struct Header {
namespace coverage {
LLVM_PACKED_START
template <class IntPtrT>
struct CovMapFunctionRecord {
template <class IntPtrT> struct CovMapFunctionRecord {
#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name;
#include "llvm/ProfileData/InstrProfData.inc"
};

View File

@ -483,8 +483,9 @@ std::error_code IndexedInstrProfReader::readHeader() {
return success();
}
ErrorOr<InstrProfRecord> IndexedInstrProfReader::getInstrProfRecord(
StringRef FuncName, uint64_t FuncHash) {
ErrorOr<InstrProfRecord>
IndexedInstrProfReader::getInstrProfRecord(StringRef FuncName,
uint64_t FuncHash) {
ArrayRef<InstrProfRecord> Data;
std::error_code EC = Index.getRecords(FuncName, Data);
if (EC != instrprof_error::success) return EC;
@ -498,10 +499,12 @@ ErrorOr<InstrProfRecord> IndexedInstrProfReader::getInstrProfRecord(
return error(instrprof_error::hash_mismatch);
}
std::error_code IndexedInstrProfReader::getFunctionCounts(
StringRef FuncName, uint64_t FuncHash, std::vector<uint64_t> &Counts) {
std::error_code
IndexedInstrProfReader::getFunctionCounts(StringRef FuncName, uint64_t FuncHash,
std::vector<uint64_t> &Counts) {
ErrorOr<InstrProfRecord> Record = getInstrProfRecord(FuncName, FuncHash);
if (std::error_code EC = Record.getError()) return EC;
if (std::error_code EC = Record.getError())
return EC;
Counts = Record.get().Counts;
return success();

View File

@ -54,14 +54,15 @@ public:
M += sizeof(uint64_t); // Number of value kinds with value sites.
for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind) {
uint32_t NumValueSites = ProfRecord.getNumValueSites(Kind);
if (NumValueSites == 0) continue;
if (NumValueSites == 0)
continue;
M += sizeof(uint64_t); // Value kind
M += sizeof(uint64_t); // The number of value sites for given value kind
for (uint32_t I = 0; I < NumValueSites; I++) {
M += sizeof(uint64_t); // Number of value data pairs at a value site
uint64_t NumValueDataForSite =
ProfRecord.getNumValueDataForSite(Kind, I);
M += 2 * sizeof(uint64_t) * NumValueDataForSite; // Value data pairs
M += 2 * sizeof(uint64_t) * NumValueDataForSite; // Value data pairs
}
}
}
@ -83,7 +84,8 @@ public:
LE.write<uint64_t>(ProfileData.first); // Function hash
LE.write<uint64_t>(ProfRecord.Counts.size());
for (uint64_t I : ProfRecord.Counts) LE.write<uint64_t>(I);
for (uint64_t I : ProfRecord.Counts)
LE.write<uint64_t>(I);
// Compute the number of value kinds with value sites.
uint64_t NumValueKinds = ProfRecord.getNumValueKinds();
@ -92,7 +94,8 @@ public:
// Write value data
for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind) {
uint32_t NumValueSites = ProfRecord.getNumValueSites(Kind);
if (NumValueSites == 0) continue;
if (NumValueSites == 0)
continue;
LE.write<uint64_t>(Kind); // Write value kind
// Write number of value sites for current value kind
LE.write<uint64_t>(NumValueSites);
@ -134,7 +137,8 @@ static std::error_code combineInstrProfRecords(InstrProfRecord &Dest,
}
for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind) {
if (std::error_code EC = Dest.mergeValueProfData(Kind, Source)) return EC;
if (std::error_code EC = Dest.mergeValueProfData(Kind, Source))
return EC;
}
// We keep track of the max function count as we go for simplicity.