1//===--- MemProfInstrumentation.h - Memory profiler instrumentation ----*- C++
2//-*-===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9//
10// This file declares the MemProf instrumentation pass classes.
11//
12//===----------------------------------------------------------------------===//
13#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROF_INSTRUMENTATION_H
14#define LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROF_INSTRUMENTATION_H
15
16#include "llvm/IR/PassManager.h"
17#include "llvm/Support/Compiler.h"
18
19namespace llvm {
20class Function;
21class Module;
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 LLVM_ABI explicit MemProfilerPass();
33 LLVM_ABI 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 LLVM_ABI explicit ModuleMemProfilerPass();
42 LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
43 static bool isRequired() { return true; }
44};
45
46} // namespace llvm
47
48#endif
49