LLVM 24.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 for
10// profile-guided memory optimization (MemPGO).
11//
12//===----------------------------------------------------------------------===//
13#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFUSE_H
14#define LLVM_TRANSFORMS_INSTRUMENTATION_MEMPROFUSE_H
15
17#include "llvm/IR/PassManager.h"
22
23namespace llvm {
25class Module;
27
28class MemProfUsePass : public OptionalPassInfoMixin<MemProfUsePass> {
29public:
30 LLVM_ABI explicit MemProfUsePass(
31 std::string MemoryProfileFile,
34
35private:
36 // Annotate global variables' section prefix based on data access profile,
37 // return true if any global variable is annotated and false otherwise.
38 bool
39 annotateGlobalVariables(Module &M,
40 const memprof::DataAccessProfData *DataAccessProf);
41 std::string MemoryProfileFileName;
43};
44
45namespace memprof {
46
47// Extract all calls from the IR. Arrange them in a map from caller GUIDs to a
48// list of call sites, each of the form {LineLocation, CalleeGUID}.
50 Module &M, const TargetLibraryInfo &TLI,
51 function_ref<bool(uint64_t)> IsPresentInProfile = [](uint64_t) {
52 return true;
53 });
54
56
57// Compute an undrifting map. The result is a map from caller GUIDs to an inner
58// map that maps source locations in the profile to those in the current IR.
61 const TargetLibraryInfo &TLI);
62
63} // namespace memprof
64} // namespace llvm
65
66#endif
const TargetLowering & TLI
uint64_t uint64_t
#define LLVM_ABI
Definition Compiler.h:211
This header defines various interfaces for pass management in LLVM.
This file defines the RefCountedBase, ThreadSafeRefCountedBase, and IntrusiveRefCntPtr classes.
Contains the forward declaration for vfs::FileSystem, as well as the IntrusiveRefCntPtrInfo specializ...
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:68
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)
DenseMap< LineLocation, LineLocation > LocToLocMap
Definition MemProfUse.h:55
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.