LLVM 20.0.0git
CycleAnalysis.cpp
Go to the documentation of this file.
1//===- CycleAnalysis.cpp - Compute CycleInfo for LLVM IR ------------------===//
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
11#include "llvm/IR/CFG.h" // for successors found by ADL in GenericCycleImpl.h
13
14using namespace llvm;
15
16namespace llvm {
17class Module;
18} // namespace llvm
19
21 CycleInfo CI;
22 CI.compute(F);
23 return CI;
24}
25
26AnalysisKey CycleAnalysis::Key;
27
29
32 OS << "CycleInfo for function: " << F.getName() << "\n";
34
36}
37
41 CI.verify();
43}
44
45//===----------------------------------------------------------------------===//
46// CycleInfoWrapperPass Implementation
47//===----------------------------------------------------------------------===//
48//
49// The implementation details of the wrapper pass that holds a CycleInfo
50// suitable for use with the legacy pass manager.
51//
52//===----------------------------------------------------------------------===//
53
55
58}
59
60INITIALIZE_PASS_BEGIN(CycleInfoWrapperPass, "cycles", "Cycle Info Analysis",
61 true, true)
63 true)
64
65void CycleInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
66 AU.setPreservesAll();
67}
68
70 CI.clear();
71
72 F = &Func;
73 CI.compute(Func);
74 return false;
75}
76
78 OS << "CycleInfo for function: " << F->getName() << "\n";
79 CI.print(OS);
80}
81
83 CI.clear();
84 F = nullptr;
85}
basic Basic Alias true
block Block Frequency Analysis
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
cycles
This file declares an analysis pass that computes CycleInfo for LLVM IR, specialized from GenericCycl...
This template implementation resides in a separate file so that it does not get injected into every ....
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
#define F(x, y, z)
Definition: MD5.cpp:55
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:57
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:52
raw_pwrite_stream & OS
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:405
Represent the analysis usage information of a pass.
Analysis pass which computes a CycleInfo.
Definition: CycleAnalysis.h:46
CycleInfo run(Function &F, FunctionAnalysisManager &)
Run the analysis pass over a function and produce a dominator tree.
CycleInfoPrinterPass(raw_ostream &OS)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Legacy analysis pass which computes a CycleInfo.
Definition: CycleAnalysis.h:25
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:310
void verify() const
Verify that the entire cycle tree well-formed.
void print(raw_ostream &Out) const
Print the cycle info.
void clear()
Reset the object to its initial state.
void compute(FunctionT &F)
Compute the cycle info for a function.
A possibly irreducible generalization of a Loop.
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
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.
Definition: Analysis.h:111
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:117
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void initializeCycleInfoWrapperPassPass(PassRegistry &)
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr)
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:28
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)