From 913815ec023daa5a912c2685a76e155ed6c888e7 Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Wed, 13 Jan 2016 00:27:24 +0000 Subject: [PATCH] Rollback r257547 -- buildbot failure TBI git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257549 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ProfileData/CoverageMapping.h | 43 ++-------------------- lib/ProfileData/CoverageMappingReader.cpp | 30 ++++++++------- 2 files changed, 20 insertions(+), 53 deletions(-) diff --git a/include/llvm/ProfileData/CoverageMapping.h b/include/llvm/ProfileData/CoverageMapping.h index a353e1f86ac..2386442d28b 100644 --- a/include/llvm/ProfileData/CoverageMapping.h +++ b/include/llvm/ProfileData/CoverageMapping.h @@ -20,9 +20,8 @@ #include "llvm/ADT/Hashing.h" #include "llvm/ADT/Triple.h" #include "llvm/ADT/iterator.h" -#include "llvm/ProfileData/InstrProf.h" +#include "llvm/ProfileData/InstrProfData.inc" #include "llvm/Support/Debug.h" -#include "llvm/Support/Endian.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/raw_ostream.h" #include @@ -480,50 +479,14 @@ inline std::error_code make_error_code(coveragemap_error E) { // [Encoded Region Mapping Data] LLVM_PACKED_START template struct CovMapFunctionRecord { -#define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name; -#include "llvm/ProfileData/InstrProfData.inc" - - // Return the structural hash associated with the function. - template uint64_t getFuncHash() const { - return support::endian::byte_swap(FuncHash); - } - // Return the coverage map data size for the funciton. - template uint32_t getDataSize() const { - return support::endian::byte_swap(DataSize); - } - // Return function lookup key. The value is consider opaque. - template IntPtrT getFuncNameRef() const { - return support::endian::byte_swap(NamePtr); - } - // Return the PGO name of the function */ - template - std::error_code getFuncName(InstrProfSymtab &ProfileNames, - StringRef &FuncName) const { - IntPtrT NameRef = getFuncNameRef(); - uint32_t NameS = support::endian::byte_swap(NameSize); - FuncName = ProfileNames.getFuncName(NameRef, NameS); - if (NameS && FuncName.empty()) - return coveragemap_error::malformed; - return std::error_code(); - } + #define COVMAP_FUNC_RECORD(Type, LLVMType, Name, Init) Type Name; + #include "llvm/ProfileData/InstrProfData.inc" }; // Per module coverage mapping data header, i.e. CoverageMapFileHeader // documented above. struct CovMapHeader { #define COVMAP_HEADER(Type, LLVMType, Name, Init) Type Name; #include "llvm/ProfileData/InstrProfData.inc" - template uint32_t getNRecords() const { - return support::endian::byte_swap(NRecords); - } - template uint32_t getFilenamesSize() const { - return support::endian::byte_swap(FilenamesSize); - } - template uint32_t getCoverageSize() const { - return support::endian::byte_swap(CoverageSize); - } - template uint32_t getVersion() const { - return support::endian::byte_swap(Version); - } }; LLVM_PACKED_END diff --git a/lib/ProfileData/CoverageMappingReader.cpp b/lib/ProfileData/CoverageMappingReader.cpp index aa794b080bb..af6c616fa03 100644 --- a/lib/ProfileData/CoverageMappingReader.cpp +++ b/lib/ProfileData/CoverageMappingReader.cpp @@ -319,10 +319,13 @@ static std::error_code readCoverageMappingData( if (Buf + sizeof(CovMapHeader) > End) return coveragemap_error::malformed; auto CovHeader = reinterpret_cast(Buf); - uint32_t NRecords = CovHeader->getNRecords(); - uint32_t FilenamesSize = CovHeader->getFilenamesSize(); - uint32_t CoverageSize = CovHeader->getCoverageSize(); - uint32_t Version = CovHeader->getVersion(); + uint32_t NRecords = + endian::byte_swap(CovHeader->NRecords); + uint32_t FilenamesSize = + endian::byte_swap(CovHeader->FilenamesSize); + uint32_t CoverageSize = + endian::byte_swap(CovHeader->CoverageSize); + uint32_t Version = endian::byte_swap(CovHeader->Version); Buf = reinterpret_cast(++CovHeader); if (Version > coverage::CoverageMappingCurrentVersion) @@ -357,8 +360,11 @@ static std::error_code readCoverageMappingData( reinterpret_cast *>(FunBuf); while ((const char *)CFR < FunEnd) { // Read the function information - uint32_t DataSize = CFR->template getDataSize(); - uint64_t FuncHash = CFR->template getFuncHash(); + T NamePtr = endian::byte_swap(CFR->NamePtr); + uint32_t NameSize = endian::byte_swap(CFR->NameSize); + uint32_t DataSize = endian::byte_swap(CFR->DataSize); + uint64_t FuncHash = endian::byte_swap(CFR->FuncHash); + CFR++; // Now use that to read the coverage data. if (CovBuf + DataSize > CovEnd) @@ -369,18 +375,16 @@ static std::error_code readCoverageMappingData( // Ignore this record if we already have a record that points to the same // function name. This is useful to ignore the redundant records for the // functions with ODR linkage. - T NameRef = CFR->template getFuncNameRef(); - if (!UniqueFunctionMappingData.insert(NameRef).second) + if (!UniqueFunctionMappingData.insert(NamePtr).second) continue; - StringRef FuncName; - if (std::error_code EC = - CFR->template getFuncName(ProfileNames, FuncName)) - return EC; + // Finally, grab the name and create a record. + StringRef FuncName = ProfileNames.getFuncName(NamePtr, NameSize); + if (NameSize && FuncName.empty()) + return coveragemap_error::malformed; Records.push_back(BinaryCoverageReader::ProfileMappingRecord( CoverageMappingVersion(Version), FuncName, FuncHash, Mapping, FilenamesBegin, Filenames.size() - FilenamesBegin)); - CFR++; } } -- 2.34.1