diff options
author | Stephen Hines <srhines@google.com> | 2014-07-21 00:45:20 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-07-21 00:45:20 -0700 |
commit | c6a4f5e819217e1e12c458aed8e7b122e23a3a58 (patch) | |
tree | 81b7dd2bb4370a392f31d332a566c903b5744764 /include/llvm/ProfileData | |
parent | 19c6fbb3e8aaf74093afa08013134b61fa08f245 (diff) | |
download | external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.zip external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.tar.gz external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.tar.bz2 |
Update LLVM for rebase to r212749.
Includes a cherry-pick of:
r212948 - fixes a small issue with atomic calls
Change-Id: Ib97bd980b59f18142a69506400911a6009d9df18
Diffstat (limited to 'include/llvm/ProfileData')
-rw-r--r-- | include/llvm/ProfileData/InstrProf.h | 26 | ||||
-rw-r--r-- | include/llvm/ProfileData/InstrProfReader.h | 49 | ||||
-rw-r--r-- | include/llvm/ProfileData/InstrProfWriter.h | 5 |
3 files changed, 38 insertions, 42 deletions
diff --git a/include/llvm/ProfileData/InstrProf.h b/include/llvm/ProfileData/InstrProf.h index 8457678..eafb768 100644 --- a/include/llvm/ProfileData/InstrProf.h +++ b/include/llvm/ProfileData/InstrProf.h @@ -16,14 +16,12 @@ #ifndef LLVM_PROFILEDATA_INSTRPROF_H_ #define LLVM_PROFILEDATA_INSTRPROF_H_ -#include "llvm/Support/system_error.h" +#include <system_error> namespace llvm { +const std::error_category &instrprof_category(); -const error_category &instrprof_category(); - -struct instrprof_error { - enum ErrorType { +enum class instrprof_error { success = 0, eof, bad_magic, @@ -37,21 +35,17 @@ struct instrprof_error { hash_mismatch, count_mismatch, counter_overflow - }; - ErrorType V; - - instrprof_error(ErrorType V) : V(V) {} - operator ErrorType() const { return V; } }; -inline error_code make_error_code(instrprof_error E) { - return error_code(static_cast<int>(E), instrprof_category()); +inline std::error_code make_error_code(instrprof_error E) { + return std::error_code(static_cast<int>(E), instrprof_category()); } -template <> struct is_error_code_enum<instrprof_error> : std::true_type {}; -template <> struct is_error_code_enum<instrprof_error::ErrorType> - : std::true_type {}; - } // end namespace llvm +namespace std { +template <> +struct is_error_code_enum<llvm::instrprof_error> : std::true_type {}; +} + #endif // LLVM_PROFILEDATA_INSTRPROF_H_ diff --git a/include/llvm/ProfileData/InstrProfReader.h b/include/llvm/ProfileData/InstrProfReader.h index 3e18c76..7a5a71d 100644 --- a/include/llvm/ProfileData/InstrProfReader.h +++ b/include/llvm/ProfileData/InstrProfReader.h @@ -60,28 +60,29 @@ public: /// Base class and interface for reading profiling data of any known instrprof /// format. Provides an iterator over InstrProfRecords. class InstrProfReader { - error_code LastError; + std::error_code LastError; + public: InstrProfReader() : LastError(instrprof_error::success) {} virtual ~InstrProfReader() {} /// Read the header. Required before reading first record. - virtual error_code readHeader() = 0; + virtual std::error_code readHeader() = 0; /// Read a single record. - virtual error_code readNextRecord(InstrProfRecord &Record) = 0; + virtual std::error_code readNextRecord(InstrProfRecord &Record) = 0; /// Iterator over profile data. InstrProfIterator begin() { return InstrProfIterator(this); } InstrProfIterator end() { return InstrProfIterator(); } protected: - /// Set the current error_code and return same. - error_code error(error_code EC) { + /// Set the current std::error_code and return same. + std::error_code error(std::error_code EC) { LastError = EC; return EC; } /// Clear the current error code and return a successful one. - error_code success() { return error(instrprof_error::success); } + std::error_code success() { return error(instrprof_error::success); } public: /// Return true if the reader has finished reading the profile data. @@ -89,12 +90,12 @@ public: /// Return true if the reader encountered an error reading profiling data. bool hasError() { return LastError && !isEOF(); } /// Get the current error code. - error_code getError() { return LastError; } + std::error_code getError() { return LastError; } /// Factory method to create an appropriately typed reader for the given /// instrprof file. - static error_code create(std::string Path, - std::unique_ptr<InstrProfReader> &Result); + static std::error_code create(std::string Path, + std::unique_ptr<InstrProfReader> &Result); }; /// Reader for the simple text based instrprof format. @@ -122,9 +123,9 @@ public: : DataBuffer(std::move(DataBuffer_)), Line(*DataBuffer, '#') {} /// Read the header. - error_code readHeader() override { return success(); } + std::error_code readHeader() override { return success(); } /// Read a single record. - error_code readNextRecord(InstrProfRecord &Record) override; + std::error_code readNextRecord(InstrProfRecord &Record) override; }; /// Reader for the raw instrprof binary format from runtime. @@ -167,23 +168,23 @@ private: const char *NamesStart; const char *ProfileEnd; - RawInstrProfReader(const TextInstrProfReader &) LLVM_DELETED_FUNCTION; - RawInstrProfReader &operator=(const TextInstrProfReader &) + RawInstrProfReader(const RawInstrProfReader &) LLVM_DELETED_FUNCTION; + RawInstrProfReader &operator=(const RawInstrProfReader &) LLVM_DELETED_FUNCTION; public: RawInstrProfReader(std::unique_ptr<MemoryBuffer> DataBuffer) : DataBuffer(std::move(DataBuffer)) { } static bool hasFormat(const MemoryBuffer &DataBuffer); - error_code readHeader() override; - error_code readNextRecord(InstrProfRecord &Record) override; + std::error_code readHeader() override; + std::error_code readNextRecord(InstrProfRecord &Record) override; private: - error_code readNextHeader(const char *CurrentPos); - error_code readHeader(const RawHeader &Header); + std::error_code readNextHeader(const char *CurrentPos); + std::error_code readHeader(const RawHeader &Header); template <class IntT> IntT swap(IntT Int) const { - return ShouldSwapBytes ? sys::SwapByteOrder(Int) : Int; + return ShouldSwapBytes ? sys::getSwappedBytes(Int) : Int; } const uint64_t *getCounter(IntPtrT CounterPtr) const { ptrdiff_t Offset = (swap(CounterPtr) - CountersDelta) / sizeof(uint64_t); @@ -281,19 +282,19 @@ public: static bool hasFormat(const MemoryBuffer &DataBuffer); /// Read the file header. - error_code readHeader() override; + std::error_code readHeader() override; /// Read a single record. - error_code readNextRecord(InstrProfRecord &Record) override; + std::error_code readNextRecord(InstrProfRecord &Record) override; /// Fill Counts with the profile data for the given function name. - error_code getFunctionCounts(StringRef FuncName, uint64_t &FuncHash, - std::vector<uint64_t> &Counts); + std::error_code getFunctionCounts(StringRef FuncName, uint64_t &FuncHash, + std::vector<uint64_t> &Counts); /// Return the maximum of all known function counts. uint64_t getMaximumFunctionCount() { return MaxFunctionCount; } /// Factory method to create an indexed reader. - static error_code create(std::string Path, - std::unique_ptr<IndexedInstrProfReader> &Result); + static std::error_code + create(std::string Path, std::unique_ptr<IndexedInstrProfReader> &Result); }; } // end namespace llvm diff --git a/include/llvm/ProfileData/InstrProfWriter.h b/include/llvm/ProfileData/InstrProfWriter.h index fa37bf1..6e68bee 100644 --- a/include/llvm/ProfileData/InstrProfWriter.h +++ b/include/llvm/ProfileData/InstrProfWriter.h @@ -38,8 +38,9 @@ public: /// Add function counts for the given function. If there are already counts /// for this function and the hash and number of counts match, each counter is /// summed. - error_code addFunctionCounts(StringRef FunctionName, uint64_t FunctionHash, - ArrayRef<uint64_t> Counters); + std::error_code addFunctionCounts(StringRef FunctionName, + uint64_t FunctionHash, + ArrayRef<uint64_t> Counters); /// Ensure that all data is written to disk. void write(raw_fd_ostream &OS); }; |