26int64_t getNrBlocksFromCond(
const BasicBlock &BB) {
28 if (
const auto *BI = dyn_cast<BranchInst>(BB.
getTerminator())) {
29 if (BI->isConditional())
30 Ret += BI->getNumSuccessors();
31 }
else if (
const auto *SI = dyn_cast<SwitchInst>(BB.
getTerminator())) {
32 Ret += (
SI->getNumCases() + (
nullptr !=
SI->getDefaultDest()));
38 return ((!
F.hasLocalLinkage()) ? 1 : 0) +
F.getNumUses();
42void FunctionPropertiesInfo::reIncludeBB(
const BasicBlock &BB) {
46void FunctionPropertiesInfo::updateForBB(
const BasicBlock &BB,
52 for (
const auto &
I : BB) {
53 if (
auto *CS = dyn_cast<CallBase>(&
I)) {
54 const auto *
Callee = CS->getCalledFunction();
58 if (
I.getOpcode() == Instruction::Load) {
60 }
else if (
I.getOpcode() == Instruction::Store) {
67void FunctionPropertiesInfo::updateAggregateStats(
const Function &
F,
73 std::deque<const Loop *> Worklist;
75 while (!Worklist.empty()) {
76 const auto *
L = Worklist.front();
78 std::max(
MaxLoopDepth,
static_cast<int64_t
>(
L->getLoopDepth()));
92 for (
const auto &BB :
F)
93 if (DT.isReachableFromEntry(&BB))
95 FPI.updateAggregateStats(
F, LI);
101 <<
"BlocksReachedFromConditionalInstruction: "
103 <<
"Uses: " <<
Uses <<
"\n"
122 OS <<
"Printing analysis results of CFA for function "
123 <<
"'" <<
F.getName() <<
"':"
132 assert(isa<CallInst>(CB) || isa<InvokeInst>(CB));
139 LikelyToChangeBBs.
insert(&CallSiteBB);
156 if (
const auto *II = dyn_cast<InvokeInst>(&CB)) {
157 const auto *UnwindDest = II->getUnwindDest();
166 Successors.erase(&CallSiteBB);
168 for (
const auto *BB : Successors)
169 LikelyToChangeBBs.
insert(BB);
175 for (
const auto *BB : LikelyToChangeBBs)
176 FPI.updateForBB(*BB, -1);
209 if (&CallSiteBB != &*Caller.
begin())
213 for (
const auto *Succ : Successors)
214 if (DT.isReachableFromEntry(Succ))
223 const auto IncludeSuccessorsMark = Reinclude.
size();
224 bool CSInsertion = Reinclude.
insert(&CallSiteBB);
227 for (
size_t I = 0;
I < Reinclude.
size(); ++
I) {
228 const auto *BB = Reinclude[
I];
229 FPI.reIncludeBB(*BB);
230 if (
I >= IncludeSuccessorsMark)
238 const auto AlreadyExcludedMark = Unreachable.
size();
239 for (
size_t I = 0;
I < Unreachable.
size(); ++
I) {
240 const auto *U = Unreachable[
I];
241 if (
I >= AlreadyExcludedMark)
242 FPI.updateForBB(*U, -1);
244 if (!DT.isReachableFromEntry(Succ))
249 FPI.updateAggregateStats(Caller, LI);
amdgpu Simplify well known AMD library false FunctionCallee Callee
static const Function * getParent(const Value *V)
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
Loop::LoopBounds::Direction Direction
FunctionAnalysisManager FAM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
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.
LLVM Basic Block Representation.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Analysis pass which computes a DominatorTree.
FunctionPropertiesInfo run(Function &F, FunctionAnalysisManager &FAM)
int64_t BasicBlockCount
Number of basic blocks.
int64_t Uses
Number of uses of this function, plus 1 if the function is callable outside the module.
int64_t TopLevelLoopCount
int64_t BlocksReachedFromConditionalInstruction
Number of blocks reached from a conditional instruction, or that are 'cases' of a SwitchInstr.
static FunctionPropertiesInfo getFunctionPropertiesInfo(const Function &F, FunctionAnalysisManager &FAM)
void print(raw_ostream &OS) const
int64_t TotalInstructionCount
int64_t DirectCallsToDefinedFunctions
Number of direct calls made from this function to other functions defined in this module.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
void finish(FunctionAnalysisManager &FAM) const
FunctionPropertiesUpdater(FunctionPropertiesInfo &FPI, const CallBase &CB)
Analysis pass that exposes the LoopInfo for a function.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
A vector that has set insertion semantics.
size_type size() const
Determine the number of elements in the SetVector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
Interval::succ_iterator succ_end(Interval *I)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
auto successors(const MachineBasicBlock *BB)
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
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...
Direction
An enum for the direction of the loop.