<div dir="ltr">I forgot to update -- I have browsed through the changes (post commit). They seem fine to me.<div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 3, 2017 at 2:17 PM, Vedant Kumar via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Eugene,<br>
<br>
Making this kind of large change without approval from anyone who works on the affected code is inappropriate. This pollutes the git history and creates churn I'd rather live without.<br>
<br>
If you must make these kinds of invasive changes, just ask for a review first.<br>
<br>
vedant<br>
<div class="HOEnZb"><div class="h5"><br>
> On Mar 2, 2017, at 5:07 PM, Eugene Zelenko via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: eugenezelenko<br>
> Date: Thu Mar  2 19:07:34 2017<br>
> New Revision: 296846<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=296846&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=296846&view=rev</a><br>
> Log:<br>
> [ProfileData] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).<br>
><br>
> Modified:<br>
>    llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMapping.h<br>
>    llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMappingReader.h<br>
>    llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMappingWriter.h<br>
>    llvm/trunk/include/llvm/<wbr>ProfileData/InstrProf.h<br>
>    llvm/trunk/include/llvm/<wbr>ProfileData/InstrProfReader.h<br>
>    llvm/trunk/include/llvm/<wbr>ProfileData/InstrProfWriter.h<br>
>    llvm/trunk/include/llvm/<wbr>ProfileData/ProfileCommon.h<br>
>    llvm/trunk/include/llvm/<wbr>ProfileData/SampleProf.h<br>
>    llvm/trunk/include/llvm/<wbr>ProfileData/SampleProfReader.h<br>
>    llvm/trunk/include/llvm/<wbr>ProfileData/SampleProfWriter.h<br>
>    llvm/trunk/lib/ProfileData/<wbr>Coverage/CoverageMapping.cpp<br>
>    llvm/trunk/lib/ProfileData/<wbr>Coverage/<wbr>CoverageMappingReader.cpp<br>
>    llvm/trunk/lib/ProfileData/<wbr>Coverage/<wbr>CoverageMappingWriter.cpp<br>
>    llvm/trunk/lib/ProfileData/<wbr>InstrProf.cpp<br>
>    llvm/trunk/lib/ProfileData/<wbr>InstrProfReader.cpp<br>
>    llvm/trunk/lib/ProfileData/<wbr>InstrProfWriter.cpp<br>
>    llvm/trunk/lib/ProfileData/<wbr>SampleProf.cpp<br>
>    llvm/trunk/lib/ProfileData/<wbr>SampleProfReader.cpp<br>
>    llvm/trunk/lib/ProfileData/<wbr>SampleProfWriter.cpp<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMapping.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMapping.h?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ProfileData/Coverage/<wbr>CoverageMapping.h?rev=296846&<wbr>r1=296845&r2=296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMapping.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMapping.h Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- CoverageMapping.h - Code coverage mapping support ---------*- C++ -*-=//<br>
> +//===- CoverageMapping.h - Code coverage mapping support --------*- C++ -*-===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -12,25 +12,42 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> -#ifndef LLVM_PROFILEDATA_<wbr>COVERAGEMAPPING_H_<br>
> -#define LLVM_PROFILEDATA_<wbr>COVERAGEMAPPING_H_<br>
> +#ifndef LLVM_PROFILEDATA_COVERAGE_<wbr>COVERAGEMAPPING_H<br>
> +#define LLVM_PROFILEDATA_COVERAGE_<wbr>COVERAGEMAPPING_H<br>
><br>
> #include "llvm/ADT/ArrayRef.h"<br>
> #include "llvm/ADT/DenseMap.h"<br>
> #include "llvm/ADT/Hashing.h"<br>
> -#include "llvm/ADT/StringSet.h"<br>
> -#include "llvm/ADT/Triple.h"<br>
> #include "llvm/ADT/iterator.h"<br>
> +#include "llvm/ADT/iterator_range.h"<br>
> +#include "llvm/ADT/None.h"<br>
> +#include "llvm/ADT/StringSet.h"<br>
> +#include "llvm/ADT/StringRef.h"<br>
> #include "llvm/ProfileData/InstrProf.h"<br>
> +#include "llvm/Support/Compiler.h"<br>
> #include "llvm/Support/Debug.h"<br>
> #include "llvm/Support/Endian.h"<br>
> +#include "llvm/Support/Error.h"<br>
> #include "llvm/Support/raw_ostream.h"<br>
> +#include <cassert><br>
> +#include <cstdint><br>
> +#include <iterator><br>
> +#include <memory><br>
> +#include <string><br>
> #include <system_error><br>
> #include <tuple><br>
> +#include <utility><br>
> +#include <vector><br>
><br>
> namespace llvm {<br>
> +<br>
> +class IndexedInstrProfReader;<br>
> +<br>
> namespace coverage {<br>
><br>
> +class CoverageMappingReader;<br>
> +struct CoverageMappingRecord;<br>
> +<br>
> enum class coveragemap_error {<br>
>   success = 0,<br>
>   eof,<br>
> @@ -68,19 +85,6 @@ private:<br>
>   coveragemap_error Err;<br>
> };<br>
><br>
> -} // end of coverage namespace.<br>
> -} // end of llvm namespace<br>
> -<br>
> -namespace llvm {<br>
> -class IndexedInstrProfReader;<br>
> -namespace coverage {<br>
> -<br>
> -class CoverageMappingReader;<br>
> -struct CoverageMappingRecord;<br>
> -<br>
> -class CoverageMapping;<br>
> -struct CounterExpressions;<br>
> -<br>
> /// \brief A Counter is an abstract value that describes how to compute the<br>
> /// execution count for a region of code using the collected profile count data.<br>
> struct Counter {<br>
> @@ -91,13 +95,13 @@ struct Counter {<br>
>       EncodingTagBits + 1;<br>
><br>
> private:<br>
> -  CounterKind Kind;<br>
> -  unsigned ID;<br>
> +  CounterKind Kind = Zero;<br>
> +  unsigned ID = 0;<br>
><br>
>   Counter(CounterKind Kind, unsigned ID) : Kind(Kind), ID(ID) {}<br>
><br>
> public:<br>
> -  Counter() : Kind(Zero), ID(0) {}<br>
> +  Counter() = default;<br>
><br>
>   CounterKind getKind() const { return Kind; }<br>
><br>
> @@ -153,8 +157,9 @@ struct CounterExpression {<br>
> class CounterExpressionBuilder {<br>
>   /// \brief A list of all the counter expressions<br>
>   std::vector<CounterExpression> Expressions;<br>
> +<br>
>   /// \brief A lookup table for the index of a given expression.<br>
> -  llvm::DenseMap<<wbr>CounterExpression, unsigned> ExpressionIndices;<br>
> +  DenseMap<CounterExpression, unsigned> ExpressionIndices;<br>
><br>
>   /// \brief Return the counter which corresponds to the given expression.<br>
>   ///<br>
> @@ -238,7 +243,6 @@ struct CounterMappingRegion {<br>
>                                 LineEnd, ColumnEnd, SkippedRegion);<br>
>   }<br>
><br>
> -<br>
>   inline std::pair<unsigned, unsigned> startLoc() const {<br>
>     return std::pair<unsigned, unsigned>(LineStart, ColumnStart);<br>
>   }<br>
> @@ -269,7 +273,7 @@ public:<br>
><br>
>   void setCounts(ArrayRef<uint64_t> Counts) { CounterValues = Counts; }<br>
><br>
> -  void dump(const Counter &C, llvm::raw_ostream &OS) const;<br>
> +  void dump(const Counter &C, raw_ostream &OS) const;<br>
>   void dump(const Counter &C) const { dump(C, dbgs()); }<br>
><br>
>   /// \brief Return the number of times that a region of code associated with<br>
> @@ -390,13 +394,14 @@ struct CoverageSegment {<br>
> /// provides a sequence of CoverageSegments to iterate through, as well as the<br>
> /// list of expansions that can be further processed.<br>
> class CoverageData {<br>
> +  friend class CoverageMapping;<br>
> +<br>
>   std::string Filename;<br>
>   std::vector<CoverageSegment> Segments;<br>
>   std::vector<ExpansionRecord> Expansions;<br>
> -  friend class CoverageMapping;<br>
><br>
> public:<br>
> -  CoverageData() {}<br>
> +  CoverageData() = default;<br>
><br>
>   CoverageData(StringRef Filename) : Filename(Filename) {}<br>
><br>
> @@ -422,18 +427,17 @@ public:<br>
> class CoverageMapping {<br>
>   StringSet<> FunctionNames;<br>
>   std::vector<FunctionRecord> Functions;<br>
> -  unsigned MismatchedFunctionCount;<br>
> -<br>
> -  CoverageMapping() : MismatchedFunctionCount(0) {}<br>
> -<br>
> -  CoverageMapping(const CoverageMapping &) = delete;<br>
> -  const CoverageMapping &operator=(const CoverageMapping &) = delete;<br>
> +  unsigned MismatchedFunctionCount = 0;<br>
><br>
> +  CoverageMapping() = default;<br>
>   /// \brief Add a function record corresponding to \p Record.<br>
>   Error loadFunctionRecord(const CoverageMappingRecord &Record,<br>
>                            IndexedInstrProfReader &ProfileReader);<br>
><br>
> public:<br>
> +  CoverageMapping(const CoverageMapping &) = delete;<br>
> +  CoverageMapping &operator=(const CoverageMapping &) = delete;<br>
> +<br>
>   /// \brief Load the coverage mapping using the given readers.<br>
>   static Expected<std::unique_ptr<<wbr>CoverageMapping>><br>
>   load(CoverageMappingReader &CoverageReader,<br>
> @@ -517,14 +521,17 @@ template <class IntPtrT> struct CovMapFu<br>
>   template <support::endianness Endian> uint64_t getFuncHash() const {<br>
>     return support::endian::byte_swap<<wbr>uint64_t, Endian>(FuncHash);<br>
>   }<br>
> +<br>
>   // Return the coverage map data size for the funciton.<br>
>   template <support::endianness Endian> uint32_t getDataSize() const {<br>
>     return support::endian::byte_swap<<wbr>uint32_t, Endian>(DataSize);<br>
>   }<br>
> +<br>
>   // Return function lookup key. The value is consider opaque.<br>
>   template <support::endianness Endian> IntPtrT getFuncNameRef() const {<br>
>     return support::endian::byte_swap<<wbr>IntPtrT, Endian>(NamePtr);<br>
>   }<br>
> +<br>
>   // Return the PGO name of the function */<br>
>   template <support::endianness Endian><br>
>   Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const {<br>
> @@ -545,14 +552,17 @@ struct CovMapFunctionRecord {<br>
>   template <support::endianness Endian> uint64_t getFuncHash() const {<br>
>     return support::endian::byte_swap<<wbr>uint64_t, Endian>(FuncHash);<br>
>   }<br>
> +<br>
>   // Return the coverage map data size for the funciton.<br>
>   template <support::endianness Endian> uint32_t getDataSize() const {<br>
>     return support::endian::byte_swap<<wbr>uint32_t, Endian>(DataSize);<br>
>   }<br>
> +<br>
>   // Return function lookup key. The value is consider opaque.<br>
>   template <support::endianness Endian> uint64_t getFuncNameRef() const {<br>
>     return support::endian::byte_swap<<wbr>uint64_t, Endian>(NameRef);<br>
>   }<br>
> +<br>
>   // Return the PGO name of the function */<br>
>   template <support::endianness Endian><br>
>   Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const {<br>
> @@ -570,12 +580,15 @@ struct CovMapHeader {<br>
>   template <support::endianness Endian> uint32_t getNRecords() const {<br>
>     return support::endian::byte_swap<<wbr>uint32_t, Endian>(NRecords);<br>
>   }<br>
> +<br>
>   template <support::endianness Endian> uint32_t getFilenamesSize() const {<br>
>     return support::endian::byte_swap<<wbr>uint32_t, Endian>(FilenamesSize);<br>
>   }<br>
> +<br>
>   template <support::endianness Endian> uint32_t getCoverageSize() const {<br>
>     return support::endian::byte_swap<<wbr>uint32_t, Endian>(CoverageSize);<br>
>   }<br>
> +<br>
>   template <support::endianness Endian> uint32_t getVersion() const {<br>
>     return support::endian::byte_swap<<wbr>uint32_t, Endian>(Version);<br>
>   }<br>
> @@ -635,4 +648,4 @@ template<> struct DenseMapInfo<coverage:<br>
><br>
> } // end namespace llvm<br>
><br>
> -#endif // LLVM_PROFILEDATA_<wbr>COVERAGEMAPPING_H_<br>
> +#endif // LLVM_PROFILEDATA_COVERAGE_<wbr>COVERAGEMAPPING_H<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMappingReader.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMappingReader.h?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ProfileData/Coverage/<wbr>CoverageMappingReader.h?rev=<wbr>296846&r1=296845&r2=296846&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMappingReader.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMappingReader.h Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- CoverageMappingReader.h - Code coverage mapping reader ------*- C++ -*-=//<br>
> +//===- CoverageMappingReader.h - Code coverage mapping reader ---*- C++ -*-===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -12,18 +12,20 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> -#ifndef LLVM_PROFILEDATA_<wbr>COVERAGEMAPPINGREADER_H<br>
> -#define LLVM_PROFILEDATA_<wbr>COVERAGEMAPPINGREADER_H<br>
> +#ifndef LLVM_PROFILEDATA_COVERAGE_<wbr>COVERAGEMAPPINGREADER_H<br>
> +#define LLVM_PROFILEDATA_COVERAGE_<wbr>COVERAGEMAPPINGREADER_H<br>
><br>
> #include "llvm/ADT/ArrayRef.h"<br>
> #include "llvm/ADT/StringRef.h"<br>
> -#include "llvm/ADT/Triple.h"<br>
> -#include "llvm/Object/ObjectFile.h"<br>
> #include "llvm/ProfileData/Coverage/<wbr>CoverageMapping.h"<br>
> #include "llvm/ProfileData/InstrProf.h"<br>
> -#include "llvm/Support/FileSystem.h"<br>
> +#include "llvm/Support/Error.h"<br>
> #include "llvm/Support/MemoryBuffer.h"<br>
> +#include <cstddef><br>
> +#include <cstdint><br>
> #include <iterator><br>
> +#include <memory><br>
> +#include <vector><br>
><br>
> namespace llvm {<br>
> namespace coverage {<br>
> @@ -42,13 +44,14 @@ struct CoverageMappingRecord {<br>
> /// \brief A file format agnostic iterator over coverage mapping data.<br>
> class CoverageMappingIterator<br>
>     : public std::iterator<std::input_<wbr>iterator_tag, CoverageMappingRecord> {<br>
> -  CoverageMappingReader *Reader;<br>
> +  CoverageMappingReader *Reader = nullptr;<br>
>   CoverageMappingRecord Record;<br>
><br>
>   void increment();<br>
><br>
> public:<br>
> -  CoverageMappingIterator() : Reader(nullptr) {}<br>
> +  CoverageMappingIterator() = default;<br>
> +<br>
>   CoverageMappingIterator(<wbr>CoverageMappingReader *Reader) : Reader(Reader) {<br>
>     increment();<br>
>   }<br>
> @@ -69,10 +72,11 @@ public:<br>
><br>
> class CoverageMappingReader {<br>
> public:<br>
> +  virtual ~CoverageMappingReader() = default;<br>
> +<br>
>   virtual Error readNextRecord(<wbr>CoverageMappingRecord &Record) = 0;<br>
>   CoverageMappingIterator begin() { return CoverageMappingIterator(this); }<br>
>   CoverageMappingIterator end() { return CoverageMappingIterator(); }<br>
> -  virtual ~CoverageMappingReader() {}<br>
> };<br>
><br>
> /// \brief Base class for the raw coverage mapping and filenames data readers.<br>
> @@ -92,13 +96,12 @@ protected:<br>
> class RawCoverageFilenamesReader : public RawCoverageReader {<br>
>   std::vector<StringRef> &Filenames;<br>
><br>
> -  RawCoverageFilenamesReader(<wbr>const RawCoverageFilenamesReader &) = delete;<br>
> -  RawCoverageFilenamesReader &<br>
> -  operator=(const RawCoverageFilenamesReader &) = delete;<br>
> -<br>
> public:<br>
>   RawCoverageFilenamesReader(<wbr>StringRef Data, std::vector<StringRef> &Filenames)<br>
>       : RawCoverageReader(Data), Filenames(Filenames) {}<br>
> +  RawCoverageFilenamesReader(<wbr>const RawCoverageFilenamesReader &) = delete;<br>
> +  RawCoverageFilenamesReader &<br>
> +  operator=(const RawCoverageFilenamesReader &) = delete;<br>
><br>
>   Error read();<br>
> };<br>
> @@ -120,10 +123,6 @@ class RawCoverageMappingReader : public<br>
>   std::vector<CounterExpression> &Expressions;<br>
>   std::vector<<wbr>CounterMappingRegion> &MappingRegions;<br>
><br>
> -  RawCoverageMappingReader(const RawCoverageMappingReader &) = delete;<br>
> -  RawCoverageMappingReader &<br>
> -  operator=(const RawCoverageMappingReader &) = delete;<br>
> -<br>
> public:<br>
>   RawCoverageMappingReader(<wbr>StringRef MappingData,<br>
>                            ArrayRef<StringRef> TranslationUnitFilenames,<br>
> @@ -134,6 +133,9 @@ public:<br>
>         TranslationUnitFilenames(<wbr>TranslationUnitFilenames),<br>
>         Filenames(Filenames), Expressions(Expressions),<br>
>         MappingRegions(MappingRegions) {}<br>
> +  RawCoverageMappingReader(const RawCoverageMappingReader &) = delete;<br>
> +  RawCoverageMappingReader &<br>
> +  operator=(const RawCoverageMappingReader &) = delete;<br>
><br>
>   Error read();<br>
><br>
> @@ -169,17 +171,17 @@ private:<br>
>   std::vector<StringRef> Filenames;<br>
>   std::vector<<wbr>ProfileMappingRecord> MappingRecords;<br>
>   InstrProfSymtab ProfileNames;<br>
> -  size_t CurrentRecord;<br>
> +  size_t CurrentRecord = 0;<br>
>   std::vector<StringRef> FunctionsFilenames;<br>
>   std::vector<CounterExpression> Expressions;<br>
>   std::vector<<wbr>CounterMappingRegion> MappingRegions;<br>
><br>
> +  BinaryCoverageReader() = default;<br>
> +<br>
> +public:<br>
>   BinaryCoverageReader(const BinaryCoverageReader &) = delete;<br>
>   BinaryCoverageReader &operator=(const BinaryCoverageReader &) = delete;<br>
><br>
> -  BinaryCoverageReader() : CurrentRecord(0) {}<br>
> -<br>
> -public:<br>
>   static Expected<std::unique_ptr<<wbr>BinaryCoverageReader>><br>
>   create(std::unique_ptr<<wbr>MemoryBuffer> &ObjectBuffer,<br>
>          StringRef Arch);<br>
> @@ -190,4 +192,4 @@ public:<br>
> } // end namespace coverage<br>
> } // end namespace llvm<br>
><br>
> -#endif<br>
> +#endif // LLVM_PROFILEDATA_COVERAGE_<wbr>COVERAGEMAPPINGREADER_H<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMappingWriter.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ProfileData/Coverage/<wbr>CoverageMappingWriter.h?rev=<wbr>296846&r1=296845&r2=296846&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMappingWriter.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ProfileData/Coverage/<wbr>CoverageMappingWriter.h Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- CoverageMappingWriter.h - Code coverage mapping writer ------*- C++ -*-=//<br>
> +//===- CoverageMappingWriter.h - Code coverage mapping writer ---*- C++ -*-===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -12,15 +12,17 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> -#ifndef LLVM_PROFILEDATA_<wbr>COVERAGEMAPPINGWRITER_H<br>
> -#define LLVM_PROFILEDATA_<wbr>COVERAGEMAPPINGWRITER_H<br>
> +#ifndef LLVM_PROFILEDATA_COVERAGE_<wbr>COVERAGEMAPPINGWRITER_H<br>
> +#define LLVM_PROFILEDATA_COVERAGE_<wbr>COVERAGEMAPPINGWRITER_H<br>
><br>
> #include "llvm/ADT/ArrayRef.h"<br>
> -#include "llvm/ADT/StringMap.h"<br>
> +#include "llvm/ADT/StringRef.h"<br>
> #include "llvm/ProfileData/Coverage/<wbr>CoverageMapping.h"<br>
> -#include "llvm/Support/raw_ostream.h"<br>
><br>
> namespace llvm {<br>
> +<br>
> +class raw_ostream;<br>
> +<br>
> namespace coverage {<br>
><br>
> /// \brief Writer of the filenames section for the instrumentation<br>
> @@ -54,6 +56,7 @@ public:<br>
> };<br>
><br>
> } // end namespace coverage<br>
> +<br>
> } // end namespace llvm<br>
><br>
> -#endif<br>
> +#endif // LLVM_PROFILEDATA_COVERAGE_<wbr>COVERAGEMAPPINGWRITER_H<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ProfileData/InstrProf.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ProfileData/InstrProf.h?<wbr>rev=296846&r1=296845&r2=<wbr>296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ProfileData/InstrProf.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ProfileData/InstrProf.h Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//===-- InstrProf.h - Instrumented profiling format support -----*- C++ -*-===//<br>
> +//===- InstrProf.h - Instrumented profiling format support ------*- C++ -*-===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -16,26 +16,41 @@<br>
> #ifndef LLVM_PROFILEDATA_INSTRPROF_H<br>
> #define LLVM_PROFILEDATA_INSTRPROF_H<br>
><br>
> +#include "llvm/ADT/ArrayRef.h"<br>
> #include "llvm/ADT/STLExtras.h"<br>
> #include "llvm/ADT/StringRef.h"<br>
> #include "llvm/ADT/StringSet.h"<br>
> #include "llvm/IR/GlobalValue.h"<br>
> -#include "llvm/IR/Metadata.h"<br>
> +#include "llvm/IR/ProfileSummary.h"<br>
> #include "llvm/ProfileData/<wbr>InstrProfData.inc"<br>
> -#include "llvm/ProfileData/<wbr>ProfileCommon.h"<br>
> +#include "llvm/Support/Compiler.h"<br>
> #include "llvm/Support/Endian.h"<br>
> +#include "llvm/Support/Error.h"<br>
> #include "llvm/Support/ErrorHandling.h"<br>
> +#include "llvm/Support/Host.h"<br>
> #include "llvm/Support/MD5.h"<br>
> #include "llvm/Support/MathExtras.h"<br>
> +#include "llvm/Support/raw_ostream.h"<br>
> +#include <algorithm><br>
> +#include <cassert><br>
> +#include <cstddef><br>
> #include <cstdint><br>
> +#include <cstring><br>
> #include <list><br>
> +#include <memory><br>
> +#include <string><br>
> #include <system_error><br>
> +#include <utility><br>
> #include <vector><br>
><br>
> namespace llvm {<br>
><br>
> class Function;<br>
> class GlobalVariable;<br>
> +struct InstrProfRecord;<br>
> +class InstrProfSymtab;<br>
> +class Instruction;<br>
> +class MDNode;<br>
> class Module;<br>
><br>
> /// Return the name of data section containing profile counter variables.<br>
> @@ -201,6 +216,7 @@ GlobalVariable *createPGOFuncNameVar(Fun<br>
> GlobalVariable *createPGOFuncNameVar(Module &M,<br>
>                                      GlobalValue::LinkageTypes Linkage,<br>
>                                      StringRef PGOFuncName);<br>
> +<br>
> /// Return the initializer in string of the PGO name var \c NameVar.<br>
> StringRef getPGOFuncNameVarInitializer(<wbr>GlobalVariable *NameVar);<br>
><br>
> @@ -220,11 +236,12 @@ StringRef getFuncNameWithoutPrefix(Strin<br>
> /// second field will have value zero.<br>
> Error collectPGOFuncNameStrings(<wbr>const std::vector<std::string> &NameStrs,<br>
>                                 bool doCompression, std::string &Result);<br>
> +<br>
> /// Produce \c Result string with the same format described above. The input<br>
> /// is vector of PGO function name variables that are referenced.<br>
> Error collectPGOFuncNameStrings(<wbr>const std::vector<GlobalVariable *> &NameVars,<br>
>                                 std::string &Result, bool doCompression = true);<br>
> -class InstrProfSymtab;<br>
> +<br>
> /// \c NameStrings is a string composed of one of more sub-strings encoded in<br>
> /// the format described above. The substrings are separated by 0 or more zero<br>
> /// bytes. This method decodes the string and populates the \c Symtab.<br>
> @@ -244,8 +261,6 @@ enum InstrProfValueKind : uint32_t {<br>
> #include "llvm/ProfileData/<wbr>InstrProfData.inc"<br>
> };<br>
><br>
> -struct InstrProfRecord;<br>
> -<br>
> /// Get the value profile data for value site \p SiteIdx from \p InstrProfR<br>
> /// and annotate the instruction \p Inst with the value profile meta data.<br>
> /// Annotate up to \p MaxMDCount (default 3) number of records per value site.<br>
> @@ -253,6 +268,7 @@ void annotateValueSite(Module &M, Instru<br>
>                        const InstrProfRecord &InstrProfR,<br>
>                        InstrProfValueKind ValueKind, uint32_t SiteIndx,<br>
>                        uint32_t MaxMDCount = 3);<br>
> +<br>
> /// Same as the above interface but using an ArrayRef, as well as \p Sum.<br>
> void annotateValueSite(Module &M, Instruction &Inst,<br>
>                        ArrayRef<InstrProfValueData> VDs,<br>
> @@ -347,25 +363,22 @@ class SoftInstrProfErrors {<br>
>   /// the first such error for reporting purposes.<br>
><br>
>   /// The first soft error encountered.<br>
> -  instrprof_error FirstError;<br>
> +  instrprof_error FirstError = instrprof_error::success;<br>
><br>
>   /// The number of hash mismatches.<br>
> -  unsigned NumHashMismatches;<br>
> +  unsigned NumHashMismatches = 0;<br>
><br>
>   /// The number of count mismatches.<br>
> -  unsigned NumCountMismatches;<br>
> +  unsigned NumCountMismatches = 0;<br>
><br>
>   /// The number of counter overflows.<br>
> -  unsigned NumCounterOverflows;<br>
> +  unsigned NumCounterOverflows = 0;<br>
><br>
>   /// The number of value site count mismatches.<br>
> -  unsigned NumValueSiteCountMismatches;<br>
> +  unsigned NumValueSiteCountMismatches = 0;<br>
><br>
> public:<br>
> -  SoftInstrProfErrors()<br>
> -      : FirstError(instrprof_error::<wbr>success), NumHashMismatches(0),<br>
> -        NumCountMismatches(0), NumCounterOverflows(0),<br>
> -        NumValueSiteCountMismatches(0) {}<br>
> +  SoftInstrProfErrors() = default;<br>
><br>
>   ~SoftInstrProfErrors() {<br>
>     assert(FirstError == instrprof_error::success &&<br>
> @@ -401,12 +414,16 @@ public:<br>
> };<br>
><br>
> namespace object {<br>
> +<br>
> class SectionRef;<br>
> -}<br>
> +<br>
> +} // end namespace object<br>
><br>
> namespace IndexedInstrProf {<br>
> +<br>
> uint64_t ComputeHash(StringRef K);<br>
> -}<br>
> +<br>
> +} // end namespace IndexedInstrProf<br>
><br>
> /// A symbol table used for function PGO name look-up with keys<br>
> /// (such as pointers, md5hash values) to the function. A function's<br>
> @@ -419,7 +436,7 @@ public:<br>
><br>
> private:<br>
>   StringRef Data;<br>
> -  uint64_t Address;<br>
> +  uint64_t Address = 0;<br>
>   // Unique name strings.<br>
>   StringSet<> NameTab;<br>
>   // A map from MD5 keys to function name strings.<br>
> @@ -432,9 +449,7 @@ private:<br>
>   AddrHashMap AddrToMD5Map;<br>
><br>
> public:<br>
> -  InstrProfSymtab()<br>
> -      : Data(), Address(0), NameTab(), MD5NameMap(), MD5FuncMap(),<br>
> -      AddrToMD5Map() {}<br>
> +  InstrProfSymtab() = default;<br>
><br>
>   /// Create InstrProfSymtab from an object file section which<br>
>   /// contains function PGO names. When section may contain raw<br>
> @@ -443,26 +458,32 @@ public:<br>
>   /// the section base address. The decompression will be delayed<br>
>   /// until before it is used. See also \c create(StringRef) method.<br>
>   Error create(object::SectionRef &Section);<br>
> +<br>
>   /// This interface is used by reader of CoverageMapping test<br>
>   /// format.<br>
>   inline Error create(StringRef D, uint64_t BaseAddr);<br>
> +<br>
>   /// \c NameStrings is a string composed of one of more sub-strings<br>
>   ///  encoded in the format described in \c collectPGOFuncNameStrings.<br>
>   /// This method is a wrapper to \c readPGOFuncNameStrings method.<br>
>   inline Error create(StringRef NameStrings);<br>
> +<br>
>   /// A wrapper interface to populate the PGO symtab with functions<br>
>   /// decls from module \c M. This interface is used by transformation<br>
>   /// passes such as indirect function call promotion. Variable \c InLTO<br>
>   /// indicates if this is called from LTO optimization passes.<br>
>   void create(Module &M, bool InLTO = false);<br>
> +<br>
>   /// Create InstrProfSymtab from a set of names iteratable from<br>
>   /// \p IterRange. This interface is used by IndexedProfReader.<br>
>   template <typename NameIterRange> void create(const NameIterRange &IterRange);<br>
> +<br>
>   // If the symtab is created by a series of calls to \c addFuncName, \c<br>
>   // finalizeSymtab needs to be called before looking up function names.<br>
>   // This is required because the underlying map is a vector (for space<br>
>   // efficiency) which needs to be sorted.<br>
>   inline void finalizeSymtab();<br>
> +<br>
>   /// Update the symtab by adding \p FuncName to the table. This interface<br>
>   /// is used by the raw and text profile readers.<br>
>   void addFuncName(StringRef FuncName) {<br>
> @@ -471,25 +492,32 @@ public:<br>
>       MD5NameMap.push_back(std::<wbr>make_pair(<br>
>           IndexedInstrProf::ComputeHash(<wbr>FuncName), Ins.first->getKey()));<br>
>   }<br>
> +<br>
>   /// Map a function address to its name's MD5 hash. This interface<br>
>   /// is only used by the raw profiler reader.<br>
>   void mapAddress(uint64_t Addr, uint64_t MD5Val) {<br>
>     AddrToMD5Map.push_back(std::<wbr>make_pair(Addr, MD5Val));<br>
>   }<br>
> +<br>
>   AddrHashMap &getAddrHashMap() { return AddrToMD5Map; }<br>
> +<br>
>   /// Return function's PGO name from the function name's symbol<br>
>   /// address in the object file. If an error occurs, return<br>
>   /// an empty string.<br>
>   StringRef getFuncName(uint64_t FuncNameAddress, size_t NameSize);<br>
> +<br>
>   /// Return function's PGO name from the name's md5 hash value.<br>
>   /// If not found, return an empty string.<br>
>   inline StringRef getFuncName(uint64_t FuncMD5Hash);<br>
> +<br>
>   /// Return function from the name's md5 hash. Return nullptr if not found.<br>
>   inline Function *getFunction(uint64_t FuncMD5Hash);<br>
> +<br>
>   /// Return the function's original assembly name by stripping off<br>
>   /// the prefix attached (to symbols with priviate linkage). For<br>
>   /// global functions, it returns the same string as getFuncName.<br>
>   inline StringRef getOrigFuncName(uint64_t FuncMD5Hash);<br>
> +<br>
>   /// Return the name section data.<br>
>   inline StringRef getNameData() const { return Data; }<br>
> };<br>
> @@ -579,40 +607,48 @@ struct InstrProfValueSiteRecord {<br>
><br>
> /// Profiling information for a single function.<br>
> struct InstrProfRecord {<br>
> -  InstrProfRecord() : SIPE() {}<br>
> -  InstrProfRecord(StringRef Name, uint64_t Hash, std::vector<uint64_t> Counts)<br>
> -      : Name(Name), Hash(Hash), Counts(std::move(Counts)), SIPE() {}<br>
>   StringRef Name;<br>
>   uint64_t Hash;<br>
>   std::vector<uint64_t> Counts;<br>
>   SoftInstrProfErrors SIPE;<br>
><br>
> +  InstrProfRecord() = default;<br>
> +  InstrProfRecord(StringRef Name, uint64_t Hash, std::vector<uint64_t> Counts)<br>
> +      : Name(Name), Hash(Hash), Counts(std::move(Counts)) {}<br>
> +<br>
>   typedef std::vector<std::pair<uint64_<wbr>t, uint64_t>> ValueMapType;<br>
><br>
>   /// Return the number of value profile kinds with non-zero number<br>
>   /// of profile sites.<br>
>   inline uint32_t getNumValueKinds() const;<br>
> +<br>
>   /// Return the number of instrumented sites for ValueKind.<br>
>   inline uint32_t getNumValueSites(uint32_t ValueKind) const;<br>
> +<br>
>   /// Return the total number of ValueData for ValueKind.<br>
>   inline uint32_t getNumValueData(uint32_t ValueKind) const;<br>
> +<br>
>   /// Return the number of value data collected for ValueKind at profiling<br>
>   /// site: Site.<br>
>   inline uint32_t getNumValueDataForSite(uint32_<wbr>t ValueKind,<br>
>                                          uint32_t Site) const;<br>
> +<br>
>   /// Return the array of profiled values at \p Site. If \p TotalC<br>
>   /// is not null, the total count of all target values at this site<br>
>   /// will be stored in \c *TotalC.<br>
>   inline std::unique_ptr<<wbr>InstrProfValueData[]><br>
>   getValueForSite(uint32_t ValueKind, uint32_t Site,<br>
> -                  uint64_t *TotalC = 0) const;<br>
> +                  uint64_t *TotalC = nullptr) const;<br>
> +<br>
>   /// Get the target value/counts of kind \p ValueKind collected at site<br>
>   /// \p Site and store the result in array \p Dest. Return the total<br>
>   /// counts of all target values at this site.<br>
>   inline uint64_t getValueForSite(<wbr>InstrProfValueData Dest[], uint32_t ValueKind,<br>
>                                   uint32_t Site) const;<br>
> +<br>
>   /// Reserve space for NumValueSites sites.<br>
>   inline void reserveSites(uint32_t ValueKind, uint32_t NumValueSites);<br>
> +<br>
>   /// Add ValueData for ValueKind at value Site.<br>
>   void addValueData(uint32_t ValueKind, uint32_t Site,<br>
>                     InstrProfValueData *VData, uint32_t N,<br>
> @@ -647,6 +683,7 @@ struct InstrProfRecord {<br>
> private:<br>
>   std::vector<<wbr>InstrProfValueSiteRecord> IndirectCallSites;<br>
>   const std::vector<<wbr>InstrProfValueSiteRecord> &<br>
> +<br>
>   getValueSitesForKind(uint32_t ValueKind) const {<br>
>     switch (ValueKind) {<br>
>     case IPVK_IndirectCallTarget:<br>
> @@ -672,6 +709,7 @@ private:<br>
>   // Scale merged value counts by \p Weight.<br>
>   void mergeValueProfData(uint32_t ValueKind, InstrProfRecord &Src,<br>
>                           uint64_t Weight);<br>
> +<br>
>   // Scale up value profile data count.<br>
>   void scaleValueProfData(uint32_t ValueKind, uint64_t Weight);<br>
> };<br>
> @@ -706,7 +744,7 @@ std::unique_ptr<<wbr>InstrProfValueData[]><br>
> InstrProfRecord::<wbr>getValueForSite(uint32_t ValueKind, uint32_t Site,<br>
>                                  uint64_t *TotalC) const {<br>
>   uint64_t Dummy;<br>
> -  uint64_t &TotalCount = (TotalC == 0 ? Dummy : *TotalC);<br>
> +  uint64_t &TotalCount = (TotalC == nullptr ? Dummy : *TotalC);<br>
>   uint32_t N = getNumValueDataForSite(<wbr>ValueKind, Site);<br>
>   if (N == 0) {<br>
>     TotalCount = 0;<br>
> @@ -762,7 +800,6 @@ namespace IndexedInstrProf {<br>
><br>
> enum class HashT : uint32_t {<br>
>   MD5,<br>
> -<br>
>   Last = MD5<br>
> };<br>
><br>
> @@ -816,7 +853,6 @@ struct Header {<br>
> // format. It is introduced in version 4. The summary data follows<br>
> // right after the profile file header.<br>
> struct Summary {<br>
> -<br>
>   struct Entry {<br>
>     uint64_t Cutoff; ///< The required percentile of total execution count.<br>
>     uint64_t<br>
> @@ -857,13 +893,16 @@ struct Summary {<br>
>   const uint64_t *getSummaryDataBase() const {<br>
>     return reinterpret_cast<const uint64_t *>(this + 1);<br>
>   }<br>
> +<br>
>   uint64_t *getSummaryDataBase() {<br>
>     return reinterpret_cast<uint64_t *>(this + 1);<br>
>   }<br>
> +<br>
>   const Entry *getCutoffEntryBase() const {<br>
>     return reinterpret_cast<const Entry *>(<br>
>         &getSummaryDataBase()[<wbr>NumSummaryFields]);<br>
>   }<br>
> +<br>
>   Entry *getCutoffEntryBase() {<br>
>     return reinterpret_cast<Entry *>(&getSummaryDataBase()[<wbr>NumSummaryFields]);<br>
>   }<br>
> @@ -877,6 +916,7 @@ struct Summary {<br>
>   }<br>
><br>
>   const Entry &getEntry(uint32_t I) const { return getCutoffEntryBase()[I]; }<br>
> +<br>
>   void setEntry(uint32_t I, const ProfileSummaryEntry &E) {<br>
>     Entry &ER = getCutoffEntryBase()[I];<br>
>     ER.Cutoff = E.Cutoff;<br>
> @@ -894,6 +934,7 @@ inline std::unique_ptr<Summary> allocSum<br>
>   return std::unique_ptr<Summary>(new (::operator new(TotalSize))<br>
>                                       Summary(TotalSize));<br>
> }<br>
> +<br>
> } // end namespace IndexedInstrProf<br>
><br>
> namespace RawInstrProf {<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ProfileData/InstrProfReader.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProfReader.h?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ProfileData/<wbr>InstrProfReader.h?rev=296846&<wbr>r1=296845&r2=296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ProfileData/InstrProfReader.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ProfileData/InstrProfReader.h Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- InstrProfReader.h - Instrumented profiling readers ----------*- C++ -*-=//<br>
> +//===- InstrProfReader.h - Instrumented profiling readers -------*- C++ -*-===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -16,14 +16,23 @@<br>
> #define LLVM_PROFILEDATA_<wbr>INSTRPROFREADER_H<br>
><br>
> #include "llvm/ADT/ArrayRef.h"<br>
> -#include "llvm/ADT/StringExtras.h"<br>
> +#include "llvm/ADT/StringRef.h"<br>
> +#include "llvm/IR/ProfileSummary.h"<br>
> #include "llvm/ProfileData/InstrProf.h"<br>
> -#include "llvm/Support/EndianStream.h"<br>
> +#include "llvm/Support/Endian.h"<br>
> +#include "llvm/Support/Error.h"<br>
> #include "llvm/Support/LineIterator.h"<br>
> #include "llvm/Support/MemoryBuffer.h"<br>
> #include "llvm/Support/OnDiskHashTable.<wbr>h"<br>
> -#include "llvm/Support/raw_ostream.h"<br>
> +#include "llvm/Support/SwapByteOrder.h"<br>
> +#include <algorithm><br>
> +#include <cassert><br>
> +#include <cstddef><br>
> +#include <cstdint><br>
> #include <iterator><br>
> +#include <memory><br>
> +#include <utility><br>
> +#include <vector><br>
><br>
> namespace llvm {<br>
><br>
> @@ -32,12 +41,13 @@ class InstrProfReader;<br>
> /// A file format agnostic iterator over profiling data.<br>
> class InstrProfIterator : public std::iterator<std::input_<wbr>iterator_tag,<br>
>                                                InstrProfRecord> {<br>
> -  InstrProfReader *Reader;<br>
> +  InstrProfReader *Reader = nullptr;<br>
>   InstrProfRecord Record;<br>
><br>
>   void Increment();<br>
> +<br>
> public:<br>
> -  InstrProfIterator() : Reader(nullptr) {}<br>
> +  InstrProfIterator() = default;<br>
>   InstrProfIterator(<wbr>InstrProfReader *Reader) : Reader(Reader) { Increment(); }<br>
><br>
>   InstrProfIterator &operator++() { Increment(); return *this; }<br>
> @@ -50,19 +60,22 @@ public:<br>
> /// Base class and interface for reading profiling data of any known instrprof<br>
> /// format. Provides an iterator over InstrProfRecords.<br>
> class InstrProfReader {<br>
> -  instrprof_error LastError;<br>
> +  instrprof_error LastError = instrprof_error::success;<br>
><br>
> public:<br>
> -  InstrProfReader() : LastError(instrprof_error::<wbr>success), Symtab() {}<br>
> -  virtual ~InstrProfReader() {}<br>
> +  InstrProfReader() = default;<br>
> +  virtual ~InstrProfReader() = default;<br>
><br>
>   /// Read the header.  Required before reading first record.<br>
>   virtual Error readHeader() = 0;<br>
> +<br>
>   /// Read a single record.<br>
>   virtual Error readNextRecord(InstrProfRecord &Record) = 0;<br>
> +<br>
>   /// Iterator over profile data.<br>
>   InstrProfIterator begin() { return InstrProfIterator(this); }<br>
>   InstrProfIterator end() { return InstrProfIterator(); }<br>
> +<br>
>   virtual bool isIRLevelProfile() const = 0;<br>
><br>
>   /// Return the PGO symtab. There are three different readers:<br>
> @@ -86,6 +99,7 @@ protected:<br>
>       return Error::success();<br>
>     return make_error<InstrProfError>(<wbr>Err);<br>
>   }<br>
> +<br>
>   Error error(Error E) { return error(InstrProfError::take(<wbr>std::move(E))); }<br>
><br>
>   /// Clear the current error and return a successful one.<br>
> @@ -94,8 +108,10 @@ protected:<br>
> public:<br>
>   /// Return true if the reader has finished reading the profile data.<br>
>   bool isEOF() { return LastError == instrprof_error::eof; }<br>
> +<br>
>   /// Return true if the reader encountered an error reading profiling data.<br>
>   bool hasError() { return LastError != instrprof_error::success && !isEOF(); }<br>
> +<br>
>   /// Get the current error.<br>
>   Error getError() {<br>
>     if (hasError())<br>
> @@ -125,16 +141,15 @@ private:<br>
>   std::unique_ptr<MemoryBuffer> DataBuffer;<br>
>   /// Iterator over the profile data.<br>
>   line_iterator Line;<br>
> -  bool IsIRLevelProfile;<br>
> +  bool IsIRLevelProfile = false;<br>
><br>
> -  TextInstrProfReader(const TextInstrProfReader &) = delete;<br>
> -  TextInstrProfReader &operator=(const TextInstrProfReader &) = delete;<br>
>   Error readValueProfileData(<wbr>InstrProfRecord &Record);<br>
><br>
> public:<br>
>   TextInstrProfReader(std::<wbr>unique_ptr<MemoryBuffer> DataBuffer_)<br>
> -      : DataBuffer(std::move(<wbr>DataBuffer_)), Line(*DataBuffer, true, '#'),<br>
> -        IsIRLevelProfile(false) {}<br>
> +      : DataBuffer(std::move(<wbr>DataBuffer_)), Line(*DataBuffer, true, '#') {}<br>
> +  TextInstrProfReader(const TextInstrProfReader &) = delete;<br>
> +  TextInstrProfReader &operator=(const TextInstrProfReader &) = delete;<br>
><br>
>   /// Return true if the given buffer is in text instrprof format.<br>
>   static bool hasFormat(const MemoryBuffer &Buffer);<br>
> @@ -143,6 +158,7 @@ public:<br>
><br>
>   /// Read the header.<br>
>   Error readHeader() override;<br>
> +<br>
>   /// Read a single record.<br>
>   Error readNextRecord(InstrProfRecord &Record) override;<br>
><br>
> @@ -184,15 +200,16 @@ private:<br>
><br>
>   InstrProfRecord::ValueMapType FunctionPtrToNameMap;<br>
><br>
> -  RawInstrProfReader(const RawInstrProfReader &) = delete;<br>
> -  RawInstrProfReader &operator=(const RawInstrProfReader &) = delete;<br>
> public:<br>
>   RawInstrProfReader(std::<wbr>unique_ptr<MemoryBuffer> DataBuffer)<br>
>       : DataBuffer(std::move(<wbr>DataBuffer)) { }<br>
> +  RawInstrProfReader(const RawInstrProfReader &) = delete;<br>
> +  RawInstrProfReader &operator=(const RawInstrProfReader &) = delete;<br>
><br>
>   static bool hasFormat(const MemoryBuffer &DataBuffer);<br>
>   Error readHeader() override;<br>
>   Error readNextRecord(InstrProfRecord &Record) override;<br>
> +<br>
>   bool isIRLevelProfile() const override {<br>
>     return (Version & VARIANT_MASK_IR_PROF) != 0;<br>
>   }<br>
> @@ -206,9 +223,11 @@ private:<br>
>   Error createSymtab(InstrProfSymtab &Symtab);<br>
>   Error readNextHeader(const char *CurrentPos);<br>
>   Error readHeader(const RawInstrProf::Header &Header);<br>
> +<br>
>   template <class IntT> IntT swap(IntT Int) const {<br>
>     return ShouldSwapBytes ? sys::getSwappedBytes(Int) : Int;<br>
>   }<br>
> +<br>
>   support::endianness getDataEndianness() const {<br>
>     support::endianness HostEndian = getHostEndianness();<br>
>     if (!ShouldSwapBytes)<br>
> @@ -222,15 +241,18 @@ private:<br>
>   inline uint8_t getNumPaddingBytes(uint64_t SizeInBytes) {<br>
>     return 7 & (sizeof(uint64_t) - SizeInBytes % sizeof(uint64_t));<br>
>   }<br>
> +<br>
>   Error readName(InstrProfRecord &Record);<br>
>   Error readFuncHash(InstrProfRecord &Record);<br>
>   Error readRawCounts(InstrProfRecord &Record);<br>
>   Error readValueProfilingData(<wbr>InstrProfRecord &Record);<br>
>   bool atEnd() const { return Data == DataEnd; }<br>
> +<br>
>   void advanceData() {<br>
>     Data++;<br>
>     ValueDataStart += CurValueDataSize;<br>
>   }<br>
> +<br>
>   const char *getNextHeaderPos() const {<br>
>       assert(atEnd());<br>
>       return (const char *)ValueDataStart;<br>
> @@ -240,6 +262,7 @@ private:<br>
>     ptrdiff_t Offset = (swap(CounterPtr) - CountersDelta) / sizeof(uint64_t);<br>
>     return CountersStart + Offset;<br>
>   }<br>
> +<br>
>   StringRef getName(uint64_t NameRef) const {<br>
>     return Symtab->getFuncName(swap(<wbr>NameRef));<br>
>   }<br>
> @@ -249,8 +272,10 @@ typedef RawInstrProfReader<uint32_t> Raw<br>
> typedef RawInstrProfReader<uint64_t> RawInstrProfReader64;<br>
><br>
> namespace IndexedInstrProf {<br>
> +<br>
> enum class HashT : uint32_t;<br>
> -}<br>
> +<br>
> +} // end namespace IndexedInstrProf<br>
><br>
> /// Trait for lookups into the on-disk hash table for the binary instrprof<br>
> /// format.<br>
> @@ -261,12 +286,11 @@ class InstrProfLookupTrait {<br>
>   // Endianness of the input value profile data.<br>
>   // It should be LE by default, but can be changed<br>
>   // for testing purpose.<br>
> -  support::endianness ValueProfDataEndianness;<br>
> +  support::endianness ValueProfDataEndianness = support::little;<br>
><br>
> public:<br>
>   InstrProfLookupTrait(<wbr>IndexedInstrProf::HashT HashType, unsigned FormatVersion)<br>
> -      : HashType(HashType), FormatVersion(FormatVersion),<br>
> -        ValueProfDataEndianness(<wbr>support::little) {}<br>
> +      : HashType(HashType), FormatVersion(FormatVersion) {}<br>
><br>
>   typedef ArrayRef<InstrProfRecord> data_type;<br>
><br>
> @@ -284,6 +308,7 @@ public:<br>
>   static std::pair<offset_type, offset_type><br>
>   ReadKeyDataLength(const unsigned char *&D) {<br>
>     using namespace support;<br>
> +<br>
>     offset_type KeyLen = endian::readNext<offset_type, little, unaligned>(D);<br>
>     offset_type DataLen = endian::readNext<offset_type, little, unaligned>(D);<br>
>     return std::make_pair(KeyLen, DataLen);<br>
> @@ -304,16 +329,18 @@ public:<br>
> };<br>
><br>
> struct InstrProfReaderIndexBase {<br>
> +  virtual ~InstrProfReaderIndexBase() = default;<br>
> +<br>
>   // Read all the profile records with the same key pointed to the current<br>
>   // iterator.<br>
>   virtual Error getRecords(ArrayRef<<wbr>InstrProfRecord> &Data) = 0;<br>
> +<br>
>   // Read all the profile records with the key equal to FuncName<br>
>   virtual Error getRecords(StringRef FuncName,<br>
>                                      ArrayRef<InstrProfRecord> &Data) = 0;<br>
>   virtual void advanceToNextKey() = 0;<br>
>   virtual bool atEnd() const = 0;<br>
>   virtual void setValueProfDataEndianness(<wbr>support::endianness Endianness) = 0;<br>
> -  virtual ~InstrProfReaderIndexBase() {}<br>
>   virtual uint64_t getVersion() const = 0;<br>
>   virtual bool isIRLevelProfile() const = 0;<br>
>   virtual void populateSymtab(InstrProfSymtab &) = 0;<br>
> @@ -335,22 +362,27 @@ public:<br>
>                        const unsigned char *const Payload,<br>
>                        const unsigned char *const Base,<br>
>                        IndexedInstrProf::HashT HashType, uint64_t Version);<br>
> +  ~InstrProfReaderIndex() override = default;<br>
><br>
>   Error getRecords(ArrayRef<<wbr>InstrProfRecord> &Data) override;<br>
>   Error getRecords(StringRef FuncName,<br>
>                    ArrayRef<InstrProfRecord> &Data) override;<br>
>   void advanceToNextKey() override { RecordIterator++; }<br>
> +<br>
>   bool atEnd() const override {<br>
>     return RecordIterator == HashTable->data_end();<br>
>   }<br>
> +<br>
>   void setValueProfDataEndianness(<wbr>support::endianness Endianness) override {<br>
>     HashTable->getInfoObj().<wbr>setValueProfDataEndianness(<wbr>Endianness);<br>
>   }<br>
> -  ~InstrProfReaderIndex() override {}<br>
> +<br>
>   uint64_t getVersion() const override { return GET_VERSION(FormatVersion); }<br>
> +<br>
>   bool isIRLevelProfile() const override {<br>
>     return (FormatVersion & VARIANT_MASK_IR_PROF) != 0;<br>
>   }<br>
> +<br>
>   void populateSymtab(InstrProfSymtab &Symtab) override {<br>
>     Symtab.create(HashTable->keys(<wbr>));<br>
>   }<br>
> @@ -366,20 +398,20 @@ private:<br>
>   /// Profile summary data.<br>
>   std::unique_ptr<<wbr>ProfileSummary> Summary;<br>
><br>
> -  IndexedInstrProfReader(const IndexedInstrProfReader &) = delete;<br>
> -  IndexedInstrProfReader &operator=(const IndexedInstrProfReader &) = delete;<br>
> -<br>
>   // Read the profile summary. Return a pointer pointing to one byte past the<br>
>   // end of the summary data if it exists or the input \c Cur.<br>
>   const unsigned char *readSummary(IndexedInstrProf:<wbr>:ProfVersion Version,<br>
>                                    const unsigned char *Cur);<br>
><br>
> public:<br>
> +  IndexedInstrProfReader(std::<wbr>unique_ptr<MemoryBuffer> DataBuffer)<br>
> +      : DataBuffer(std::move(<wbr>DataBuffer)) {}<br>
> +  IndexedInstrProfReader(const IndexedInstrProfReader &) = delete;<br>
> +  IndexedInstrProfReader &operator=(const IndexedInstrProfReader &) = delete;<br>
> +<br>
>   /// Return the profile version.<br>
>   uint64_t getVersion() const { return Index->getVersion(); }<br>
>   bool isIRLevelProfile() const override { return Index->isIRLevelProfile(); }<br>
> -  IndexedInstrProfReader(std::<wbr>unique_ptr<MemoryBuffer> DataBuffer)<br>
> -      : DataBuffer(std::move(<wbr>DataBuffer)), Index(nullptr) {}<br>
><br>
>   /// Return true if the given buffer is in an indexed instrprof format.<br>
>   static bool hasFormat(const MemoryBuffer &DataBuffer);<br>
> @@ -422,4 +454,4 @@ public:<br>
><br>
> } // end namespace llvm<br>
><br>
> -#endif<br>
> +#endif // LLVM_PROFILEDATA_<wbr>INSTRPROFREADER_H<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ProfileData/InstrProfWriter.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProfWriter.h?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ProfileData/<wbr>InstrProfWriter.h?rev=296846&<wbr>r1=296845&r2=296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ProfileData/InstrProfWriter.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ProfileData/InstrProfWriter.h Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- InstrProfWriter.h - Instrumented profiling writer -----------*- C++ -*-=//<br>
> +//===- InstrProfWriter.h - Instrumented profiling writer --------*- C++ -*-===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -16,16 +16,19 @@<br>
> #define LLVM_PROFILEDATA_<wbr>INSTRPROFWRITER_H<br>
><br>
> #include "llvm/ADT/DenseMap.h"<br>
> +#include "llvm/ADT/StringMap.h"<br>
> #include "llvm/ProfileData/InstrProf.h"<br>
> -#include "llvm/Support/DataTypes.h"<br>
> +#include "llvm/Support/Endian.h"<br>
> +#include "llvm/Support/Error.h"<br>
> #include "llvm/Support/MemoryBuffer.h"<br>
> -#include "llvm/Support/raw_ostream.h"<br>
> +#include <cstdint><br>
> +#include <memory><br>
><br>
> namespace llvm {<br>
><br>
> /// Writer for instrumentation based profile data.<br>
> -class ProfOStream;<br>
> class InstrProfRecordWriterTrait;<br>
> +class ProfOStream;<br>
><br>
> class InstrProfWriter {<br>
> public:<br>
> @@ -35,7 +38,7 @@ public:<br>
> private:<br>
>   bool Sparse;<br>
>   StringMap<ProfilingData> FunctionData;<br>
> -  ProfKind ProfileKind;<br>
> +  ProfKind ProfileKind = PF_Unknown;<br>
>   // Use raw pointer here for the incomplete type object.<br>
>   InstrProfRecordWriterTrait *InfoObj;<br>
><br>
> @@ -47,15 +50,20 @@ public:<br>
>   /// for this function and the hash and number of counts match, each counter is<br>
>   /// summed. Optionally scale counts by \p Weight.<br>
>   Error addRecord(InstrProfRecord &&I, uint64_t Weight = 1);<br>
> +<br>
>   /// Merge existing function counts from the given writer.<br>
>   Error mergeRecordsFromWriter(<wbr>InstrProfWriter &&IPW);<br>
> +<br>
>   /// Write the profile to \c OS<br>
>   void write(raw_fd_ostream &OS);<br>
> +<br>
>   /// Write the profile in text format to \c OS<br>
>   void writeText(raw_fd_ostream &OS);<br>
> +<br>
>   /// Write \c Record in text format to \c OS<br>
>   static void writeRecordInText(const InstrProfRecord &Record,<br>
>                                 InstrProfSymtab &Symtab, raw_fd_ostream &OS);<br>
> +<br>
>   /// Write the profile, returning the raw data. For testing.<br>
>   std::unique_ptr<MemoryBuffer> writeBuffer();<br>
><br>
> @@ -82,4 +90,4 @@ private:<br>
><br>
> } // end namespace llvm<br>
><br>
> -#endif<br>
> +#endif // LLVM_PROFILEDATA_<wbr>INSTRPROFWRITER_H<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ProfileData/ProfileCommon.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/ProfileCommon.h?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ProfileData/<wbr>ProfileCommon.h?rev=296846&r1=<wbr>296845&r2=296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ProfileData/ProfileCommon.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ProfileData/ProfileCommon.h Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//===-- ProfileCommon.h - Common profiling APIs. ----------------*- C++ -*-===//<br>
> +//===- ProfileCommon.h - Common profiling APIs. -----------------*- C++ -*-===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -12,38 +12,33 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> -#ifndef LLVM_PROFILEDATA_PROFILE_<wbr>COMMON_H<br>
> -#define LLVM_PROFILEDATA_PROFILE_<wbr>COMMON_H<br>
> +#ifndef LLVM_PROFILEDATA_<wbr>PROFILECOMMON_H<br>
> +#define LLVM_PROFILEDATA_<wbr>PROFILECOMMON_H<br>
><br>
> +#include "llvm/ADT/ArrayRef.h"<br>
> +#include "llvm/IR/ProfileSummary.h"<br>
> +#include "llvm/Support/Error.h"<br>
> +#include <algorithm><br>
> #include <cstdint><br>
> #include <functional><br>
> #include <map><br>
> -#include <utility><br>
> +#include <memory><br>
> #include <vector><br>
><br>
> -#include "llvm/IR/ProfileSummary.h"<br>
> -#include "llvm/Support/Error.h"<br>
> -#include "llvm/ADT/ArrayRef.h"<br>
> -<br>
> namespace llvm {<br>
> -class Function;<br>
> -namespace IndexedInstrProf {<br>
> -struct Summary;<br>
> -}<br>
> +<br>
> +struct InstrProfRecord;<br>
> +<br>
> namespace sampleprof {<br>
> +<br>
> class FunctionSamples;<br>
> -}<br>
> -struct InstrProfRecord;<br>
> -class LLVMContext;<br>
> -class Metadata;<br>
> -class MDTuple;<br>
> -class MDNode;<br>
> +<br>
> +} // end namespace sampleprof<br>
><br>
> inline const char *getHotSectionPrefix() { return ".hot"; }<br>
> inline const char *getUnlikelySectionPrefix() { return ".unlikely"; }<br>
><br>
> class ProfileSummaryBuilder {<br>
> -<br>
> private:<br>
>   /// We keep track of the number of times a count (block count or samples)<br>
>   /// appears in the profile. The map is kept sorted in the descending order of<br>
> @@ -53,13 +48,18 @@ private:<br>
><br>
> protected:<br>
>   SummaryEntryVector DetailedSummary;<br>
> +  uint64_t TotalCount = 0;<br>
> +  uint64_t MaxCount = 0;<br>
> +  uint64_t MaxFunctionCount = 0;<br>
> +  uint32_t NumCounts = 0;<br>
> +  uint32_t NumFunctions = 0;<br>
> +<br>
>   ProfileSummaryBuilder(std::<wbr>vector<uint32_t> Cutoffs)<br>
>       : DetailedSummaryCutoffs(std::<wbr>move(Cutoffs)) {}<br>
> -  inline void addCount(uint64_t Count);<br>
>   ~ProfileSummaryBuilder() = default;<br>
> +<br>
> +  inline void addCount(uint64_t Count);<br>
>   void computeDetailedSummary();<br>
> -  uint64_t TotalCount = 0, MaxCount = 0, MaxFunctionCount = 0;<br>
> -  uint32_t NumCounts = 0, NumFunctions = 0;<br>
><br>
> public:<br>
>   /// \brief A vector of useful cutoff values for detailed summary.<br>
> @@ -68,22 +68,24 @@ public:<br>
><br>
> class InstrProfSummaryBuilder final : public ProfileSummaryBuilder {<br>
>   uint64_t MaxInternalBlockCount = 0;<br>
> +<br>
>   inline void addEntryCount(uint64_t Count);<br>
>   inline void addInternalCount(uint64_t Count);<br>
><br>
> public:<br>
>   InstrProfSummaryBuilder(std::<wbr>vector<uint32_t> Cutoffs)<br>
>       : ProfileSummaryBuilder(std::<wbr>move(Cutoffs)) {}<br>
> +<br>
>   void addRecord(const InstrProfRecord &);<br>
>   std::unique_ptr<<wbr>ProfileSummary> getSummary();<br>
> };<br>
><br>
> class SampleProfileSummaryBuilder final : public ProfileSummaryBuilder {<br>
> -<br>
> public:<br>
> -  void addRecord(const sampleprof::FunctionSamples &FS);<br>
>   SampleProfileSummaryBuilder(<wbr>std::vector<uint32_t> Cutoffs)<br>
>       : ProfileSummaryBuilder(std::<wbr>move(Cutoffs)) {}<br>
> +<br>
> +  void addRecord(const sampleprof::FunctionSamples &FS);<br>
>   std::unique_ptr<<wbr>ProfileSummary> getSummary();<br>
> };<br>
><br>
> @@ -96,6 +98,6 @@ void ProfileSummaryBuilder::<wbr>addCount(uin<br>
>   CountFrequencies[Count]++;<br>
> }<br>
><br>
> -<br>
> } // end namespace llvm<br>
> -#endif<br>
> +<br>
> +#endif // LLVM_PROFILEDATA_<wbr>PROFILECOMMON_H<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ProfileData/SampleProf.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/SampleProf.h?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ProfileData/SampleProf.h?<wbr>rev=296846&r1=296845&r2=<wbr>296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ProfileData/SampleProf.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ProfileData/SampleProf.h Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- SampleProf.h - Sampling profiling format support --------------------===//<br>
> +//===- SampleProf.h - Sampling profiling format support ---------*- C++ -*-===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -12,23 +12,30 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> -#ifndef LLVM_PROFILEDATA_SAMPLEPROF_H_<br>
> -#define LLVM_PROFILEDATA_SAMPLEPROF_H_<br>
> +#ifndef LLVM_PROFILEDATA_SAMPLEPROF_H<br>
> +#define LLVM_PROFILEDATA_SAMPLEPROF_H<br>
><br>
> #include "llvm/ADT/DenseSet.h"<br>
> #include "llvm/ADT/SmallVector.h"<br>
> #include "llvm/ADT/StringMap.h"<br>
> +#include "llvm/ADT/StringRef.h"<br>
> +#include "llvm/IR/Function.h"<br>
> #include "llvm/IR/GlobalValue.h"<br>
> #include "llvm/IR/Module.h"<br>
> #include "llvm/Support/Debug.h"<br>
> #include "llvm/Support/ErrorOr.h"<br>
> -#include "llvm/Support/raw_ostream.h"<br>
> -<br>
> +#include "llvm/Support/MathExtras.h"<br>
> +#include <algorithm><br>
> +#include <cstdint><br>
> #include <map><br>
> +#include <string><br>
> #include <system_error><br>
> +#include <utility><br>
><br>
> namespace llvm {<br>
><br>
> +class raw_ostream;<br>
> +<br>
> const std::error_category &sampleprof_category();<br>
><br>
> enum class sampleprof_error {<br>
> @@ -62,12 +69,13 @@ inline sampleprof_error MergeResult(samp<br>
> } // end namespace llvm<br>
><br>
> namespace std {<br>
> +<br>
> template <><br>
> struct is_error_code_enum<llvm::<wbr>sampleprof_error> : std::true_type {};<br>
> -}<br>
><br>
> -namespace llvm {<br>
> +} // end namespace std<br>
><br>
> +namespace llvm {<br>
> namespace sampleprof {<br>
><br>
> static inline uint64_t SPMagic() {<br>
> @@ -90,8 +98,10 @@ static inline uint64_t SPVersion() { ret<br>
> /// (e.g., the two post-increment instructions in "if (p) x++; else y++;").<br>
> struct LineLocation {<br>
>   LineLocation(uint32_t L, uint32_t D) : LineOffset(L), Discriminator(D) {}<br>
> +<br>
>   void print(raw_ostream &OS) const;<br>
>   void dump() const;<br>
> +<br>
>   bool operator<(const LineLocation &O) const {<br>
>     return LineOffset < O.LineOffset ||<br>
>            (LineOffset == O.LineOffset && Discriminator < O.Discriminator);<br>
> @@ -117,7 +127,7 @@ class SampleRecord {<br>
> public:<br>
>   typedef StringMap<uint64_t> CallTargetMap;<br>
><br>
> -  SampleRecord() : NumSamples(0), CallTargets() {}<br>
> +  SampleRecord() = default;<br>
><br>
>   /// Increment the number of samples for this record by \p S.<br>
>   /// Optionally scale sample count \p S by \p Weight.<br>
> @@ -147,7 +157,7 @@ public:<br>
>   }<br>
><br>
>   /// Return true if this sample record contains function calls.<br>
> -  bool hasCalls() const { return CallTargets.size() > 0; }<br>
> +  bool hasCalls() const { return !CallTargets.empty(); }<br>
><br>
>   uint64_t getSamples() const { return NumSamples; }<br>
>   const CallTargetMap &getCallTargets() const { return CallTargets; }<br>
> @@ -166,7 +176,7 @@ public:<br>
>   void dump() const;<br>
><br>
> private:<br>
> -  uint64_t NumSamples;<br>
> +  uint64_t NumSamples = 0;<br>
>   CallTargetMap CallTargets;<br>
> };<br>
><br>
> @@ -183,9 +193,11 @@ typedef std::map<LineLocation, FunctionS<br>
> /// within the body of the function.<br>
> class FunctionSamples {<br>
> public:<br>
> -  FunctionSamples() : Name(), TotalSamples(0), TotalHeadSamples(0) {}<br>
> +  FunctionSamples() = default;<br>
> +<br>
>   void print(raw_ostream &OS = dbgs(), unsigned Indent = 0) const;<br>
>   void dump() const;<br>
> +<br>
>   sampleprof_error addTotalSamples(uint64_t Num, uint64_t Weight = 1) {<br>
>     bool Overflowed;<br>
>     TotalSamples =<br>
> @@ -193,6 +205,7 @@ public:<br>
>     return Overflowed ? sampleprof_error::counter_<wbr>overflow<br>
>                       : sampleprof_error::success;<br>
>   }<br>
> +<br>
>   sampleprof_error addHeadSamples(uint64_t Num, uint64_t Weight = 1) {<br>
>     bool Overflowed;<br>
>     TotalHeadSamples =<br>
> @@ -200,11 +213,13 @@ public:<br>
>     return Overflowed ? sampleprof_error::counter_<wbr>overflow<br>
>                       : sampleprof_error::success;<br>
>   }<br>
> +<br>
>   sampleprof_error addBodySamples(uint32_t LineOffset, uint32_t Discriminator,<br>
>                                   uint64_t Num, uint64_t Weight = 1) {<br>
>     return BodySamples[LineLocation(<wbr>LineOffset, Discriminator)].addSamples(<br>
>         Num, Weight);<br>
>   }<br>
> +<br>
>   sampleprof_error addCalledTargetSamples(uint32_<wbr>t LineOffset,<br>
>                                           uint32_t Discriminator,<br>
>                                           const std::string &FName,<br>
> @@ -331,12 +346,12 @@ private:<br>
>   ///<br>
>   /// Samples are cumulative, they include all the samples collected<br>
>   /// inside this function and all its inlined callees.<br>
> -  uint64_t TotalSamples;<br>
> +  uint64_t TotalSamples = 0;<br>
><br>
>   /// Total number of samples collected at the head of the function.<br>
>   /// This is an approximation of the number of calls made to this function<br>
>   /// at runtime.<br>
> -  uint64_t TotalHeadSamples;<br>
> +  uint64_t TotalHeadSamples = 0;<br>
><br>
>   /// Map instruction locations to collected samples.<br>
>   ///<br>
> @@ -383,6 +398,7 @@ public:<br>
>                        return A->first < B->first;<br>
>                      });<br>
>   }<br>
> +<br>
>   const SamplesWithLocList &get() const { return V; }<br>
><br>
> private:<br>
> @@ -390,7 +406,6 @@ private:<br>
> };<br>
><br>
> } // end namespace sampleprof<br>
> -<br>
> } // end namespace llvm<br>
><br>
> -#endif // LLVM_PROFILEDATA_SAMPLEPROF_H_<br>
> +#endif // LLVM_PROFILEDATA_SAMPLEPROF_H<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ProfileData/SampleProfReader.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/SampleProfReader.h?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ProfileData/<wbr>SampleProfReader.h?rev=296846&<wbr>r1=296845&r2=296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ProfileData/SampleProfReader.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ProfileData/SampleProfReader.h Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//===- SampleProfReader.h - Read LLVM sample profile data -----------------===//<br>
> +//===- SampleProfReader.h - Read LLVM sample profile data -------*- C++ -*-===//<br>
> //<br>
> //                      The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -205,26 +205,34 @@<br>
> //        FUNCTION BODY<br>
> //          A FUNCTION BODY entry describing the inlined function.<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
> +<br>
> #ifndef LLVM_PROFILEDATA_<wbr>SAMPLEPROFREADER_H<br>
> #define LLVM_PROFILEDATA_<wbr>SAMPLEPROFREADER_H<br>
><br>
> +#include "llvm/ADT/SmallVector.h"<br>
> #include "llvm/ADT/StringMap.h"<br>
> #include "llvm/ADT/StringRef.h"<br>
> #include "llvm/ADT/Twine.h"<br>
> #include "llvm/IR/DiagnosticInfo.h"<br>
> #include "llvm/IR/Function.h"<br>
> #include "llvm/IR/LLVMContext.h"<br>
> -#include "llvm/ProfileData/<wbr>ProfileCommon.h"<br>
> +#include "llvm/IR/ProfileSummary.h"<br>
> #include "llvm/ProfileData/SampleProf.<wbr>h"<br>
> #include "llvm/Support/Debug.h"<br>
> -#include "llvm/Support/ErrorHandling.h"<br>
> #include "llvm/Support/ErrorOr.h"<br>
> #include "llvm/Support/GCOV.h"<br>
> #include "llvm/Support/MemoryBuffer.h"<br>
> -#include "llvm/Support/raw_ostream.h"<br>
> +#include <algorithm><br>
> +#include <cstdint><br>
> +#include <memory><br>
> +#include <string><br>
> +#include <system_error><br>
> +#include <vector><br>
><br>
> namespace llvm {<br>
><br>
> +class raw_ostream;<br>
> +<br>
> namespace sampleprof {<br>
><br>
> /// \brief Sample-based profile reader.<br>
> @@ -259,7 +267,7 @@ public:<br>
>   SampleProfileReader(std::<wbr>unique_ptr<MemoryBuffer> B, LLVMContext &C)<br>
>       : Profiles(0), Ctx(C), Buffer(std::move(B)) {}<br>
><br>
> -  virtual ~SampleProfileReader() {}<br>
> +  virtual ~SampleProfileReader() = default;<br>
><br>
>   /// \brief Read and validate the file header.<br>
>   virtual std::error_code readHeader() = 0;<br>
> @@ -442,8 +450,8 @@ protected:<br>
>   static const uint32_t GCOVTagAFDOFunction = 0xac000000;<br>
> };<br>
><br>
> -} // End namespace sampleprof<br>
> +} // end namespace sampleprof<br>
><br>
> -} // End namespace llvm<br>
> +} // end namespace llvm<br>
><br>
> #endif // LLVM_PROFILEDATA_<wbr>SAMPLEPROFREADER_H<br>
><br>
> Modified: llvm/trunk/include/llvm/<wbr>ProfileData/SampleProfWriter.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/SampleProfWriter.h?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/ProfileData/<wbr>SampleProfWriter.h?rev=296846&<wbr>r1=296845&r2=296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/include/llvm/<wbr>ProfileData/SampleProfWriter.h (original)<br>
> +++ llvm/trunk/include/llvm/<wbr>ProfileData/SampleProfWriter.h Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//===- SampleProfWriter.h - Write LLVM sample profile data ----------------===//<br>
> +//===- SampleProfWriter.h - Write LLVM sample profile data ------*- C++ -*-===//<br>
> //<br>
> //                      The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -14,15 +14,18 @@<br>
> #define LLVM_PROFILEDATA_<wbr>SAMPLEPROFWRITER_H<br>
><br>
> #include "llvm/ADT/MapVector.h"<br>
> +#include "llvm/ADT/StringMap.h"<br>
> #include "llvm/ADT/StringRef.h"<br>
> -#include "llvm/ProfileData/<wbr>ProfileCommon.h"<br>
> +#include "llvm/IR/ProfileSummary.h"<br>
> #include "llvm/ProfileData/SampleProf.<wbr>h"<br>
> #include "llvm/Support/ErrorOr.h"<br>
> -#include "llvm/Support/FileSystem.h"<br>
> #include "llvm/Support/raw_ostream.h"<br>
> +#include <algorithm><br>
> +#include <cstdint><br>
> +#include <memory><br>
> +#include <system_error><br>
><br>
> namespace llvm {<br>
> -<br>
> namespace sampleprof {<br>
><br>
> enum SampleProfileFormat { SPF_None = 0, SPF_Text, SPF_Binary, SPF_GCC };<br>
> @@ -30,7 +33,7 @@ enum SampleProfileFormat { SPF_None = 0,<br>
> /// \brief Sample-based profile writer. Base class.<br>
> class SampleProfileWriter {<br>
> public:<br>
> -  virtual ~SampleProfileWriter() {}<br>
> +  virtual ~SampleProfileWriter() = default;<br>
><br>
>   /// Write sample profiles in \p S.<br>
>   ///<br>
> @@ -114,7 +117,7 @@ public:<br>
><br>
> protected:<br>
>   SampleProfileWriterBinary(std:<wbr>:unique_ptr<raw_ostream> &OS)<br>
> -      : SampleProfileWriter(OS), NameTable() {}<br>
> +      : SampleProfileWriter(OS) {}<br>
><br>
>   std::error_code<br>
>   writeHeader(const StringMap<FunctionSamples> &ProfileMap) override;<br>
> @@ -133,8 +136,7 @@ private:<br>
>                               SampleProfileFormat Format);<br>
> };<br>
><br>
> -} // End namespace sampleprof<br>
> -<br>
> -} // End namespace llvm<br>
> +} // end namespace sampleprof<br>
> +} // end namespace llvm<br>
><br>
> #endif // LLVM_PROFILEDATA_<wbr>SAMPLEPROFWRITER_H<br>
><br>
> Modified: llvm/trunk/lib/ProfileData/<wbr>Coverage/CoverageMapping.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/Coverage/CoverageMapping.cpp?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ProfileData/Coverage/<wbr>CoverageMapping.cpp?rev=<wbr>296846&r1=296845&r2=296846&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/ProfileData/<wbr>Coverage/CoverageMapping.cpp (original)<br>
> +++ llvm/trunk/lib/ProfileData/<wbr>Coverage/CoverageMapping.cpp Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- CoverageMapping.cpp - Code coverage mapping support ---------*- C++ -*-=//<br>
> +//===- CoverageMapping.cpp - Code coverage mapping support ------*- C++ -*-===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -12,18 +12,32 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> -#include "llvm/ProfileData/Coverage/<wbr>CoverageMapping.h"<br>
> +#include "llvm/ADT/ArrayRef.h"<br>
> #include "llvm/ADT/DenseMap.h"<br>
> +#include "llvm/ADT/None.h"<br>
> #include "llvm/ADT/Optional.h"<br>
> #include "llvm/ADT/SmallBitVector.h"<br>
> +#include "llvm/ADT/SmallVector.h"<br>
> +#include "llvm/ADT/StringRef.h"<br>
> +#include "llvm/ProfileData/Coverage/<wbr>CoverageMapping.h"<br>
> #include "llvm/ProfileData/Coverage/<wbr>CoverageMappingReader.h"<br>
> #include "llvm/ProfileData/<wbr>InstrProfReader.h"<br>
> #include "llvm/Support/Debug.h"<br>
> #include "llvm/Support/Errc.h"<br>
> +#include "llvm/Support/Error.h"<br>
> #include "llvm/Support/ErrorHandling.h"<br>
> #include "llvm/Support/ManagedStatic.h"<br>
> -#include "llvm/Support/Path.h"<br>
> +#include "llvm/Support/MemoryBuffer.h"<br>
> #include "llvm/Support/raw_ostream.h"<br>
> +#include <algorithm><br>
> +#include <cassert><br>
> +#include <cstdint><br>
> +#include <iterator><br>
> +#include <memory><br>
> +#include <string><br>
> +#include <system_error><br>
> +#include <utility><br>
> +#include <vector><br>
><br>
> using namespace llvm;<br>
> using namespace coverage;<br>
> @@ -59,7 +73,7 @@ void CounterExpressionBuilder::<wbr>extractTe<br>
><br>
> Counter CounterExpressionBuilder::<wbr>simplify(Counter ExpressionTree) {<br>
>   // Gather constant terms.<br>
> -  llvm::SmallVector<std::pair<<wbr>unsigned, int>, 32> Terms;<br>
> +  SmallVector<std::pair<<wbr>unsigned, int>, 32> Terms;<br>
>   extractTerms(ExpressionTree, +1, Terms);<br>
><br>
>   // If there are no terms, this is just a zero. The algorithm below assumes at<br>
> @@ -120,8 +134,7 @@ Counter CounterExpressionBuilder::<wbr>subtra<br>
>       get(CounterExpression(<wbr>CounterExpression::Subtract, LHS, RHS)));<br>
> }<br>
><br>
> -void CounterMappingContext::dump(<wbr>const Counter &C,<br>
> -                                 llvm::raw_ostream &OS) const {<br>
> +void CounterMappingContext::dump(<wbr>const Counter &C, raw_ostream &OS) const {<br>
>   switch (C.getKind()) {<br>
>   case Counter::Zero:<br>
>     OS << '0';<br>
> @@ -145,7 +158,7 @@ void CounterMappingContext::dump(<wbr>const C<br>
>     return;<br>
>   Expected<int64_t> Value = evaluate(C);<br>
>   if (auto E = Value.takeError()) {<br>
> -    llvm::consumeError(std::move(<wbr>E));<br>
> +    consumeError(std::move(E));<br>
>     return;<br>
>   }<br>
>   OS << '[' << *Value << ']';<br>
> @@ -217,7 +230,7 @@ Error CoverageMapping::<wbr>loadFunctionRecor<br>
>   for (const auto &Region : Record.MappingRegions) {<br>
>     Expected<int64_t> ExecutionCount = Ctx.evaluate(Region.Count);<br>
>     if (auto E = ExecutionCount.takeError()) {<br>
> -      llvm::consumeError(std::move(<wbr>E));<br>
> +      consumeError(std::move(E));<br>
>       return Error::success();<br>
>     }<br>
>     Function.pushRegion(Region, *ExecutionCount);<br>
> @@ -281,6 +294,7 @@ CoverageMapping::load(<wbr>ArrayRef<StringRef<br>
> }<br>
><br>
> namespace {<br>
> +<br>
> /// \brief Distributes functions into instantiation sets.<br>
> ///<br>
> /// An instantiation set is a collection of functions that have the same source<br>
> @@ -326,7 +340,7 @@ class SegmentBuilder {<br>
>       Segments.pop_back();<br>
>     DEBUG(dbgs() << "Segment at " << Line << ":" << Col);<br>
>     // Set this region's count.<br>
> -    if (Region.Kind != coverage::<wbr>CounterMappingRegion::<wbr>SkippedRegion) {<br>
> +    if (Region.Kind != CounterMappingRegion::<wbr>SkippedRegion) {<br>
>       DEBUG(dbgs() << " with count " << Region.ExecutionCount);<br>
>       Segments.emplace_back(Line, Col, Region.ExecutionCount, IsRegionEntry);<br>
>     } else<br>
> @@ -380,10 +394,10 @@ class SegmentBuilder {<br>
>       // in combineRegions(). Because we accumulate counter values only from<br>
>       // regions of the same kind as the first region of the area, prefer<br>
>       // CodeRegion to ExpansionRegion and ExpansionRegion to SkippedRegion.<br>
> -      static_assert(coverage::<wbr>CounterMappingRegion::<wbr>CodeRegion <<br>
> -                            coverage::<wbr>CounterMappingRegion::<wbr>ExpansionRegion &&<br>
> -                        coverage::<wbr>CounterMappingRegion::<wbr>ExpansionRegion <<br>
> -                            coverage::<wbr>CounterMappingRegion::<wbr>SkippedRegion,<br>
> +      static_assert(<wbr>CounterMappingRegion::<wbr>CodeRegion <<br>
> +                            CounterMappingRegion::<wbr>ExpansionRegion &&<br>
> +                        CounterMappingRegion::<wbr>ExpansionRegion <<br>
> +                            CounterMappingRegion::<wbr>SkippedRegion,<br>
>                     "Unexpected order of region kind values");<br>
>       return LHS.Kind < RHS.Kind;<br>
>     });<br>
> @@ -437,7 +451,8 @@ public:<br>
>     return Segments;<br>
>   }<br>
> };<br>
> -}<br>
> +<br>
> +} // end anonymous namespace<br>
><br>
> std::vector<StringRef> CoverageMapping::<wbr>getUniqueSourceFiles() const {<br>
>   std::vector<StringRef> Filenames;<br>
> @@ -487,7 +502,7 @@ static bool isExpansion(const CountedReg<br>
><br>
> CoverageData CoverageMapping::<wbr>getCoverageForFile(StringRef Filename) const {<br>
>   CoverageData FileCoverage(Filename);<br>
> -  std::vector<coverage::<wbr>CountedRegion> Regions;<br>
> +  std::vector<CountedRegion> Regions;<br>
><br>
>   for (const auto &Function : Functions) {<br>
>     auto MainFileID = findMainViewFileID(Filename, Function);<br>
> @@ -533,7 +548,7 @@ CoverageMapping::<wbr>getCoverageForFunction(<br>
>     return CoverageData();<br>
><br>
>   CoverageData FunctionCoverage(Function.<wbr>Filenames[*MainFileID]);<br>
> -  std::vector<coverage::<wbr>CountedRegion> Regions;<br>
> +  std::vector<CountedRegion> Regions;<br>
>   for (const auto &CR : Function.CountedRegions)<br>
>     if (CR.FileID == *MainFileID) {<br>
>       Regions.push_back(CR);<br>
> @@ -551,7 +566,7 @@ CoverageData CoverageMapping::getCoverag<br>
>     const ExpansionRecord &Expansion) const {<br>
>   CoverageData ExpansionCoverage(<br>
>       Expansion.Function.Filenames[<wbr>Expansion.FileID]);<br>
> -  std::vector<coverage::<wbr>CountedRegion> Regions;<br>
> +  std::vector<CountedRegion> Regions;<br>
>   for (const auto &CR : Expansion.Function.<wbr>CountedRegions)<br>
>     if (CR.FileID == Expansion.FileID) {<br>
>       Regions.push_back(CR);<br>
> @@ -566,8 +581,7 @@ CoverageData CoverageMapping::getCoverag<br>
>   return ExpansionCoverage;<br>
> }<br>
><br>
> -namespace {<br>
> -std::string getCoverageMapErrString(<wbr>coveragemap_error Err) {<br>
> +static std::string getCoverageMapErrString(<wbr>coveragemap_error Err) {<br>
>   switch (Err) {<br>
>   case coveragemap_error::success:<br>
>     return "Success";<br>
> @@ -585,6 +599,8 @@ std::string getCoverageMapErrString(cove<br>
>   llvm_unreachable("A value of coveragemap_error has no message.");<br>
> }<br>
><br>
> +namespace {<br>
> +<br>
> // FIXME: This class is only here to support the transition to llvm::Error. It<br>
> // will be removed once this transition is complete. Clients should prefer to<br>
> // deal with the Error value directly, rather than converting to error_code.<br>
> @@ -594,6 +610,7 @@ class CoverageMappingErrorCategoryTy<wbr>pe :<br>
>     return getCoverageMapErrString(<wbr>static_cast<coveragemap_error><wbr>(IE));<br>
>   }<br>
> };<br>
> +<br>
> } // end anonymous namespace<br>
><br>
> std::string CoverageMapError::message() const {<br>
><br>
> Modified: llvm/trunk/lib/ProfileData/<wbr>Coverage/<wbr>CoverageMappingReader.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ProfileData/Coverage/<wbr>CoverageMappingReader.cpp?rev=<wbr>296846&r1=296845&r2=296846&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/ProfileData/<wbr>Coverage/<wbr>CoverageMappingReader.cpp (original)<br>
> +++ llvm/trunk/lib/ProfileData/<wbr>Coverage/<wbr>CoverageMappingReader.cpp Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- CoverageMappingReader.cpp - Code coverage mapping reader ----*- C++ -*-=//<br>
> +//===- CoverageMappingReader.cpp - Code coverage mapping reader -*- C++ -*-===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -12,15 +12,34 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> -#include "llvm/ProfileData/Coverage/<wbr>CoverageMappingReader.h"<br>
> +#include "llvm/ADT/ArrayRef.h"<br>
> #include "llvm/ADT/DenseMap.h"<br>
> +#include "llvm/ADT/SmallVector.h"<br>
> +#include "llvm/ADT/STLExtras.h"<br>
> +#include "llvm/ADT/StringRef.h"<br>
> +#include "llvm/ADT/Triple.h"<br>
> +#include "llvm/Object/Binary.h"<br>
> +#include "llvm/Object/Error.h"<br>
> #include "llvm/Object/MachOUniversal.h"<br>
> #include "llvm/Object/ObjectFile.h"<br>
> +#include "llvm/ProfileData/Coverage/<wbr>CoverageMappingReader.h"<br>
> +#include "llvm/ProfileData/InstrProf.h"<br>
> +#include "llvm/Support/Casting.h"<br>
> #include "llvm/Support/Debug.h"<br>
> +#include "llvm/Support/Error.h"<br>
> +#include "llvm/Support/ErrorHandling.h"<br>
> #include "llvm/Support/Endian.h"<br>
> #include "llvm/Support/LEB128.h"<br>
> #include "llvm/Support/MathExtras.h"<br>
> #include "llvm/Support/raw_ostream.h"<br>
> +#include <algorithm><br>
> +#include <cassert><br>
> +#include <cstddef><br>
> +#include <cstdint><br>
> +#include <limits><br>
> +#include <memory><br>
> +#include <utility><br>
> +#include <vector><br>
><br>
> using namespace llvm;<br>
> using namespace coverage;<br>
> @@ -226,9 +245,8 @@ Error RawCoverageMappingReader::<wbr>readMapp<br>
> }<br>
><br>
> Error RawCoverageMappingReader::<wbr>read() {<br>
> -<br>
>   // Read the virtual file mapping.<br>
> -  llvm::SmallVector<unsigned, 8> VirtualFileMapping;<br>
> +  SmallVector<unsigned, 8> VirtualFileMapping;<br>
>   uint64_t NumFileMappings;<br>
>   if (auto Err = readSize(NumFileMappings))<br>
>     return Err;<br>
> @@ -349,7 +367,10 @@ static Expected<bool> isCoverageMappingD<br>
> }<br>
><br>
> namespace {<br>
> +<br>
> struct CovMapFuncRecordReader {<br>
> +  virtual ~CovMapFuncRecordReader() = default;<br>
> +<br>
>   // The interface to read coverage mapping function records for a module.<br>
>   //<br>
>   // \p Buf points to the buffer containing the \c CovHeader of the coverage<br>
> @@ -359,26 +380,24 @@ struct CovMapFuncRecordReader {<br>
>   // greater than \p End if not.<br>
>   virtual Expected<const char *> readFunctionRecords(const char *Buf,<br>
>                                                      const char *End) = 0;<br>
> -  virtual ~CovMapFuncRecordReader() {}<br>
> +<br>
>   template <class IntPtrT, support::endianness Endian><br>
>   static Expected<std::unique_ptr<<wbr>CovMapFuncRecordReader>><br>
> -  get(coverage::CovMapVersion Version, InstrProfSymtab &P,<br>
> +  get(CovMapVersion Version, InstrProfSymtab &P,<br>
>       std::vector<<wbr>BinaryCoverageReader::<wbr>ProfileMappingRecord> &R,<br>
>       std::vector<StringRef> &F);<br>
> };<br>
><br>
> // A class for reading coverage mapping function records for a module.<br>
> -template <coverage::CovMapVersion Version, class IntPtrT,<br>
> -          support::endianness Endian><br>
> +template <CovMapVersion Version, class IntPtrT, support::endianness Endian><br>
> class VersionedCovMapFuncRecordReade<wbr>r : public CovMapFuncRecordReader {<br>
> -  typedef typename coverage::CovMapTraits<<br>
> +  typedef typename CovMapTraits<<br>
>       Version, IntPtrT>::CovMapFuncRecordType FuncRecordType;<br>
> -  typedef typename coverage::CovMapTraits<<wbr>Version, IntPtrT>::NameRefType<br>
> -      NameRefType;<br>
> +  typedef typename CovMapTraits<Version, IntPtrT>::NameRefType  NameRefType;<br>
><br>
>   // Maps function's name references to the indexes of their records<br>
>   // in \c Records.<br>
> -  llvm::DenseMap<NameRefType, size_t> FunctionRecords;<br>
> +  DenseMap<NameRefType, size_t> FunctionRecords;<br>
>   InstrProfSymtab &ProfileNames;<br>
>   std::vector<StringRef> &Filenames;<br>
>   std::vector<<wbr>BinaryCoverageReader::<wbr>ProfileMappingRecord> &Records;<br>
> @@ -432,14 +451,16 @@ public:<br>
>       std::vector<<wbr>BinaryCoverageReader::<wbr>ProfileMappingRecord> &R,<br>
>       std::vector<StringRef> &F)<br>
>       : ProfileNames(P), Filenames(F), Records(R) {}<br>
> -  ~<wbr>VersionedCovMapFuncRecordReade<wbr>r() override {}<br>
> +<br>
> +  ~<wbr>VersionedCovMapFuncRecordReade<wbr>r() override = default;<br>
><br>
>   Expected<const char *> readFunctionRecords(const char *Buf,<br>
>                                              const char *End) override {<br>
>     using namespace support;<br>
> +<br>
>     if (Buf + sizeof(CovMapHeader) > End)<br>
>       return make_error<CoverageMapError>(<wbr>coveragemap_error::malformed);<br>
> -    auto CovHeader = reinterpret_cast<const coverage::CovMapHeader *>(Buf);<br>
> +    auto CovHeader = reinterpret_cast<const CovMapHeader *>(Buf);<br>
>     uint32_t NRecords = CovHeader->getNRecords<Endian><wbr>();<br>
>     uint32_t FilenamesSize = CovHeader->getFilenamesSize<<wbr>Endian>();<br>
>     uint32_t CoverageSize = CovHeader->getCoverageSize<<wbr>Endian>();<br>
> @@ -490,14 +511,16 @@ public:<br>
>     return Buf;<br>
>   }<br>
> };<br>
> +<br>
> } // end anonymous namespace<br>
><br>
> template <class IntPtrT, support::endianness Endian><br>
> Expected<std::unique_ptr<<wbr>CovMapFuncRecordReader>> CovMapFuncRecordReader::get(<br>
> -    coverage::CovMapVersion Version, InstrProfSymtab &P,<br>
> +    CovMapVersion Version, InstrProfSymtab &P,<br>
>     std::vector<<wbr>BinaryCoverageReader::<wbr>ProfileMappingRecord> &R,<br>
>     std::vector<StringRef> &F) {<br>
>   using namespace coverage;<br>
> +<br>
>   switch (Version) {<br>
>   case CovMapVersion::Version1:<br>
>     return llvm::make_unique<<wbr>VersionedCovMapFuncRecordReade<wbr>r<<br>
> @@ -518,11 +541,12 @@ static Error readCoverageMappingData(<br>
>     std::vector<<wbr>BinaryCoverageReader::<wbr>ProfileMappingRecord> &Records,<br>
>     std::vector<StringRef> &Filenames) {<br>
>   using namespace coverage;<br>
> +<br>
>   // Read the records in the coverage data section.<br>
>   auto CovHeader =<br>
> -      reinterpret_cast<const coverage::CovMapHeader *>(Data.data());<br>
> +      reinterpret_cast<const CovMapHeader *>(Data.data());<br>
>   CovMapVersion Version = (CovMapVersion)CovHeader-><wbr>getVersion<Endian>();<br>
> -  if (Version > coverage::CovMapVersion::<wbr>CurrentVersion)<br>
> +  if (Version > CovMapVersion::CurrentVersion)<br>
>     return make_error<CoverageMapError>(<wbr>coveragemap_error::<wbr>unsupported_version);<br>
>   Expected<std::unique_ptr<<wbr>CovMapFuncRecordReader>> ReaderExpected =<br>
>       CovMapFuncRecordReader::get<T, Endian>(Version, ProfileNames, Records,<br>
> @@ -538,6 +562,7 @@ static Error readCoverageMappingData(<br>
>   }<br>
>   return Error::success();<br>
> }<br>
> +<br>
> static const char *TestingFormatMagic = "llvmcovmtestdata";<br>
><br>
> static Error loadTestingFormat(StringRef Data, InstrProfSymtab &ProfileNames,<br>
> @@ -595,21 +620,21 @@ static Error loadBinaryFormat(MemoryBuff<br>
>                               StringRef &CoverageMapping,<br>
>                               uint8_t &BytesInAddress,<br>
>                               support::endianness &Endian, StringRef Arch) {<br>
> -  auto BinOrErr = object::createBinary(<wbr>ObjectBuffer);<br>
> +  auto BinOrErr = createBinary(ObjectBuffer);<br>
>   if (!BinOrErr)<br>
>     return BinOrErr.takeError();<br>
>   auto Bin = std::move(BinOrErr.get());<br>
>   std::unique_ptr<ObjectFile> OF;<br>
> -  if (auto *Universal = dyn_cast<object::<wbr>MachOUniversalBinary>(Bin.get(<wbr>))) {<br>
> +  if (auto *Universal = dyn_cast<MachOUniversalBinary><wbr>(Bin.get())) {<br>
>     // If we have a universal binary, try to look up the object for the<br>
>     // appropriate architecture.<br>
>     auto ObjectFileOrErr = Universal->getObjectForArch(<wbr>Arch);<br>
>     if (!ObjectFileOrErr)<br>
>       return ObjectFileOrErr.takeError();<br>
>     OF = std::move(ObjectFileOrErr.get(<wbr>));<br>
> -  } else if (isa<object::ObjectFile>(Bin.<wbr>get())) {<br>
> +  } else if (isa<ObjectFile>(Bin.get())) {<br>
>     // For any other object file, upcast and take ownership.<br>
> -    OF.reset(cast<object::<wbr>ObjectFile>(Bin.release()));<br>
> +    OF.reset(cast<ObjectFile>(Bin.<wbr>release()));<br>
>     // If we've asked for a particular arch, make sure they match.<br>
>     if (!Arch.empty() && OF->getArch() != Triple(Arch).getArch())<br>
>       return errorCodeToError(object_error:<wbr>:arch_not_found);<br>
><br>
> Modified: llvm/trunk/lib/ProfileData/<wbr>Coverage/<wbr>CoverageMappingWriter.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/Coverage/CoverageMappingWriter.cpp?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ProfileData/Coverage/<wbr>CoverageMappingWriter.cpp?rev=<wbr>296846&r1=296845&r2=296846&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/ProfileData/<wbr>Coverage/<wbr>CoverageMappingWriter.cpp (original)<br>
> +++ llvm/trunk/lib/ProfileData/<wbr>Coverage/<wbr>CoverageMappingWriter.cpp Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- CoverageMappingWriter.cpp - Code coverage mapping writer -------------=//<br>
> +//===- CoverageMappingWriter.cpp - Code coverage mapping writer -----------===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -12,8 +12,15 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> +#include "llvm/ADT/ArrayRef.h"<br>
> +#include "llvm/ADT/SmallVector.h"<br>
> #include "llvm/ProfileData/Coverage/<wbr>CoverageMappingWriter.h"<br>
> #include "llvm/Support/LEB128.h"<br>
> +#include "llvm/Support/raw_ostream.h"<br>
> +#include <algorithm><br>
> +#include <cassert><br>
> +#include <limits><br>
> +#include <vector><br>
><br>
> using namespace llvm;<br>
> using namespace coverage;<br>
> @@ -27,14 +34,25 @@ void CoverageFilenamesSectionWriter<wbr>::wri<br>
> }<br>
><br>
> namespace {<br>
> +<br>
> /// \brief Gather only the expressions that are used by the mapping<br>
> /// regions in this function.<br>
> class CounterExpressionsMinimizer {<br>
>   ArrayRef<CounterExpression> Expressions;<br>
> -  llvm::SmallVector<<wbr>CounterExpression, 16> UsedExpressions;<br>
> +  SmallVector<CounterExpression, 16> UsedExpressions;<br>
>   std::vector<unsigned> AdjustedExpressionIDs;<br>
><br>
> public:<br>
> +  CounterExpressionsMinimizer(<wbr>ArrayRef<CounterExpression> Expressions,<br>
> +                              ArrayRef<CounterMappingRegion> MappingRegions)<br>
> +      : Expressions(Expressions) {<br>
> +    AdjustedExpressionIDs.resize(<wbr>Expressions.size(), 0);<br>
> +    for (const auto &I : MappingRegions)<br>
> +      mark(I.Count);<br>
> +    for (const auto &I : MappingRegions)<br>
> +      gatherUsed(I.Count);<br>
> +  }<br>
> +<br>
>   void mark(Counter C) {<br>
>     if (!C.isExpression())<br>
>       return;<br>
> @@ -54,16 +72,6 @@ public:<br>
>     gatherUsed(E.RHS);<br>
>   }<br>
><br>
> -  CounterExpressionsMinimizer(<wbr>ArrayRef<CounterExpression> Expressions,<br>
> -                              ArrayRef<CounterMappingRegion> MappingRegions)<br>
> -      : Expressions(Expressions) {<br>
> -    AdjustedExpressionIDs.resize(<wbr>Expressions.size(), 0);<br>
> -    for (const auto &I : MappingRegions)<br>
> -      mark(I.Count);<br>
> -    for (const auto &I : MappingRegions)<br>
> -      gatherUsed(I.Count);<br>
> -  }<br>
> -<br>
>   ArrayRef<CounterExpression> getExpressions() const { return UsedExpressions; }<br>
><br>
>   /// \brief Adjust the given counter to correctly transition from the old<br>
> @@ -74,7 +82,8 @@ public:<br>
>     return C;<br>
>   }<br>
> };<br>
> -}<br>
> +<br>
> +} // end anonymous namespace<br>
><br>
> /// \brief Encode the counter.<br>
> ///<br>
><br>
> Modified: llvm/trunk/lib/ProfileData/<wbr>InstrProf.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ProfileData/InstrProf.cpp?rev=<wbr>296846&r1=296845&r2=296846&<wbr>view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/ProfileData/<wbr>InstrProf.cpp (original)<br>
> +++ llvm/trunk/lib/ProfileData/<wbr>InstrProf.cpp Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- InstrProf.cpp - Instrumented profiling format support -----------------=//<br>
> +//===- InstrProf.cpp - Instrumented profiling format support --------------===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -12,19 +12,46 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> -#include "llvm/ProfileData/InstrProf.h"<br>
> +#include "llvm/ADT/ArrayRef.h"<br>
> +#include "llvm/ADT/SmallString.h"<br>
> +#include "llvm/ADT/SmallVector.h"<br>
> #include "llvm/ADT/StringExtras.h"<br>
> +#include "llvm/ADT/StringRef.h"<br>
> #include "llvm/ADT/Triple.h"<br>
> +#include "llvm/IR/Constant.h"<br>
> #include "llvm/IR/Constants.h"<br>
> #include "llvm/IR/Function.h"<br>
> +#include "llvm/IR/GlobalValue.h"<br>
> #include "llvm/IR/GlobalVariable.h"<br>
> +#include "llvm/IR/Instruction.h"<br>
> +#include "llvm/IR/LLVMContext.h"<br>
> #include "llvm/IR/MDBuilder.h"<br>
> +#include "llvm/IR/Metadata.h"<br>
> #include "llvm/IR/Module.h"<br>
> +#include "llvm/IR/Type.h"<br>
> +#include "llvm/ProfileData/InstrProf.h"<br>
> +#include "llvm/Support/Casting.h"<br>
> +#include "llvm/Support/CommandLine.h"<br>
> +#include "llvm/Support/Compiler.h"<br>
> #include "llvm/Support/Compression.h"<br>
> +#include "llvm/Support/Endian.h"<br>
> +#include "llvm/Support/Error.h"<br>
> #include "llvm/Support/ErrorHandling.h"<br>
> #include "llvm/Support/LEB128.h"<br>
> #include "llvm/Support/ManagedStatic.h"<br>
> +#include "llvm/Support/MathExtras.h"<br>
> #include "llvm/Support/Path.h"<br>
> +#include "llvm/Support/SwapByteOrder.h"<br>
> +#include <algorithm><br>
> +#include <cassert><br>
> +#include <cstddef><br>
> +#include <cstring><br>
> +#include <cstdint><br>
> +#include <memory><br>
> +#include <string><br>
> +#include <system_error><br>
> +#include <utility><br>
> +#include <vector><br>
><br>
> using namespace llvm;<br>
><br>
> @@ -46,8 +73,7 @@ static cl::opt<unsigned> StaticFuncStrip<br>
>     cl::desc("Strip specified level of directory name from source path in "<br>
>              "the profile counter name for static functions."));<br>
><br>
> -namespace {<br>
> -std::string getInstrProfErrString(<wbr>instrprof_error Err) {<br>
> +static std::string getInstrProfErrString(<wbr>instrprof_error Err) {<br>
>   switch (Err) {<br>
>   case instrprof_error::success:<br>
>     return "Success";<br>
> @@ -89,15 +115,19 @@ std::string getInstrProfErrString(instrp<br>
>   llvm_unreachable("A value of instrprof_error has no message.");<br>
> }<br>
><br>
> +namespace {<br>
> +<br>
> // FIXME: This class is only here to support the transition to llvm::Error. It<br>
> // will be removed once this transition is complete. Clients should prefer to<br>
> // deal with the Error value directly, rather than converting to error_code.<br>
> class InstrProfErrorCategoryType : public std::error_category {<br>
>   const char *name() const noexcept override { return "llvm.instrprof"; }<br>
> +<br>
>   std::string message(int IE) const override {<br>
>     return getInstrProfErrString(static_<wbr>cast<instrprof_error>(IE));<br>
>   }<br>
> };<br>
> +<br>
> } // end anonymous namespace<br>
><br>
> static ManagedStatic<<wbr>InstrProfErrorCategoryType> ErrorCategory;<br>
> @@ -231,7 +261,6 @@ std::string getPGOFuncNameVarName(String<br>
> GlobalVariable *createPGOFuncNameVar(Module &M,<br>
>                                      GlobalValue::LinkageTypes Linkage,<br>
>                                      StringRef PGOFuncName) {<br>
> -<br>
>   // We generally want to match the function's linkage, but available_externally<br>
>   // and extern_weak both have the wrong semantics, and anything that doesn't<br>
>   // need to link across compilation units doesn't need to be visible at all.<br>
> @@ -276,7 +305,7 @@ void InstrProfSymtab::create(Module &M,<br>
><br>
> Error collectPGOFuncNameStrings(<wbr>const std::vector<std::string> &NameStrs,<br>
>                                 bool doCompression, std::string &Result) {<br>
> -  assert(NameStrs.size() && "No name data to emit");<br>
> +  assert(!NameStrs.empty() && "No name data to emit");<br>
><br>
>   uint8_t Header[16], *P = Header;<br>
>   std::string UncompressedNameStrings =<br>
> @@ -589,6 +618,7 @@ void ValueProfRecord::<wbr>deserializeTo(Inst<br>
> void ValueProfRecord::swapBytes(<wbr>support::endianness Old,<br>
>                                 support::endianness New) {<br>
>   using namespace support;<br>
> +<br>
>   if (Old == New)<br>
>     return;<br>
><br>
> @@ -625,6 +655,7 @@ void ValueProfData::deserializeTo(<wbr>InstrP<br>
> template <class T><br>
> static T swapToHostOrder(const unsigned char *&D, support::endianness Orig) {<br>
>   using namespace support;<br>
> +<br>
>   if (Orig == little)<br>
>     return endian::readNext<T, little, unaligned>(D);<br>
>   else<br>
> @@ -659,6 +690,7 @@ ValueProfData::<wbr>getValueProfData(const un<br>
>                                 const unsigned char *const BufferEnd,<br>
>                                 support::endianness Endianness) {<br>
>   using namespace support;<br>
> +<br>
>   if (D + sizeof(ValueProfData) > BufferEnd)<br>
>     return make_error<InstrProfError>(<wbr>instrprof_error::truncated);<br>
><br>
> @@ -681,6 +713,7 @@ ValueProfData::<wbr>getValueProfData(const un<br>
><br>
> void ValueProfData::<wbr>swapBytesToHost(support::<wbr>endianness Endianness) {<br>
>   using namespace support;<br>
> +<br>
>   if (Endianness == getHostEndianness())<br>
>     return;<br>
><br>
> @@ -696,6 +729,7 @@ void ValueProfData::<wbr>swapBytesToHost(supp<br>
><br>
> void ValueProfData::<wbr>swapBytesFromHost(support::<wbr>endianness Endianness) {<br>
>   using namespace support;<br>
> +<br>
>   if (Endianness == getHostEndianness())<br>
>     return;<br>
><br>
> @@ -890,4 +924,5 @@ bool canRenameComdatFunc(const Function<br>
>   }<br>
>   return true;<br>
> }<br>
> +<br>
> } // end namespace llvm<br>
><br>
> Modified: llvm/trunk/lib/ProfileData/<wbr>InstrProfReader.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProfReader.cpp?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ProfileData/InstrProfReader.<wbr>cpp?rev=296846&r1=296845&r2=<wbr>296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/ProfileData/<wbr>InstrProfReader.cpp (original)<br>
> +++ llvm/trunk/lib/ProfileData/<wbr>InstrProfReader.cpp Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- InstrProfReader.cpp - Instrumented profiling reader -------------------=//<br>
> +//===- InstrProfReader.cpp - Instrumented profiling reader ----------------===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -12,9 +12,27 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> -#include "llvm/ProfileData/<wbr>InstrProfReader.h"<br>
> +#include "llvm/ADT/ArrayRef.h"<br>
> #include "llvm/ADT/STLExtras.h"<br>
> -#include <cassert><br>
> +#include "llvm/ADT/StringRef.h"<br>
> +#include "llvm/IR/ProfileSummary.h"<br>
> +#include "llvm/ProfileData/InstrProf.h"<br>
> +#include "llvm/ProfileData/<wbr>InstrProfReader.h"<br>
> +#include "llvm/ProfileData/<wbr>ProfileCommon.h"<br>
> +#include "llvm/Support/Endian.h"<br>
> +#include "llvm/Support/Error.h"<br>
> +#include "llvm/Support/ErrorOr.h"<br>
> +#include "llvm/Support/MemoryBuffer.h"<br>
> +#include "llvm/Support/SwapByteOrder.h"<br>
> +#include <algorithm><br>
> +#include <cctype><br>
> +#include <cstddef><br>
> +#include <cstdint><br>
> +#include <limits><br>
> +#include <memory><br>
> +#include <system_error><br>
> +#include <utility><br>
> +#include <vector><br>
><br>
> using namespace llvm;<br>
><br>
> @@ -78,7 +96,6 @@ IndexedInstrProfReader::<wbr>create(const Twi<br>
>   return IndexedInstrProfReader::<wbr>create(std::move(<wbr>BufferOrError.get()));<br>
> }<br>
><br>
> -<br>
> Expected<std::unique_ptr<<wbr>IndexedInstrProfReader>><br>
> IndexedInstrProfReader::<wbr>create(std::unique_ptr<<wbr>MemoryBuffer> Buffer) {<br>
>   // Sanity check the buffer.<br>
> @@ -399,7 +416,6 @@ Error RawInstrProfReader<IntPtrT>::<wbr>readR<br>
> template <class IntPtrT><br>
> Error RawInstrProfReader<IntPtrT>::<wbr>readValueProfilingData(<br>
>     InstrProfRecord &Record) {<br>
> -<br>
>   Record.clearValueData();<br>
>   CurValueDataSize = 0;<br>
>   // Need to match the logic in value profile dumper code in compiler-rt:<br>
> @@ -455,9 +471,11 @@ Error RawInstrProfReader<IntPtrT>::<wbr>readN<br>
> }<br>
><br>
> namespace llvm {<br>
> +<br>
> template class RawInstrProfReader<uint32_t>;<br>
> template class RawInstrProfReader<uint64_t>;<br>
> -}<br>
> +<br>
> +} // end namespace llvm<br>
><br>
> InstrProfLookupTrait::hash_<wbr>value_type<br>
> InstrProfLookupTrait::<wbr>ComputeHash(StringRef K) {<br>
> @@ -483,6 +501,8 @@ bool InstrProfLookupTrait::<wbr>readValueProf<br>
><br>
> data_type InstrProfLookupTrait::<wbr>ReadData(StringRef K, const unsigned char *D,<br>
>                                          offset_type N) {<br>
> +  using namespace support;<br>
> +<br>
>   // Check if the data is corrupt. If so, don't try to read it.<br>
>   if (N % sizeof(uint64_t))<br>
>     return data_type();<br>
> @@ -490,7 +510,6 @@ data_type InstrProfLookupTrait::ReadData<br>
>   DataBuffer.clear();<br>
>   std::vector<uint64_t> CounterBuffer;<br>
><br>
> -  using namespace support;<br>
>   const unsigned char *End = D + N;<br>
>   while (D < End) {<br>
>     // Read hash.<br>
> @@ -568,9 +587,10 @@ InstrProfReaderIndex<<wbr>HashTableImpl>::Ins<br>
> }<br>
><br>
> bool IndexedInstrProfReader::<wbr>hasFormat(const MemoryBuffer &DataBuffer) {<br>
> +  using namespace support;<br>
> +<br>
>   if (DataBuffer.getBufferSize() < 8)<br>
>     return false;<br>
> -  using namespace support;<br>
>   uint64_t Magic =<br>
>       endian::read<uint64_t, little, aligned>(DataBuffer.<wbr>getBufferStart());<br>
>   // Verify that it's magical.<br>
> @@ -582,6 +602,7 @@ IndexedInstrProfReader::<wbr>readSummary(Inde<br>
>                                     const unsigned char *Cur) {<br>
>   using namespace IndexedInstrProf;<br>
>   using namespace support;<br>
> +<br>
>   if (Version >= IndexedInstrProf::Version4) {<br>
>     const IndexedInstrProf::Summary *SummaryInLE =<br>
>         reinterpret_cast<const IndexedInstrProf::Summary *>(Cur);<br>
> @@ -618,6 +639,7 @@ IndexedInstrProfReader::<wbr>readSummary(Inde<br>
>   } else {<br>
>     // For older version of profile data, we need to compute on the fly:<br>
>     using namespace IndexedInstrProf;<br>
> +<br>
>     InstrProfSummaryBuilder Builder(ProfileSummaryBuilder:<wbr>:DefaultCutoffs);<br>
>     // FIXME: This only computes an empty summary. Need to call addRecord for<br>
>     // all InstrProfRecords to get the correct summary.<br>
> @@ -627,14 +649,14 @@ IndexedInstrProfReader::<wbr>readSummary(Inde<br>
> }<br>
><br>
> Error IndexedInstrProfReader::<wbr>readHeader() {<br>
> +  using namespace support;<br>
> +<br>
>   const unsigned char *Start =<br>
>       (const unsigned char *)DataBuffer->getBufferStart()<wbr>;<br>
>   const unsigned char *Cur = Start;<br>
>   if ((const unsigned char *)DataBuffer->getBufferEnd() - Cur < 24)<br>
>     return error(instrprof_error::<wbr>truncated);<br>
><br>
> -  using namespace support;<br>
> -<br>
>   auto *Header = reinterpret_cast<const IndexedInstrProf::Header *>(Cur);<br>
>   Cur += sizeof(IndexedInstrProf::<wbr>Header);<br>
><br>
><br>
> Modified: llvm/trunk/lib/ProfileData/<wbr>InstrProfWriter.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProfWriter.cpp?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ProfileData/InstrProfWriter.<wbr>cpp?rev=296846&r1=296845&r2=<wbr>296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/ProfileData/<wbr>InstrProfWriter.cpp (original)<br>
> +++ llvm/trunk/lib/ProfileData/<wbr>InstrProfWriter.cpp Thu Mar  2 19:07:34 2017<br>
> @@ -1,4 +1,4 @@<br>
> -//=-- InstrProfWriter.cpp - Instrumented profiling writer -------------------=//<br>
> +//===- InstrProfWriter.cpp - Instrumented profiling writer ----------------===//<br>
> //<br>
> //                     The LLVM Compiler Infrastructure<br>
> //<br>
> @@ -12,15 +12,21 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> -#include "llvm/ProfileData/<wbr>InstrProfWriter.h"<br>
> +#include "llvm/ADT/STLExtras.h"<br>
> #include "llvm/ADT/StringRef.h"<br>
> #include "llvm/IR/ProfileSummary.h"<br>
> +#include "llvm/ProfileData/InstrProf.h"<br>
> +#include "llvm/ProfileData/<wbr>InstrProfWriter.h"<br>
> #include "llvm/ProfileData/<wbr>ProfileCommon.h"<br>
> +#include "llvm/Support/Endian.h"<br>
> #include "llvm/Support/EndianStream.h"<br>
> +#include "llvm/Support/Error.h"<br>
> #include "llvm/Support/MemoryBuffer.h"<br>
> #include "llvm/Support/OnDiskHashTable.<wbr>h"<br>
> #include "llvm/Support/raw_ostream.h"<br>
> #include <algorithm><br>
> +#include <cstdint><br>
> +#include <memory><br>
> #include <string><br>
> #include <tuple><br>
> #include <utility><br>
> @@ -41,10 +47,9 @@ namespace llvm {<br>
> // A wrapper class to abstract writer stream with support of bytes<br>
> // back patching.<br>
> class ProfOStream {<br>
> -<br>
> public:<br>
> -  ProfOStream(llvm::raw_fd_<wbr>ostream &FD) : IsFDOStream(true), OS(FD), LE(FD) {}<br>
> -  ProfOStream(llvm::raw_string_<wbr>ostream &STR)<br>
> +  ProfOStream(raw_fd_ostream &FD) : IsFDOStream(true), OS(FD), LE(FD) {}<br>
> +  ProfOStream(raw_string_ostream &STR)<br>
>       : IsFDOStream(false), OS(STR), LE(STR) {}<br>
><br>
>   uint64_t tell() { return OS.tell(); }<br>
> @@ -55,15 +60,16 @@ public:<br>
>   // directly and it won't be reflected in the stream's internal buffer.<br>
>   void patch(PatchItem *P, int NItems) {<br>
>     using namespace support;<br>
> +<br>
>     if (IsFDOStream) {<br>
> -      llvm::raw_fd_ostream &FDOStream = static_cast<llvm::raw_fd_<wbr>ostream &>(OS);<br>
> +      raw_fd_ostream &FDOStream = static_cast<raw_fd_ostream &>(OS);<br>
>       for (int K = 0; K < NItems; K++) {<br>
>         FDOStream.seek(P[K].Pos);<br>
>         for (int I = 0; I < P[K].N; I++)<br>
>           write(P[K].D[I]);<br>
>       }<br>
>     } else {<br>
> -      llvm::raw_string_ostream &SOStream =<br>
> +      raw_string_ostream &SOStream =<br>
>           static_cast<llvm::raw_string_<wbr>ostream &>(OS);<br>
>       std::string &Data = SOStream.str(); // with flush<br>
>       for (int K = 0; K < NItems; K++) {<br>
> @@ -94,17 +100,19 @@ public:<br>
>   typedef uint64_t hash_value_type;<br>
>   typedef uint64_t offset_type;<br>
><br>
> -  support::endianness ValueProfDataEndianness;<br>
> +  support::endianness ValueProfDataEndianness = support::little;<br>
>   InstrProfSummaryBuilder *SummaryBuilder;<br>
><br>
> -  InstrProfRecordWriterTrait() : ValueProfDataEndianness(<wbr>support::little) {}<br>
> +  InstrProfRecordWriterTrait() = default;<br>
> +<br>
>   static hash_value_type ComputeHash(key_type_ref K) {<br>
>     return IndexedInstrProf::ComputeHash(<wbr>K);<br>
>   }<br>
><br>
>   static std::pair<offset_type, offset_type><br>
>   EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V) {<br>
> -    using namespace llvm::support;<br>
> +    using namespace support;<br>
> +<br>
>     endian::Writer<little> LE(Out);<br>
><br>
>     offset_type N = K.size();<br>
> @@ -130,7 +138,8 @@ public:<br>
>   }<br>
><br>
>   void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V, offset_type) {<br>
> -    using namespace llvm::support;<br>
> +    using namespace support;<br>
> +<br>
>     endian::Writer<little> LE(Out);<br>
>     for (const auto &ProfileData : *V) {<br>
>       const InstrProfRecord &ProfRecord = ProfileData.second;<br>
> @@ -154,8 +163,7 @@ public:<br>
> } // end namespace llvm<br>
><br>
> InstrProfWriter::<wbr>InstrProfWriter(bool Sparse)<br>
> -    : Sparse(Sparse), FunctionData(), ProfileKind(PF_Unknown),<br>
> -      InfoObj(new InstrProfRecordWriterTrait()) {}<br>
> +    : Sparse(Sparse), InfoObj(new InstrProfRecordWriterTrait()) {}<br>
><br>
> InstrProfWriter::~<wbr>InstrProfWriter() { delete InfoObj; }<br>
><br>
> @@ -208,7 +216,7 @@ bool InstrProfWriter::<wbr>shouldEncodeData(c<br>
>     return true;<br>
>   for (const auto &Func : PD) {<br>
>     const InstrProfRecord &IPR = Func.second;<br>
> -    if (any_of(IPR.Counts, [](uint64_t Count) { return Count > 0; }))<br>
> +    if (llvm::any_of(IPR.Counts, [](uint64_t Count) { return Count > 0; }))<br>
>       return true;<br>
>   }<br>
>   return false;<br>
> @@ -217,6 +225,7 @@ bool InstrProfWriter::<wbr>shouldEncodeData(c<br>
> static void setSummary(IndexedInstrProf::<wbr>Summary *TheSummary,<br>
>                        ProfileSummary &PS) {<br>
>   using namespace IndexedInstrProf;<br>
> +<br>
>   std::vector<<wbr>ProfileSummaryEntry> &Res = PS.getDetailedSummary();<br>
>   TheSummary->NumSummaryFields = Summary::NumKinds;<br>
>   TheSummary->NumCutoffEntries = Res.size();<br>
> @@ -231,9 +240,10 @@ static void setSummary(IndexedInstrProf:<br>
> }<br>
><br>
> void InstrProfWriter::writeImpl(<wbr>ProfOStream &OS) {<br>
> +  using namespace IndexedInstrProf;<br>
> +<br>
>   OnDiskChainedHashTableGenerato<wbr>r<InstrProfRecordWriterTrait> Generator;<br>
><br>
> -  using namespace IndexedInstrProf;<br>
>   InstrProfSummaryBuilder ISB(ProfileSummaryBuilder::<wbr>DefaultCutoffs);<br>
>   InfoObj->SummaryBuilder = &ISB;<br>
><br>
> @@ -301,7 +311,7 @@ void InstrProfWriter::write(raw_fd_<wbr>ostre<br>
><br>
> std::unique_ptr<MemoryBuffer> InstrProfWriter::writeBuffer() {<br>
>   std::string Data;<br>
> -  llvm::raw_string_ostream OS(Data);<br>
> +  raw_string_ostream OS(Data);<br>
>   ProfOStream POS(OS);<br>
>   // Write the hash table.<br>
>   writeImpl(POS);<br>
><br>
> Modified: llvm/trunk/lib/ProfileData/<wbr>SampleProf.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/SampleProf.cpp?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ProfileData/SampleProf.cpp?<wbr>rev=296846&r1=296845&r2=<wbr>296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/ProfileData/<wbr>SampleProf.cpp (original)<br>
> +++ llvm/trunk/lib/ProfileData/<wbr>SampleProf.cpp Thu Mar  2 19:07:34 2017<br>
> @@ -13,18 +13,25 @@<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> #include "llvm/ProfileData/SampleProf.<wbr>h"<br>
> +#include "llvm/Support/Compiler.h"<br>
> +#include "llvm/Support/Debug.h"<br>
> #include "llvm/Support/ErrorHandling.h"<br>
> #include "llvm/Support/ManagedStatic.h"<br>
> +#include "llvm/Support/raw_ostream.h"<br>
> +#include <string><br>
> +#include <system_error><br>
><br>
> -using namespace llvm::sampleprof;<br>
> using namespace llvm;<br>
> +using namespace sampleprof;<br>
><br>
> namespace {<br>
> +<br>
> // FIXME: This class is only here to support the transition to llvm::Error. It<br>
> // will be removed once this transition is complete. Clients should prefer to<br>
> // deal with the Error value directly, rather than converting to error_code.<br>
> class SampleProfErrorCategoryType : public std::error_category {<br>
>   const char *name() const noexcept override { return "llvm.sampleprof"; }<br>
> +<br>
>   std::string message(int IE) const override {<br>
>     sampleprof_error E = static_cast<sampleprof_error>(<wbr>IE);<br>
>     switch (E) {<br>
> @@ -54,7 +61,8 @@ class SampleProfErrorCategoryType : publ<br>
>     llvm_unreachable("A value of sampleprof_error has no message.");<br>
>   }<br>
> };<br>
> -}<br>
> +<br>
> +} // end anonymous namespace<br>
><br>
> static ManagedStatic<<wbr>SampleProfErrorCategoryType> ErrorCategory;<br>
><br>
> @@ -105,7 +113,7 @@ void FunctionSamples::print(raw_<wbr>ostream<br>
>      << " sampled lines\n";<br>
><br>
>   OS.indent(Indent);<br>
> -  if (BodySamples.size() > 0) {<br>
> +  if (!BodySamples.empty()) {<br>
>     OS << "Samples collected in the function's body {\n";<br>
>     SampleSorter<LineLocation, SampleRecord> SortedBodySamples(BodySamples)<wbr>;<br>
>     for (const auto &SI : SortedBodySamples.get()) {<br>
> @@ -119,7 +127,7 @@ void FunctionSamples::print(raw_<wbr>ostream<br>
>   }<br>
><br>
>   OS.indent(Indent);<br>
> -  if (CallsiteSamples.size() > 0) {<br>
> +  if (!CallsiteSamples.empty()) {<br>
>     OS << "Samples collected in inlined callsites {\n";<br>
>     SampleSorter<LineLocation, FunctionSamples> SortedCallsiteSamples(<br>
>         CallsiteSamples);<br>
> @@ -141,5 +149,5 @@ raw_ostream &llvm::sampleprof::operator<<br>
> }<br>
><br>
> #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)<br>
> -LLVM_DUMP_METHOD void FunctionSamples::dump(void) const { print(dbgs(), 0); }<br>
> +LLVM_DUMP_METHOD void FunctionSamples::dump() const { print(dbgs(), 0); }<br>
> #endif<br>
><br>
> Modified: llvm/trunk/lib/ProfileData/<wbr>SampleProfReader.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/SampleProfReader.cpp?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ProfileData/SampleProfReader.<wbr>cpp?rev=296846&r1=296845&r2=<wbr>296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/ProfileData/<wbr>SampleProfReader.cpp (original)<br>
> +++ llvm/trunk/lib/ProfileData/<wbr>SampleProfReader.cpp Thu Mar  2 19:07:34 2017<br>
> @@ -23,14 +23,25 @@<br>
> #include "llvm/ProfileData/<wbr>SampleProfReader.h"<br>
> #include "llvm/ADT/DenseMap.h"<br>
> #include "llvm/ADT/STLExtras.h"<br>
> -#include "llvm/Support/Debug.h"<br>
> +#include "llvm/ADT/StringRef.h"<br>
> +#include "llvm/IR/ProfileSummary.h"<br>
> +#include "llvm/ProfileData/<wbr>ProfileCommon.h"<br>
> +#include "llvm/ProfileData/SampleProf.<wbr>h"<br>
> #include "llvm/Support/ErrorOr.h"<br>
> #include "llvm/Support/LEB128.h"<br>
> #include "llvm/Support/LineIterator.h"<br>
> #include "llvm/Support/MemoryBuffer.h"<br>
> +#include "llvm/Support/raw_ostream.h"<br>
> +#include <algorithm><br>
> +#include <cstddef><br>
> +#include <cstdint><br>
> +#include <limits><br>
> +#include <memory><br>
> +#include <system_error><br>
> +#include <vector><br>
><br>
> -using namespace llvm::sampleprof;<br>
> using namespace llvm;<br>
> +using namespace sampleprof;<br>
><br>
> /// \brief Dump the function profile for \p FName.<br>
> ///<br>
><br>
> Modified: llvm/trunk/lib/ProfileData/<wbr>SampleProfWriter.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/SampleProfWriter.cpp?rev=296846&r1=296845&r2=296846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>ProfileData/SampleProfWriter.<wbr>cpp?rev=296846&r1=296845&r2=<wbr>296846&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- llvm/trunk/lib/ProfileData/<wbr>SampleProfWriter.cpp (original)<br>
> +++ llvm/trunk/lib/ProfileData/<wbr>SampleProfWriter.cpp Thu Mar  2 19:07:34 2017<br>
> @@ -18,16 +18,23 @@<br>
> //<br>
> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
><br>
> +#include "llvm/ADT/StringRef.h"<br>
> +#include "llvm/ProfileData/<wbr>ProfileCommon.h"<br>
> +#include "llvm/ProfileData/SampleProf.<wbr>h"<br>
> #include "llvm/ProfileData/<wbr>SampleProfWriter.h"<br>
> -#include "llvm/Support/Debug.h"<br>
> #include "llvm/Support/ErrorOr.h"<br>
> +#include "llvm/Support/FileSystem.h"<br>
> #include "llvm/Support/LEB128.h"<br>
> -#include "llvm/Support/LineIterator.h"<br>
> -#include "llvm/Support/MemoryBuffer.h"<br>
> -#include "llvm/Support/Regex.h"<br>
> +#include "llvm/Support/raw_ostream.h"<br>
> +#include <algorithm><br>
> +#include <cstdint><br>
> +#include <memory><br>
> +#include <system_error><br>
> +#include <utility><br>
> +#include <vector><br>
><br>
> -using namespace llvm::sampleprof;<br>
> using namespace llvm;<br>
> +using namespace sampleprof;<br>
><br>
> /// \brief Write samples to a text file.<br>
> ///<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>