From 71d5a2540a98c81f5bcaeb48805e0e2881f530ef Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 16 Apr 2017 16:01:22 +0000 Subject: Vendor import of llvm trunk r300422: https://llvm.org/svn/llvm-project/llvm/trunk@300422 --- .../llvm/ProfileData/Coverage/CoverageMapping.h | 79 +++++++++++++--------- 1 file changed, 46 insertions(+), 33 deletions(-) (limited to 'include/llvm/ProfileData/Coverage/CoverageMapping.h') diff --git a/include/llvm/ProfileData/Coverage/CoverageMapping.h b/include/llvm/ProfileData/Coverage/CoverageMapping.h index d6051ffb3f8d..b9a9f5377698 100644 --- a/include/llvm/ProfileData/Coverage/CoverageMapping.h +++ b/include/llvm/ProfileData/Coverage/CoverageMapping.h @@ -1,4 +1,4 @@ -//=-- CoverageMapping.h - Code coverage mapping support ---------*- C++ -*-=// +//===- CoverageMapping.h - Code coverage mapping support --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,25 +12,42 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_PROFILEDATA_COVERAGEMAPPING_H_ -#define LLVM_PROFILEDATA_COVERAGEMAPPING_H_ +#ifndef LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H +#define LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Hashing.h" -#include "llvm/ADT/StringSet.h" -#include "llvm/ADT/Triple.h" #include "llvm/ADT/iterator.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/StringSet.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ProfileData/InstrProf.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include #include #include +#include +#include namespace llvm { + +class IndexedInstrProfReader; + namespace coverage { +class CoverageMappingReader; +struct CoverageMappingRecord; + enum class coveragemap_error { success = 0, eof, @@ -68,19 +85,6 @@ private: coveragemap_error Err; }; -} // end of coverage namespace. -} // end of llvm namespace - -namespace llvm { -class IndexedInstrProfReader; -namespace coverage { - -class CoverageMappingReader; -struct CoverageMappingRecord; - -class CoverageMapping; -struct CounterExpressions; - /// \brief A Counter is an abstract value that describes how to compute the /// execution count for a region of code using the collected profile count data. struct Counter { @@ -91,13 +95,13 @@ struct Counter { EncodingTagBits + 1; private: - CounterKind Kind; - unsigned ID; + CounterKind Kind = Zero; + unsigned ID = 0; Counter(CounterKind Kind, unsigned ID) : Kind(Kind), ID(ID) {} public: - Counter() : Kind(Zero), ID(0) {} + Counter() = default; CounterKind getKind() const { return Kind; } @@ -153,8 +157,9 @@ struct CounterExpression { class CounterExpressionBuilder { /// \brief A list of all the counter expressions std::vector Expressions; + /// \brief A lookup table for the index of a given expression. - llvm::DenseMap ExpressionIndices; + DenseMap ExpressionIndices; /// \brief Return the counter which corresponds to the given expression. /// @@ -238,7 +243,6 @@ struct CounterMappingRegion { LineEnd, ColumnEnd, SkippedRegion); } - inline std::pair startLoc() const { return std::pair(LineStart, ColumnStart); } @@ -269,7 +273,7 @@ public: void setCounts(ArrayRef Counts) { CounterValues = Counts; } - void dump(const Counter &C, llvm::raw_ostream &OS) const; + void dump(const Counter &C, raw_ostream &OS) const; void dump(const Counter &C) const { dump(C, dbgs()); } /// \brief Return the number of times that a region of code associated with @@ -390,13 +394,14 @@ struct CoverageSegment { /// provides a sequence of CoverageSegments to iterate through, as well as the /// list of expansions that can be further processed. class CoverageData { + friend class CoverageMapping; + std::string Filename; std::vector Segments; std::vector Expansions; - friend class CoverageMapping; public: - CoverageData() {} + CoverageData() = default; CoverageData(StringRef Filename) : Filename(Filename) {} @@ -422,18 +427,17 @@ public: class CoverageMapping { StringSet<> FunctionNames; std::vector Functions; - unsigned MismatchedFunctionCount; - - CoverageMapping() : MismatchedFunctionCount(0) {} - - CoverageMapping(const CoverageMapping &) = delete; - const CoverageMapping &operator=(const CoverageMapping &) = delete; + unsigned MismatchedFunctionCount = 0; + CoverageMapping() = default; /// \brief Add a function record corresponding to \p Record. Error loadFunctionRecord(const CoverageMappingRecord &Record, IndexedInstrProfReader &ProfileReader); public: + CoverageMapping(const CoverageMapping &) = delete; + CoverageMapping &operator=(const CoverageMapping &) = delete; + /// \brief Load the coverage mapping using the given readers. static Expected> load(CoverageMappingReader &CoverageReader, @@ -517,14 +521,17 @@ template struct CovMapFunctionRecordV1 { 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 Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const { @@ -545,14 +552,17 @@ struct CovMapFunctionRecord { 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 uint64_t getFuncNameRef() const { return support::endian::byte_swap(NameRef); } + // Return the PGO name of the function */ template Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const { @@ -570,12 +580,15 @@ struct CovMapHeader { 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); } @@ -635,4 +648,4 @@ template<> struct DenseMapInfo { } // end namespace llvm -#endif // LLVM_PROFILEDATA_COVERAGEMAPPING_H_ +#endif // LLVM_PROFILEDATA_COVERAGE_COVERAGEMAPPING_H -- cgit v1.2.3