MemProfiler.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--------- Definition of the MemProfiler class --------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file declares the MemProfiler class.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFILER_H
  18. #define LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFILER_H
  19. #include "llvm/IR/PassManager.h"
  20. namespace llvm {
  21. class Function;
  22. class FunctionPass;
  23. class Module;
  24. class ModulePass;
  25. /// Public interface to the memory profiler pass for instrumenting code to
  26. /// profile memory accesses.
  27. ///
  28. /// The profiler itself is a function pass that works by inserting various
  29. /// calls to the MemProfiler runtime library functions. The runtime library
  30. /// essentially replaces malloc() and free() with custom implementations that
  31. /// record data about the allocations.
  32. class MemProfilerPass : public PassInfoMixin<MemProfilerPass> {
  33. public:
  34. explicit MemProfilerPass();
  35. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  36. static bool isRequired() { return true; }
  37. };
  38. /// Public interface to the memory profiler module pass for instrumenting code
  39. /// to profile memory allocations and accesses.
  40. class ModuleMemProfilerPass : public PassInfoMixin<ModuleMemProfilerPass> {
  41. public:
  42. explicit ModuleMemProfilerPass();
  43. PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
  44. static bool isRequired() { return true; }
  45. };
  46. // Insert MemProfiler instrumentation
  47. FunctionPass *createMemProfilerFunctionPass();
  48. ModulePass *createModuleMemProfilerLegacyPassPass();
  49. } // namespace llvm
  50. #endif
  51. #ifdef __GNUC__
  52. #pragma GCC diagnostic pop
  53. #endif