RawMemProfReader.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. #ifndef LLVM_PROFILEDATA_RAWMEMPROFREADER_H_
  7. #define LLVM_PROFILEDATA_RAWMEMPROFREADER_H_
  8. //===- MemProfReader.h - Instrumented memory profiling reader ---*- C++ -*-===//
  9. //
  10. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  11. // See https://llvm.org/LICENSE.txt for license information.
  12. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  13. //
  14. //===----------------------------------------------------------------------===//
  15. //
  16. // This file contains support for reading MemProf profiling data.
  17. //
  18. //===----------------------------------------------------------------------===//
  19. #include "llvm/Support/Error.h"
  20. #include "llvm/Support/MemoryBuffer.h"
  21. namespace llvm {
  22. namespace memprof {
  23. class RawMemProfReader {
  24. public:
  25. RawMemProfReader(std::unique_ptr<MemoryBuffer> DataBuffer)
  26. : DataBuffer(std::move(DataBuffer)) {}
  27. // Prints aggregate counts for each raw profile parsed from the DataBuffer.
  28. void printSummaries(raw_ostream &OS) const;
  29. // Return true if the \p DataBuffer starts with magic bytes indicating it is
  30. // a raw binary memprof profile.
  31. static bool hasFormat(const MemoryBuffer &DataBuffer);
  32. // Create a RawMemProfReader after sanity checking the contents of the file at
  33. // \p Path.
  34. static Expected<std::unique_ptr<RawMemProfReader>> create(const Twine &Path);
  35. private:
  36. std::unique_ptr<MemoryBuffer> DataBuffer;
  37. };
  38. } // namespace memprof
  39. } // namespace llvm
  40. #endif // LLVM_PROFILEDATA_RAWMEMPROFREADER_H_
  41. #ifdef __GNUC__
  42. #pragma GCC diagnostic pop
  43. #endif