[llvm] r257703 - Revert r257699 -- windows buildbot failure TBI
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 13 15:12:53 PST 2016
Author: davidxl
Date: Wed Jan 13 17:12:53 2016
New Revision: 257703
URL: http://llvm.org/viewvc/llvm-project?rev=257703&view=rev
Log:
Revert r257699 -- windows buildbot failure TBI
Modified:
llvm/trunk/include/llvm/ProfileData/CoverageMapping.h
llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp
Modified: llvm/trunk/include/llvm/ProfileData/CoverageMapping.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/CoverageMapping.h?rev=257703&r1=257702&r2=257703&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/CoverageMapping.h (original)
+++ llvm/trunk/include/llvm/ProfileData/CoverageMapping.h Wed Jan 13 17:12:53 2016
@@ -543,11 +543,6 @@ enum CoverageMappingVersion {
CoverageMappingCurrentVersion = INSTR_PROF_COVMAP_VERSION
};
-template <int CovMapVersion, class IntPtrT> struct CovMapTraits {
- typedef CovMapFunctionRecord<IntPtrT> CovMapFuncRecordType;
- typedef IntPtrT NameRefType;
-};
-
} // end namespace coverage
/// \brief Provide DenseMapInfo for CounterExpression
Modified: llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp?rev=257703&r1=257702&r2=257703&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/CoverageMappingReader.cpp Wed Jan 13 17:12:53 2016
@@ -306,57 +306,31 @@ StringRef InstrProfSymtab::getFuncName(u
return Data.substr(Pointer - Address, Size);
}
-struct CovMapFuncRecordReader {
- // The interface to read coverage mapping function records for
- // a module. \p Buf is a reference to the buffer pointer pointing
- // to the \c CovHeader of coverage mapping data associated with
- // the module.
- virtual std::error_code readFunctionRecords(const char *&Buf,
- const char *End) = 0;
- template <class IntPtrT, support::endianness Endian>
- static std::unique_ptr<CovMapFuncRecordReader>
- get(coverage::CoverageMappingVersion Version, InstrProfSymtab &P,
- std::vector<BinaryCoverageReader::ProfileMappingRecord> &R,
- std::vector<StringRef> &F);
-};
-
-// A class for reading coverage mapping function records for a module.
-template <coverage::CoverageMappingVersion CovMapVersion, class IntPtrT,
- support::endianness Endian>
-class VersionedCovMapFuncRecordReader : public CovMapFuncRecordReader {
- typedef typename coverage::CovMapTraits<
- CovMapVersion, IntPtrT>::CovMapFuncRecordType FuncRecordType;
- typedef typename coverage::CovMapTraits<CovMapVersion, IntPtrT>::NameRefType
- NameRefType;
-
- llvm::DenseSet<NameRefType> UniqueFunctionMappingData;
- InstrProfSymtab &ProfileNames;
- std::vector<StringRef> &Filenames;
- std::vector<BinaryCoverageReader::ProfileMappingRecord> &Records;
-
-public:
- VersionedCovMapFuncRecordReader(
- InstrProfSymtab &P,
- std::vector<BinaryCoverageReader::ProfileMappingRecord> &R,
- std::vector<StringRef> &F)
- : ProfileNames(P), Filenames(F), Records(R) {}
-
- std::error_code readFunctionRecords(const char *&Buf,
- const char *End) override {
- using namespace support;
+template <typename T, support::endianness Endian>
+static std::error_code readCoverageMappingData(
+ InstrProfSymtab &ProfileNames, StringRef Data,
+ std::vector<BinaryCoverageReader::ProfileMappingRecord> &Records,
+ std::vector<StringRef> &Filenames) {
+ using namespace support;
+ llvm::DenseSet<T> UniqueFunctionMappingData;
+
+ // Read the records in the coverage data section.
+ for (const char *Buf = Data.data(), *End = Buf + Data.size(); Buf < End;) {
if (Buf + sizeof(CovMapHeader) > End)
return coveragemap_error::malformed;
auto CovHeader = reinterpret_cast<const coverage::CovMapHeader *>(Buf);
uint32_t NRecords = CovHeader->getNRecords<Endian>();
uint32_t FilenamesSize = CovHeader->getFilenamesSize<Endian>();
uint32_t CoverageSize = CovHeader->getCoverageSize<Endian>();
- assert((CoverageMappingVersion)CovHeader->getVersion<Endian>() ==
- CovMapVersion);
- Buf = reinterpret_cast<const char *>(CovHeader + 1);
+ uint32_t Version = CovHeader->getVersion<Endian>();
+ Buf = reinterpret_cast<const char *>(++CovHeader);
+
+ if (Version > coverage::CoverageMappingCurrentVersion)
+ return coveragemap_error::unsupported_version;
// Skip past the function records, saving the start and end for later.
const char *FunBuf = Buf;
- Buf += NRecords * sizeof(FuncRecordType);
+ Buf += NRecords * sizeof(coverage::CovMapFunctionRecord<T>);
const char *FunEnd = Buf;
// Get the filenames.
@@ -379,7 +353,8 @@ public:
// before reading the next map.
Buf += alignmentAdjustment(Buf, 8);
- auto CFR = reinterpret_cast<const FuncRecordType *>(FunBuf);
+ auto CFR =
+ reinterpret_cast<const coverage::CovMapFunctionRecord<T> *>(FunBuf);
while ((const char *)CFR < FunEnd) {
// Read the function information
uint32_t DataSize = CFR->template getDataSize<Endian>();
@@ -394,7 +369,7 @@ public:
// 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.
- NameRefType NameRef = CFR->template getFuncNameRef<Endian>();
+ T NameRef = CFR->template getFuncNameRef<Endian>();
if (!UniqueFunctionMappingData.insert(NameRef).second)
continue;
@@ -403,53 +378,15 @@ public:
CFR->template getFuncName<Endian>(ProfileNames, FuncName))
return EC;
Records.push_back(BinaryCoverageReader::ProfileMappingRecord(
- CovMapVersion, FuncName, FuncHash, Mapping, FilenamesBegin,
- Filenames.size() - FilenamesBegin));
+ CoverageMappingVersion(Version), FuncName, FuncHash, Mapping,
+ FilenamesBegin, Filenames.size() - FilenamesBegin));
CFR++;
}
- return std::error_code();
}
-};
-template <class IntPtrT, support::endianness Endian>
-std::unique_ptr<CovMapFuncRecordReader> CovMapFuncRecordReader::get(
- coverage::CoverageMappingVersion Version, InstrProfSymtab &P,
- std::vector<BinaryCoverageReader::ProfileMappingRecord> &R,
- std::vector<StringRef> &F) {
- using namespace coverage;
- switch (Version) {
- case CoverageMappingVersion1:
- return make_unique<VersionedCovMapFuncRecordReader<CoverageMappingVersion1,
- IntPtrT, Endian>>(P, R,
- F);
- default:
- break;
- }
- llvm_unreachable("Unsupported version");
-}
-
-template <typename T, support::endianness Endian>
-static std::error_code readCoverageMappingData(
- InstrProfSymtab &ProfileNames, StringRef Data,
- std::vector<BinaryCoverageReader::ProfileMappingRecord> &Records,
- std::vector<StringRef> &Filenames) {
- using namespace coverage;
- // Read the records in the coverage data section.
- auto CovHeader =
- reinterpret_cast<const coverage::CovMapHeader *>(Data.data());
- CoverageMappingVersion Version =
- (CoverageMappingVersion)CovHeader->getVersion<Endian>();
- if (Version > coverage::CoverageMappingCurrentVersion)
- return coveragemap_error::unsupported_version;
- std::unique_ptr<CovMapFuncRecordReader> Reader =
- CovMapFuncRecordReader::get<T, Endian>(Version, ProfileNames, Records,
- Filenames);
- for (const char *Buf = Data.data(), *End = Buf + Data.size(); Buf < End;) {
- if (std::error_code EC = Reader->readFunctionRecords(Buf, End))
- return EC;
- }
return std::error_code();
}
+
static const char *TestingFormatMagic = "llvmcovmtestdata";
static std::error_code loadTestingFormat(StringRef Data,
More information about the llvm-commits
mailing list