LLVM  10.0.0svn
ModuleSummaryAnalysis.h
Go to the documentation of this file.
1 //===- ModuleSummaryAnalysis.h - Module summary index builder ---*- 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 /// \file
9 /// This is the interface to build a ModuleSummaryIndex for a module.
10 ///
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_ANALYSIS_MODULESUMMARYANALYSIS_H
14 #define LLVM_ANALYSIS_MODULESUMMARYANALYSIS_H
15 
16 #include "llvm/ADT/Optional.h"
18 #include "llvm/IR/PassManager.h"
19 #include "llvm/Pass.h"
20 #include <functional>
21 
22 namespace llvm {
23 
24 class BlockFrequencyInfo;
25 class Function;
26 class Module;
27 class ProfileSummaryInfo;
28 
29 /// Direct function to compute a \c ModuleSummaryIndex from a given module.
30 ///
31 /// If operating within a pass manager which has defined ways to compute the \c
32 /// BlockFrequencyInfo for a given function, that can be provided via
33 /// a std::function callback. Otherwise, this routine will manually construct
34 /// that information.
35 ModuleSummaryIndex buildModuleSummaryIndex(
36  const Module &M,
37  std::function<BlockFrequencyInfo *(const Function &F)> GetBFICallback,
38  ProfileSummaryInfo *PSI);
39 
40 /// Analysis pass to provide the ModuleSummaryIndex object.
42  : public AnalysisInfoMixin<ModuleSummaryIndexAnalysis> {
44 
45  static AnalysisKey Key;
46 
47 public:
49 
51 };
52 
53 /// Legacy wrapper pass to provide the ModuleSummaryIndex object.
56 
57 public:
58  static char ID;
59 
61 
62  /// Get the index built by pass
64  const ModuleSummaryIndex &getIndex() const { return *Index; }
65 
66  bool runOnModule(Module &M) override;
67  bool doFinalization(Module &M) override;
68  void getAnalysisUsage(AnalysisUsage &AU) const override;
69 };
70 
71 //===--------------------------------------------------------------------===//
72 //
73 // createModuleSummaryIndexWrapperPass - This pass builds a ModuleSummaryIndex
74 // object for the module, to be written to bitcode or LLVM assembly.
75 //
77 
78 } // end namespace llvm
79 
80 #endif // LLVM_ANALYSIS_MODULESUMMARYANALYSIS_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
F(f)
Analysis pass to provide the ModuleSummaryIndex object.
ModuleSummaryIndex buildModuleSummaryIndex(const Module &M, std::function< BlockFrequencyInfo *(const Function &F)> GetBFICallback, ProfileSummaryInfo *PSI)
Direct function to compute a ModuleSummaryIndex from a given module.
const ModuleSummaryIndex & getIndex() const
ModuleSummaryIndex & getIndex()
Get the index built by pass.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:389
Represent the analysis usage information of a pass.
Result run(Module &M, ModuleAnalysisManager &AM)
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:224
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
ModulePass * createModuleSummaryIndexWrapperPass()
print Print MemDeps of function
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:70
Legacy wrapper pass to provide the ModuleSummaryIndex object.