MemProfiler.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/Function.h"
  20. #include "llvm/IR/Module.h"
  21. #include "llvm/IR/PassManager.h"
  22. #include "llvm/Pass.h"
  23. namespace llvm {
  24. /// Public interface to the memory profiler pass for instrumenting code to
  25. /// profile memory accesses.
  26. ///
  27. /// The profiler itself is a function pass that works by inserting various
  28. /// calls to the MemProfiler runtime library functions. The runtime library
  29. /// essentially replaces malloc() and free() with custom implementations that
  30. /// record data about the allocations.
  31. class MemProfilerPass : public PassInfoMixin<MemProfilerPass> {
  32. public:
  33. explicit MemProfilerPass();
  34. PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
  35. static bool isRequired() { return true; }
  36. };
  37. /// Public interface to the memory profiler module pass for instrumenting code
  38. /// to profile memory allocations and accesses.
  39. class ModuleMemProfilerPass : public PassInfoMixin<ModuleMemProfilerPass> {
  40. public:
  41. explicit ModuleMemProfilerPass();
  42. PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
  43. static bool isRequired() { return true; }
  44. };
  45. // Insert MemProfiler instrumentation
  46. FunctionPass *createMemProfilerFunctionPass();
  47. ModulePass *createModuleMemProfilerLegacyPassPass();
  48. } // namespace llvm
  49. #endif
  50. #ifdef __GNUC__
  51. #pragma GCC diagnostic pop
  52. #endif