LLVM 18.0.0git
InlineOrder.h
Go to the documentation of this file.
1//===- InlineOrder.h - Inlining order abstraction -*- 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#ifndef LLVM_ANALYSIS_INLINEORDER_H
10#define LLVM_ANALYSIS_INLINEORDER_H
11
14#include <utility>
15
16namespace llvm {
17class CallBase;
18
19template <typename T> class InlineOrder {
20public:
21 virtual ~InlineOrder() = default;
22
23 virtual size_t size() = 0;
24
25 virtual void push(const T &Elt) = 0;
26
27 virtual T pop() = 0;
28
29 virtual void erase_if(function_ref<bool(T)> Pred) = 0;
30
31 bool empty() { return !size(); }
32};
33
34std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>>
35getDefaultInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params,
36 ModuleAnalysisManager &MAM, Module &M);
37
38std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>>
39getInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params,
40 ModuleAnalysisManager &MAM, Module &M);
41
42/// Used for dynamically loading instances of InlineOrder as plugins
43///
44/// Plugins must implement an InlineOrderFactory, for an example refer to:
45/// llvm/unittests/Analysis/InlineOrderPlugin/InlineOrderPlugin.cpp
46///
47/// If a PluginInlineOrderAnalysis has been registered with the
48/// current ModuleAnalysisManager, llvm::getInlineOrder returns an
49/// InlineOrder created by the PluginInlineOrderAnalysis' Factory.
50///
52 : public AnalysisInfoMixin<PluginInlineOrderAnalysis> {
53public:
55
56 typedef std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>> (
58 const InlineParams &Params,
60
61 PluginInlineOrderAnalysis(InlineOrderFactory Factory) : Factory(Factory) {
62 HasBeenRegistered = true;
63 assert(Factory != nullptr &&
64 "The plugin inline order factory should not be a null pointer.");
65 }
66
67 struct Result {
69 };
70
71 Result run(Module &, ModuleAnalysisManager &) { return {Factory}; }
72 Result getResult() { return {Factory}; }
73
74 static bool isRegistered() { return HasBeenRegistered; }
75 static void unregister() { HasBeenRegistered = false; }
76
77private:
78 static bool HasBeenRegistered;
79 InlineOrderFactory Factory;
80};
81
82} // namespace llvm
83#endif // LLVM_ANALYSIS_INLINEORDER_H
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:620
virtual T pop()=0
virtual size_t size()=0
virtual void erase_if(function_ref< bool(T)> Pred)=0
virtual ~InlineOrder()=default
virtual void push(const T &Elt)=0
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
Used for dynamically loading instances of InlineOrder as plugins.
Definition: InlineOrder.h:52
PluginInlineOrderAnalysis(InlineOrderFactory Factory)
Definition: InlineOrder.h:61
std::unique_ptr< InlineOrder< std::pair< CallBase *, int > > >(* InlineOrderFactory)(FunctionAnalysisManager &FAM, const InlineParams &Params, ModuleAnalysisManager &MAM, Module &M)
Definition: InlineOrder.h:57
Result run(Module &, ModuleAnalysisManager &)
Definition: InlineOrder.h:71
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition: PassManager.h:907
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
Definition: PassManager.h:912
std::unique_ptr< InlineOrder< std::pair< CallBase *, int > > > getDefaultInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params, ModuleAnalysisManager &MAM, Module &M)
std::unique_ptr< InlineOrder< std::pair< CallBase *, int > > > getInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params, ModuleAnalysisManager &MAM, Module &M)
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:394
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:69
Thresholds to tune inline cost analysis.
Definition: InlineCost.h:205