diff options
author | Tarindu Jayatilaka <tarindujayatilaka@gmail.com> | 2020-07-23 12:46:47 -0700 |
---|---|---|
committer | Mircea Trofin <mtrofin@google.com> | 2020-07-23 12:46:47 -0700 |
commit | 06283661b34244f2db87aa55f2a40fe65903410e (patch) | |
tree | fcf70a32942ae7521b7eeae8fdfd3aed8a0a1462 /llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp | |
parent | b9c644ec6134dcfac7d3e8806cf3605564fd8ace (diff) | |
download | llvm-06283661b34244f2db87aa55f2a40fe65903410e.zip llvm-06283661b34244f2db87aa55f2a40fe65903410e.tar.gz llvm-06283661b34244f2db87aa55f2a40fe65903410e.tar.bz2 |
Add new function properties to FunctionPropertiesAnalysis
Added LoadInstCount, StoreInstCount, MaxLoopDepth, LoopCount
Reviewed By: jdoerfert, mtrofin
Differential Revision: https://reviews.llvm.org/D82283
Diffstat (limited to 'llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp index 9b7caf15..3db108c 100644 --- a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp +++ b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp @@ -17,7 +17,8 @@ using namespace llvm; FunctionPropertiesInfo -FunctionPropertiesInfo::getFunctionPropertiesInfo(const Function &F) { +FunctionPropertiesInfo::getFunctionPropertiesInfo(const Function &F, + const LoopInfo &LI) { FunctionPropertiesInfo FPI; @@ -40,7 +41,20 @@ FunctionPropertiesInfo::getFunctionPropertiesInfo(const Function &F) { if (Callee && !Callee->isIntrinsic() && !Callee->isDeclaration()) ++FPI.DirectCallsToDefinedFunctions; } + if (I.getOpcode() == Instruction::Load) { + ++FPI.LoadInstCount; + } else if (I.getOpcode() == Instruction::Store) { + ++FPI.StoreInstCount; + } } + // Loop Depth of the Basic Block + int64_t LoopDepth; + LoopDepth = LI.getLoopDepth(&BB); + if (FPI.MaxLoopDepth < LoopDepth) + FPI.MaxLoopDepth = LoopDepth; + } + for (Loop *L : LI) { + ++FPI.TopLevelLoopCount; } return FPI; } @@ -51,14 +65,19 @@ void FunctionPropertiesInfo::print(raw_ostream &OS) const { << BlocksReachedFromConditionalInstruction << "\n" << "Uses: " << Uses << "\n" << "DirectCallsToDefinedFunctions: " << DirectCallsToDefinedFunctions - << "\n\n"; + << "\n" + << "LoadInstCount: " << LoadInstCount << "\n" + << "StoreInstCount: " << StoreInstCount << "\n" + << "MaxLoopDepth: " << MaxLoopDepth << "\n" + << "TopLevelLoopCount: " << TopLevelLoopCount << "\n\n"; } AnalysisKey FunctionPropertiesAnalysis::Key; FunctionPropertiesInfo FunctionPropertiesAnalysis::run(Function &F, FunctionAnalysisManager &FAM) { - return FunctionPropertiesInfo::getFunctionPropertiesInfo(F); + return FunctionPropertiesInfo::getFunctionPropertiesInfo( + F, FAM.getResult<LoopAnalysis>(F)); } PreservedAnalyses |