LLVM 22.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
21#include <unordered_map>
22
23namespace llvm {
24class IndexedInstrProfReader;
25class Module;
26class TargetLibraryInfo;
27
28namespace vfs {
29class FileSystem;
30} // namespace vfs
31
32class MemProfUsePass : public PassInfoMixin<MemProfUsePass> {
33public:
34 LLVM_ABI explicit MemProfUsePass(
35 std::string MemoryProfileFile,
38
39private:
40 // Annotate global variables' section prefix based on data access profile,
41 // return true if any global variable is annotated and false otherwise.
42 bool
43 annotateGlobalVariables(Module &M,
44 const memprof::DataAccessProfData *DataAccessProf);
45 std::string MemoryProfileFileName;
47};
48
49namespace memprof {
50
51// Extract all calls from the IR. Arrange them in a map from caller GUIDs to a
52// list of call sites, each of the form {LineLocation, CalleeGUID}.
54 Module &M, const TargetLibraryInfo &TLI,
55 function_ref<bool(uint64_t)> IsPresentInProfile = [](uint64_t) {
56 return true;
57 });
58
60 uint64_t operator()(const LineLocation &Loc) const {
61 return Loc.getHashCode();
62 }
63};
64
66 std::unordered_map<LineLocation, LineLocation, LineLocationHash>;
67
68// Compute an undrifting map. The result is a map from caller GUIDs to an inner
69// map that maps source locations in the profile to those in the current IR.
72 const TargetLibraryInfo &TLI);
73
74} // namespace memprof
75} // namespace llvm
76
77#endif
#define LLVM_ABI
Definition: Compiler.h:213
This header defines various interfaces for pass management in LLVM.
This file defines the RefCountedBase, ThreadSafeRefCountedBase, and IntrusiveRefCntPtr classes.
Machine Check Debug Module
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:255
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)
Definition: MemProfUse.cpp:689
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.
LLVM_ABI DenseMap< uint64_t, LocToLocMap > computeUndriftMap(Module &M, IndexedInstrProfReader *MemProfReader, const TargetLibraryInfo &TLI)
Definition: MemProfUse.cpp:278
LLVM_ABI DenseMap< uint64_t, SmallVector< CallEdgeTy, 0 > > extractCallsFromIR(Module &M, const TargetLibraryInfo &TLI, function_ref< bool(uint64_t)> IsPresentInProfile=[](uint64_t) { return true;})
Definition: MemProfUse.cpp:203
std::unordered_map< LineLocation, LineLocation, LineLocationHash > LocToLocMap
Definition: MemProfUse.h:66
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:70
uint64_t operator()(const LineLocation &Loc) const
Definition: MemProfUse.h:60
uint64_t getHashCode() const
Definition: MemProf.h:847