Stephen Hines | c6ca60f | 2023-05-09 02:19:22 -0700 | [diff] [blame^] | 1 | //===--------- Definition of the MemProfiler class --------------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file declares the MemProfiler class. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFILER_H |
| 13 | #define LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFILER_H |
| 14 | |
| 15 | #include "llvm/IR/PassManager.h" |
| 16 | |
| 17 | namespace llvm { |
| 18 | class Function; |
| 19 | class FunctionPass; |
| 20 | class Module; |
| 21 | class ModulePass; |
| 22 | |
| 23 | /// Public interface to the memory profiler pass for instrumenting code to |
| 24 | /// profile memory accesses. |
| 25 | /// |
| 26 | /// The profiler itself is a function pass that works by inserting various |
| 27 | /// calls to the MemProfiler runtime library functions. The runtime library |
| 28 | /// essentially replaces malloc() and free() with custom implementations that |
| 29 | /// record data about the allocations. |
| 30 | class MemProfilerPass : public PassInfoMixin<MemProfilerPass> { |
| 31 | public: |
| 32 | explicit MemProfilerPass(); |
| 33 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); |
| 34 | static bool isRequired() { return true; } |
| 35 | }; |
| 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 | |
| 46 | // Insert MemProfiler instrumentation |
| 47 | FunctionPass *createMemProfilerFunctionPass(); |
| 48 | ModulePass *createModuleMemProfilerLegacyPassPass(); |
| 49 | |
| 50 | } // namespace llvm |
| 51 | |
| 52 | #endif |