blob: b584b99844927a24ace35710bdc8e939308cff10 [file] [log] [blame]
Stephen Hinesc6ca60f2023-05-09 02:19:22 -07001//===--------- 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
17namespace llvm {
18class Function;
19class FunctionPass;
20class Module;
21class 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.
30class MemProfilerPass : public PassInfoMixin<MemProfilerPass> {
31public:
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.
39class ModuleMemProfilerPass : public PassInfoMixin<ModuleMemProfilerPass> {
40public:
41 explicit ModuleMemProfilerPass();
42 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
43 static bool isRequired() { return true; }
44};
45
46// Insert MemProfiler instrumentation
47FunctionPass *createMemProfilerFunctionPass();
48ModulePass *createModuleMemProfilerLegacyPassPass();
49
50} // namespace llvm
51
52#endif