LLVM 23.0.0git
MemProfUse.h
Go to the documentation of this file.
1//===--------- MemProfUse.h - Memory profiler use pass ----*- 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 MemProfUsePass class and related utilities.
10//
11//===----------------------------------------------------------------------===//
12#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFUSE_H
13#define LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFUSE_H
14
16#include "llvm/IR/PassManager.h"
20
21namespace llvm {
23class Module;
25
26namespace vfs {
27class FileSystem;
28} // namespace vfs
29
30class MemProfUsePass : public OptionalPassInfoMixin<MemProfUsePass> {
31public:
32 LLVM_ABI explicit MemProfUsePass(
33 std::string MemoryProfileFile,
36
37private:
38 // Annotate global variables' section prefix based on data access profile,
39 // return true if any global variable is annotated and false otherwise.
40 bool
41 annotateGlobalVariables(Module &M,
42 const memprof::DataAccessProfData *DataAccessProf);
43 std::string MemoryProfileFileName;
45};
46
47namespace memprof {
48
49// Extract all calls from the IR. Arrange them in a map from caller GUIDs to a
50// list of call sites, each of the form {LineLocation, CalleeGUID}.
52 Module &M, const TargetLibraryInfo &TLI,
53 function_ref<bool(uint64_t)> IsPresentInProfile = [](uint64_t) {
54 return true;
55 });
56
58
59// Compute an undrifting map. The result is a map from caller GUIDs to an inner
60// map that maps source locations in the profile to those in the current IR.
63 const TargetLibraryInfo &TLI);
64
65} // namespace memprof
66} // namespace llvm
67
68#endif
#define LLVM_ABI
Definition Compiler.h:215
This header defines various interfaces for pass management in LLVM.
This file defines the RefCountedBase, ThreadSafeRefCountedBase, and IntrusiveRefCntPtr classes.
Reader for the indexed binary instrprof format.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
LLVM_ABI MemProfUsePass(std::string MemoryProfileFile, IntrusiveRefCntPtr< vfs::FileSystem > FS=nullptr)
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
Provides information about what library functions are available for the current target.
An efficient, type-erasing, non-owning reference to a callable.
Encapsulates the data access profile data and the methods to operate on it.
The virtual file system interface.
LLVM_ABI DenseMap< uint64_t, LocToLocMap > computeUndriftMap(Module &M, IndexedInstrProfReader *MemProfReader, const TargetLibraryInfo &TLI)
DenseMap< LineLocation, LineLocation > LocToLocMap
Definition MemProfUse.h:57
LLVM_ABI DenseMap< uint64_t, SmallVector< CallEdgeTy, 0 > > extractCallsFromIR(Module &M, const TargetLibraryInfo &TLI, function_ref< bool(uint64_t)> IsPresentInProfile=[](uint64_t) { return true;})
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
A CRTP mix-in for passes that can be skipped.