1//==- MemProfContextDisambiguation.h - Context Disambiguation ----*- 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// Implements support for context disambiguation of allocation calls for profile
10// guided heap optimization using memprof metadata. See implementation file for
11// details.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TRANSFORMS_IPO_MEMPROF_CONTEXT_DISAMBIGUATION_H
16#define LLVM_TRANSFORMS_IPO_MEMPROF_CONTEXT_DISAMBIGUATION_H
17
18#include "llvm/IR/GlobalValue.h"
19#include "llvm/IR/ModuleSummaryIndex.h"
20#include "llvm/IR/PassManager.h"
21#include <functional>
22
23namespace llvm {
24class GlobalValueSummary;
25class Module;
26class OptimizationRemarkEmitter;
27
28class MemProfContextDisambiguation
29 : public PassInfoMixin<MemProfContextDisambiguation> {
30 /// Run the context disambiguator on \p M, returns true if any changes made.
31 bool processModule(
32 Module &M,
33 function_ref<OptimizationRemarkEmitter &(Function *)> OREGetter);
34
35 /// In the ThinLTO backend, apply the cloning decisions in ImportSummary to
36 /// the IR.
37 bool applyImport(Module &M);
38
39 /// Import summary containing cloning decisions for the ThinLTO backend.
40 const ModuleSummaryIndex *ImportSummary;
41
42 // Owns the import summary specified by internal options for testing the
43 // ThinLTO backend via opt (to simulate distributed ThinLTO).
44 std::unique_ptr<ModuleSummaryIndex> ImportSummaryForTesting;
45
46public:
47 MemProfContextDisambiguation(const ModuleSummaryIndex *Summary = nullptr);
48
49 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
50
51 void run(ModuleSummaryIndex &Index,
52 function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
53 isPrevailing);
54};
55} // end namespace llvm
56
57#endif // LLVM_TRANSFORMS_IPO_MEMPROF_CONTEXT_DISAMBIGUATION_H
58

source code of llvm/include/llvm/Transforms/IPO/MemProfContextDisambiguation.h