aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
diff options
context:
space:
mode:
authorTarindu Jayatilaka <tarindujayatilaka@gmail.com>2020-07-23 11:56:56 -0700
committerMircea Trofin <mtrofin@google.com>2020-07-23 11:57:11 -0700
commitee6f0e109cb2376b44f778db63711e92e90c2ef2 (patch)
treeebf89ffe46d2b10c6fbbfb9b2ddb20f3093a3bbd /llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
parentdeb4bb2b3abd216aceaa109a5304f025a234540f (diff)
downloadllvm-ee6f0e109cb2376b44f778db63711e92e90c2ef2.zip
llvm-ee6f0e109cb2376b44f778db63711e92e90c2ef2.tar.gz
llvm-ee6f0e109cb2376b44f778db63711e92e90c2ef2.tar.bz2
Add a Printer to the FunctionPropertiesAnalysis
A printer pass and a lit test case was added. Reviewed By: mtrofin Differential Revision: https://reviews.llvm.org/D82523
Diffstat (limited to 'llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
index 0a085fc..9b7caf15 100644
--- a/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
+++ b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
@@ -1,4 +1,4 @@
-//===- FunctionPropertiesAnalysis.cpp - Function properties extraction ----===//
+//===- FunctionPropertiesAnalysis.cpp - Function Properties Analysis ------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements an analysis extracting function properties, which may be
-// used by ML-driven policies, for example.
+// This file defines the FunctionPropertiesInfo and FunctionPropertiesAnalysis
+// classes used to extract function properties.
//
//===----------------------------------------------------------------------===//
@@ -45,9 +45,27 @@ FunctionPropertiesInfo::getFunctionPropertiesInfo(const Function &F) {
return FPI;
}
+void FunctionPropertiesInfo::print(raw_ostream &OS) const {
+ OS << "BasicBlockCount: " << BasicBlockCount << "\n"
+ << "BlocksReachedFromConditionalInstruction: "
+ << BlocksReachedFromConditionalInstruction << "\n"
+ << "Uses: " << Uses << "\n"
+ << "DirectCallsToDefinedFunctions: " << DirectCallsToDefinedFunctions
+ << "\n\n";
+}
+
AnalysisKey FunctionPropertiesAnalysis::Key;
FunctionPropertiesInfo
FunctionPropertiesAnalysis::run(Function &F, FunctionAnalysisManager &FAM) {
return FunctionPropertiesInfo::getFunctionPropertiesInfo(F);
+}
+
+PreservedAnalyses
+FunctionPropertiesPrinterPass::run(Function &F, FunctionAnalysisManager &AM) {
+ OS << "Printing analysis results of CFA for function "
+ << "'" << F.getName() << "':"
+ << "\n";
+ AM.getResult<FunctionPropertiesAnalysis>(F).print(OS);
+ return PreservedAnalyses::all();
} \ No newline at end of file