summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h')
-rw-r--r--contrib/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h62
1 files changed, 23 insertions, 39 deletions
diff --git a/contrib/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h b/contrib/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
index 9f03610..4f77170 100644
--- a/contrib/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
+++ b/contrib/llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
@@ -16,48 +16,39 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
namespace llvm {
-
class BlockFrequencyInfo;
+class ProfileSummaryInfo;
-/// Class to build a module summary index for the given Module, possibly from
-/// a Pass.
-class ModuleSummaryIndexBuilder {
- /// The index being built
- std::unique_ptr<ModuleSummaryIndex> Index;
- /// The module for which we are building an index
- const Module *M;
+/// Direct function to compute a \c ModuleSummaryIndex from a given module.
+///
+/// If operating within a pass manager which has defined ways to compute the \c
+/// BlockFrequencyInfo for a given function, that can be provided via
+/// a std::function callback. Otherwise, this routine will manually construct
+/// that information.
+ModuleSummaryIndex buildModuleSummaryIndex(
+ const Module &M,
+ std::function<BlockFrequencyInfo *(const Function &F)> GetBFICallback,
+ ProfileSummaryInfo *PSI);
+
+/// Analysis pass to provide the ModuleSummaryIndex object.
+class ModuleSummaryIndexAnalysis
+ : public AnalysisInfoMixin<ModuleSummaryIndexAnalysis> {
+ friend AnalysisInfoMixin<ModuleSummaryIndexAnalysis>;
+ static AnalysisKey Key;
public:
- /// Default constructor
- ModuleSummaryIndexBuilder() = default;
-
- /// Constructor that builds an index for the given Module. An optional
- /// callback can be supplied to obtain the frequency info for a function.
- ModuleSummaryIndexBuilder(
- const Module *M,
- std::function<BlockFrequencyInfo *(const Function &F)> Ftor = nullptr);
-
- /// Get a reference to the index owned by builder
- ModuleSummaryIndex &getIndex() const { return *Index; }
+ typedef ModuleSummaryIndex Result;
- /// Take ownership of the built index
- std::unique_ptr<ModuleSummaryIndex> takeIndex() { return std::move(Index); }
-
-private:
- /// Compute summary for given function with optional frequency information
- void computeFunctionSummary(const Function &F,
- BlockFrequencyInfo *BFI = nullptr);
-
- /// Compute summary for given variable with optional frequency information
- void computeVariableSummary(const GlobalVariable &V);
+ Result run(Module &M, ModuleAnalysisManager &AM);
};
/// Legacy wrapper pass to provide the ModuleSummaryIndex object.
class ModuleSummaryIndexWrapperPass : public ModulePass {
- std::unique_ptr<ModuleSummaryIndexBuilder> IndexBuilder;
+ Optional<ModuleSummaryIndex> Index;
public:
static char ID;
@@ -65,10 +56,8 @@ public:
ModuleSummaryIndexWrapperPass();
/// Get the index built by pass
- ModuleSummaryIndex &getIndex() { return IndexBuilder->getIndex(); }
- const ModuleSummaryIndex &getIndex() const {
- return IndexBuilder->getIndex();
- }
+ ModuleSummaryIndex &getIndex() { return *Index; }
+ const ModuleSummaryIndex &getIndex() const { return *Index; }
bool runOnModule(Module &M) override;
bool doFinalization(Module &M) override;
@@ -81,11 +70,6 @@ public:
// object for the module, to be written to bitcode or LLVM assembly.
//
ModulePass *createModuleSummaryIndexWrapperPass();
-
-/// Returns true if \p M is eligible for ThinLTO promotion.
-///
-/// Currently we check if it has any any InlineASM that uses an internal symbol.
-bool moduleCanBeRenamedForThinLTO(const Module &M);
}
#endif
OpenPOWER on IntegriCloud