LLVM 22.0.0git
AllocToken.h
Go to the documentation of this file.
1//===- AllocToken.h - Allocation token instrumentation --------------------===//
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 AllocTokenPass, an instrumentation pass that
10// replaces allocation calls with ones including an allocation token.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_ALLOCTOKEN_H
15#define LLVM_TRANSFORMS_INSTRUMENTATION_ALLOCTOKEN_H
16
17#include "llvm/IR/Analysis.h"
18#include "llvm/IR/PassManager.h"
20#include <optional>
21
22namespace llvm {
23
24class Module;
25
28 std::optional<uint64_t> MaxTokens;
29 bool FastABI = false;
30 bool Extended = false;
31 AllocTokenOptions() = default;
32};
33
34/// A module pass that rewrites heap allocations to use token-enabled
35/// allocation functions based on various source-level properties.
36class AllocTokenPass : public PassInfoMixin<AllocTokenPass> {
37public:
38 LLVM_ABI explicit AllocTokenPass(AllocTokenOptions Opts = {});
40 static bool isRequired() { return true; }
41
42private:
44};
45
46} // namespace llvm
47
48#endif // LLVM_TRANSFORMS_INSTRUMENTATION_ALLOCTOKEN_H
#define LLVM_ABI
Definition Compiler.h:213
This header defines various interfaces for pass management in LLVM.
static LVOptions Options
Definition LVOptions.cpp:25
ModuleAnalysisManager MAM
LLVM_ABI AllocTokenPass(AllocTokenOptions Opts={})
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
static bool isRequired()
Definition AllocToken.h:40
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
constexpr AllocTokenMode DefaultAllocTokenMode
The default allocation token mode.
Definition AllocToken.h:41
AllocTokenMode
Modes for generating allocation token IDs.
Definition AllocToken.h:24
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
AllocTokenMode Mode
Definition AllocToken.h:27
std::optional< uint64_t > MaxTokens
Definition AllocToken.h:28
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition PassManager.h:70