From c8c39ea822f67cbf1e83b65914bf699aaf28f17c Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Wed, 13 Jan 2016 02:46:40 +0000 Subject: Rollback r257551 -- unexpected test failures TBI llvm-svn: 257564 --- llvm/lib/ProfileData/CoverageMappingReader.cpp | 30 +++++++++++++++----------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'llvm/lib/ProfileData') diff --git a/llvm/lib/ProfileData/CoverageMappingReader.cpp b/llvm/lib/ProfileData/CoverageMappingReader.cpp index 89e1cf42c57..af6c616fa03 100644 --- a/llvm/lib/ProfileData/CoverageMappingReader.cpp +++ b/llvm/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++; } } -- cgit v1.2.3