LLVM  15.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
12 #include "llvm/InitializePasses.h"
13 
14 using namespace llvm;
15 
16 namespace llvm {
17 class Module;
18 }
19 
21 template class llvm::GenericCycle<SSAContext>;
22 
24  CycleInfo CI;
25  CI.compute(F);
26  return CI;
27 }
28 
30 
32 
35  OS << "CycleInfo for function: " << F.getName() << "\n";
36  AM.getResult<CycleAnalysis>(F).print(OS);
37 
38  return PreservedAnalyses::all();
39 }
40 
41 //===----------------------------------------------------------------------===//
42 // CycleInfoWrapperPass Implementation
43 //===----------------------------------------------------------------------===//
44 //
45 // The implementation details of the wrapper pass that holds a CycleInfo
46 // suitable for use with the legacy pass manager.
47 //
48 //===----------------------------------------------------------------------===//
49 
51 
54 }
55 
56 INITIALIZE_PASS_BEGIN(CycleInfoWrapperPass, "cycles", "Cycle Info Analysis",
57  true, true)
59  true)
60 
61 void CycleInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
62  AU.setPreservesAll();
63 }
64 
66  CI.clear();
67 
68  F = &Func;
69  CI.compute(Func);
70  return false;
71 }
72 
74  OS << "CycleInfo for function: " << F->getName() << "\n";
75  CI.print(OS);
76 }
77 
79  CI.clear();
80  F = nullptr;
81 }
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::CycleInfoWrapperPass::print
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
Definition: CycleAnalysis.cpp:73
print
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
Definition: ArchiveWriter.cpp:189
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:780
llvm::Function
Definition: Function.h:60
CycleAnalysis.h
llvm::initializeCycleInfoWrapperPassPass
void initializeCycleInfoWrapperPassPass(PassRegistry &)
llvm::CycleInfoWrapperPass::releaseMemory
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
Definition: CycleAnalysis.cpp:78
true
Cycle Info true
Definition: CycleAnalysis.cpp:58
F
#define F(x, y, z)
Definition: MD5.cpp:55
Analysis
Cycle Info Analysis
Definition: CycleAnalysis.cpp:58
llvm::CycleAnalysis
Analysis pass which computes a CycleInfo.
Definition: CycleAnalysis.h:31
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
llvm::CycleAnalysis::run
CycleInfo run(Function &F, FunctionAnalysisManager &)
Run the analysis pass over a function and produce a dominator tree.
Definition: CycleAnalysis.cpp:23
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:486
llvm::GenericCycle
A possibly irreducible generalization of a Loop.
Definition: GenericCycleInfo.h:48
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::CycleInfoWrapperPass::ID
static char ID
Definition: CycleAnalysis.h:61
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:58
llvm::GenericCycleInfo::compute
void compute(FunctionT &F)
Compute the cycle info for a function.
Definition: GenericCycleImpl.h:305
CFG.h
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:69
llvm::CycleInfoWrapperPass::CycleInfoWrapperPass
CycleInfoWrapperPass()
Definition: CycleAnalysis.cpp:52
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::GenericCycleInfo< SSAContext >
INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_BEGIN(CycleInfoWrapperPass, "cycles", "Cycle Info Analysis", true, true) INITIALIZE_PASS_END(CycleInfoWrapperPass
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
llvm::GenericCycleInfo::print
void print(raw_ostream &Out) const
Print the cycle info.
Definition: GenericCycleImpl.h:399
llvm::CycleInfoWrapperPass::runOnFunction
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Definition: CycleAnalysis.cpp:65
llvm::GenericCycleInfo::clear
void clear()
Reset the object to its initial state.
Definition: GenericCycleImpl.h:298
GenericCycleImpl.h
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:308
llvm::CycleInfoWrapperPass
Legacy analysis pass which computes a CycleInfo.
Definition: CycleAnalysis.h:56
llvm::CycleInfoPrinterPass::CycleInfoPrinterPass
CycleInfoPrinterPass(raw_ostream &OS)
Definition: CycleAnalysis.cpp:31
cycles
cycles
Definition: CycleAnalysis.cpp:58
InitializePasses.h
llvm::CycleInfoPrinterPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: CycleAnalysis.cpp:33