From 4d774a394162a8eded26dd6df76de44d1c4d030c Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Fri, 6 Nov 2015 07:54:21 +0000 Subject: [PATCH] Code style fix (caused by wrongly default clang-format style) (NFC) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252276 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ProfileData/InstrProf.h | 48 +++++++++++++++------------- lib/ProfileData/InstrProfReader.cpp | 13 +++++--- lib/ProfileData/InstrProfWriter.cpp | 14 +++++--- 3 files changed, 42 insertions(+), 33 deletions(-) diff --git a/include/llvm/ProfileData/InstrProf.h b/include/llvm/ProfileData/InstrProf.h index d4119ed55c4..59baf30d7b3 100644 --- a/include/llvm/ProfileData/InstrProf.h +++ b/include/llvm/ProfileData/InstrProf.h @@ -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 getValueForSite( - uint32_t ValueKind, uint32_t Site) const; + inline std::unique_ptr + 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 IndirectCallSites; const std::vector & 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 &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 &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 InstrProfRecord::getValueForSite( - uint32_t ValueKind, uint32_t Site) const { +std::unique_ptr +InstrProfRecord::getValueForSite(uint32_t ValueKind, uint32_t Site) const { uint32_t N = getNumValueDataForSite(ValueKind, Site); - if (N == 0) return std::unique_ptr(nullptr); + if (N == 0) + return std::unique_ptr(nullptr); std::unique_ptr 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() { // It should also match the synthesized type in // Transforms/Instrumentation/InstrProfiling.cpp:getOrCreateRegionCounters. -template -struct ProfileData { +template 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 -struct CovMapFunctionRecord { +template struct CovMapFunctionRecord { #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name; #include "llvm/ProfileData/InstrProfData.inc" }; diff --git a/lib/ProfileData/InstrProfReader.cpp b/lib/ProfileData/InstrProfReader.cpp index 58dbeef6531..66fd961c84f 100644 --- a/lib/ProfileData/InstrProfReader.cpp +++ b/lib/ProfileData/InstrProfReader.cpp @@ -483,8 +483,9 @@ std::error_code IndexedInstrProfReader::readHeader() { return success(); } -ErrorOr IndexedInstrProfReader::getInstrProfRecord( - StringRef FuncName, uint64_t FuncHash) { +ErrorOr +IndexedInstrProfReader::getInstrProfRecord(StringRef FuncName, + uint64_t FuncHash) { ArrayRef Data; std::error_code EC = Index.getRecords(FuncName, Data); if (EC != instrprof_error::success) return EC; @@ -498,10 +499,12 @@ ErrorOr IndexedInstrProfReader::getInstrProfRecord( return error(instrprof_error::hash_mismatch); } -std::error_code IndexedInstrProfReader::getFunctionCounts( - StringRef FuncName, uint64_t FuncHash, std::vector &Counts) { +std::error_code +IndexedInstrProfReader::getFunctionCounts(StringRef FuncName, uint64_t FuncHash, + std::vector &Counts) { ErrorOr 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(); diff --git a/lib/ProfileData/InstrProfWriter.cpp b/lib/ProfileData/InstrProfWriter.cpp index 33386539576..b073d8df918 100644 --- a/lib/ProfileData/InstrProfWriter.cpp +++ b/lib/ProfileData/InstrProfWriter.cpp @@ -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(ProfileData.first); // Function hash LE.write(ProfRecord.Counts.size()); - for (uint64_t I : ProfRecord.Counts) LE.write(I); + for (uint64_t I : ProfRecord.Counts) + LE.write(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(Kind); // Write value kind // Write number of value sites for current value kind LE.write(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. -- 2.34.1