LLVM: lib/Analysis/OptimizationRemarkEmitter.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
23#include
24
25using namespace llvm;
26
29 if (->getContext().getDiagnosticsHotnessRequested())
30 return;
31
32
35
36
39
40
42
43
44 OwnedBFI = std::make_unique(*F, BPI, LI);
45 BFI = OwnedBFI.get();
46}
47
51 if (OwnedBFI) {
52 OwnedBFI.reset();
53 BFI = nullptr;
54 }
55
56
58 return true;
59
60
61 return false;
62}
63
64std::optional<uint64_t>
65OptimizationRemarkEmitter::computeHotness(const Value *V) {
66 if (!BFI)
67 return std::nullopt;
68
70}
71
72void OptimizationRemarkEmitter::computeHotness(
75 if (V)
76 OptDiag.setHotness(computeHotness(V));
77}
78
81 auto &OptDiag = cast(OptDiagBase);
82 computeHotness(OptDiag);
83
84
85 if (OptDiag.getHotness().value_or(0) <
87 return;
88 }
89
91}
92
97}
98
101
103 if (Context.getDiagnosticsHotnessRequested()) {
104 BFI = &getAnalysis().getBFI();
105
106 if (Context.isDiagnosticsHotnessThresholdSetFromPSI()) {
108 &getAnalysis().getPSI())
109 Context.setDiagnosticsHotnessThreshold(
110 PSI->getOrCompHotCountThreshold());
111 }
112 } else
113 BFI = nullptr;
114
115 ORE = std::make_unique(&Fn, BFI);
116 return false;
117}
118
124}
125
126AnalysisKey OptimizationRemarkEmitterAnalysis::Key;
127
132 auto &Context = F.getContext();
133
134 if (Context.getDiagnosticsHotnessRequested()) {
136
137 if (Context.isDiagnosticsHotnessThresholdSetFromPSI()) {
141 Context.setDiagnosticsHotnessThreshold(
142 PSI->getOrCompHotCountThreshold());
143 }
144 } else
145 BFI = nullptr;
146
148}
149
151static const char ore_name[] = "Optimization Remark Emitter";
152#define ORE_NAME "opt-remark-emitter"
153
155 false, true)
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
API to communicate dependencies between analyses during invalidation.
bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA)
Trigger the invalidation of some other analysis pass if not already handled and return whether it was...
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
void setPreservesAll()
Set by analyses that do not transform their input at all.
Analysis pass which computes BlockFrequencyInfo.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
std::optional< uint64_t > getBlockProfileCount(const BasicBlock *BB, bool AllowSynthetic=false) const
Returns the estimated profile count of BB.
Analysis providing branch probability information.
Common features for diagnostics dealing with optimization remarks that are used by IR passes.
const Value * getCodeRegion() const
Common features for diagnostics dealing with optimization remarks that are used by both IR and MIR pa...
void setHotness(std::optional< uint64_t > H)
std::optional< uint64_t > getHotness() const
void recalculate(ParentType &Func)
recalculate - compute a dominator tree for the given function
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
FunctionPass class - This class is used to implement most global optimizations.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
uint64_t getDiagnosticsHotnessThreshold() const
Return the minimum hotness value a diagnostic would need in order to be included in optimization diag...
static void getLazyBFIAnalysisUsage(AnalysisUsage &AU)
Helper for client passes to set up the analysis usage on behalf of this pass.
void analyze(const DominatorTreeBase< BlockT, false > &DomTree)
Create the loop forest using a stable algorithm.
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
An analysis pass based on the new PM to deliver ProfileSummaryInfo.
An analysis pass based on legacy pass manager to deliver ProfileSummaryInfo.
Analysis providing profile information.
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
void initializeOptimizationRemarkEmitterWrapperPassPass(PassRegistry &)
A special type used by analysis passes to provide an address that identifies that particular analysis...