[llvm] 44a6bda - Rename InlineFeatureAnalysis to FunctionPropertiesAnalysis
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 22 09:24:26 PDT 2020
Author: Mircea Trofin
Date: 2020-07-22T09:24:15-07:00
New Revision: 44a6bda19b40f2dfcbe92fc3d58bb6276c71ef78
URL: https://github.com/llvm/llvm-project/commit/44a6bda19b40f2dfcbe92fc3d58bb6276c71ef78
DIFF: https://github.com/llvm/llvm-project/commit/44a6bda19b40f2dfcbe92fc3d58bb6276c71ef78.diff
LOG: Rename InlineFeatureAnalysis to FunctionPropertiesAnalysis
Rename the pass to be able to extend it to function properties other than inliner features.
Reviewed By: mtrofin
Differential Revision: https://reviews.llvm.org/D82044
Added:
llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
Modified:
llvm/lib/Analysis/CMakeLists.txt
llvm/lib/Analysis/MLInlineAdvisor.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Passes/PassRegistry.def
llvm/unittests/Analysis/CMakeLists.txt
Removed:
llvm/include/llvm/Analysis/InlineFeaturesAnalysis.h
llvm/lib/Analysis/InlineFeaturesAnalysis.cpp
llvm/unittests/Analysis/InlineFeaturesAnalysisTest.cpp
################################################################################
diff --git a/llvm/include/llvm/Analysis/InlineFeaturesAnalysis.h b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
similarity index 80%
rename from llvm/include/llvm/Analysis/InlineFeaturesAnalysis.h
rename to llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
index cc3f96c424e9..0163e69ac9dd 100644
--- a/llvm/include/llvm/Analysis/InlineFeaturesAnalysis.h
+++ b/llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
@@ -1,4 +1,4 @@
-//===- InlineFeaturesAnalysis.h - ML Policy Feature extraction -*- C++ -*-===//
+//=- FunctionPropertiesAnalysis.h - Function Properties extraction -*- C++ -=//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,16 +6,16 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_INLINEFEATURESANALYSIS_H_
-#define LLVM_INLINEFEATURESANALYSIS_H_
+#ifndef LLVM_FUNCTIONPROPERTIESANALYSIS_H_
+#define LLVM_FUNCTIONPROPERTIESANALYSIS_H_
#include "llvm/IR/PassManager.h"
namespace llvm {
class Function;
-class InlineFeaturesAnalysis
- : public AnalysisInfoMixin<InlineFeaturesAnalysis> {
+class FunctionPropertiesAnalysis
+ : public AnalysisInfoMixin<FunctionPropertiesAnalysis> {
public:
static AnalysisKey Key;
struct Result {
@@ -42,4 +42,4 @@ class InlineFeaturesAnalysis
};
} // namespace llvm
-#endif // LLVM_INLINEFEATURESANALYSIS_H_
\ No newline at end of file
+#endif // LLVM_FUNCTIONPROPERTIESANALYSIS_H_
\ No newline at end of file
diff --git a/llvm/lib/Analysis/CMakeLists.txt b/llvm/lib/Analysis/CMakeLists.txt
index 4d7eeaf910eb..8bb37697a6af 100644
--- a/llvm/lib/Analysis/CMakeLists.txt
+++ b/llvm/lib/Analysis/CMakeLists.txt
@@ -49,6 +49,7 @@ add_llvm_component_library(LLVMAnalysis
DomTreeUpdater.cpp
DominanceFrontier.cpp
EHPersonalities.cpp
+ FunctionPropertiesAnalysis.cpp
GlobalsModRef.cpp
GuardUtils.cpp
HeatUtils.cpp
@@ -57,7 +58,6 @@ add_llvm_component_library(LLVMAnalysis
IndirectCallPromotionAnalysis.cpp
InlineCost.cpp
InlineAdvisor.cpp
- InlineFeaturesAnalysis.cpp
InlineSizeEstimatorAnalysis.cpp
InstCount.cpp
InstructionPrecedenceTracking.cpp
diff --git a/llvm/lib/Analysis/InlineFeaturesAnalysis.cpp b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
similarity index 80%
rename from llvm/lib/Analysis/InlineFeaturesAnalysis.cpp
rename to llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
index 90f521bbaab4..a0fc017568f2 100644
--- a/llvm/lib/Analysis/InlineFeaturesAnalysis.cpp
+++ b/llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
@@ -1,4 +1,4 @@
-//===- InlineFeaturesAnalysis.cpp - Feature extraction for ML Policies ----===//
+//===- FunctionPropertiesAnalysis.cpp - Function properties extraction ----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,15 +11,16 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Analysis/InlineFeaturesAnalysis.h"
+#include "llvm/Analysis/FunctionPropertiesAnalysis.h"
#include "llvm/IR/Instructions.h"
using namespace llvm;
-AnalysisKey InlineFeaturesAnalysis::Key;
+AnalysisKey FunctionPropertiesAnalysis::Key;
-InlineFeaturesAnalysis::Result
-InlineFeaturesAnalysis::run(const Function &F, FunctionAnalysisManager &FAM) {
+FunctionPropertiesAnalysis::Result
+FunctionPropertiesAnalysis::run(const Function &F,
+ FunctionAnalysisManager &FAM) {
Result Ret;
Ret.Uses = ((!F.hasLocalLinkage()) ? 1 : 0) + F.getNumUses();
for (const auto &BB : F) {
diff --git a/llvm/lib/Analysis/MLInlineAdvisor.cpp b/llvm/lib/Analysis/MLInlineAdvisor.cpp
index 31cb43baf9a5..e697af97eb07 100644
--- a/llvm/lib/Analysis/MLInlineAdvisor.cpp
+++ b/llvm/lib/Analysis/MLInlineAdvisor.cpp
@@ -20,8 +20,8 @@
#include "llvm/ADT/SCCIterator.h"
#include "llvm/Analysis/CallGraph.h"
+#include "llvm/Analysis/FunctionPropertiesAnalysis.h"
#include "llvm/Analysis/InlineCost.h"
-#include "llvm/Analysis/InlineFeaturesAnalysis.h"
#include "llvm/Analysis/MLInlineAdvisor.h"
#include "llvm/Analysis/MLModelRunner.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
@@ -118,7 +118,8 @@ void MLInlineAdvisor::onPassEntry() {
}
int64_t MLInlineAdvisor::getLocalCalls(Function &F) {
- return FAM.getResult<InlineFeaturesAnalysis>(F).DirectCallsToDefinedFunctions;
+ return FAM.getResult<FunctionPropertiesAnalysis>(F)
+ .DirectCallsToDefinedFunctions;
}
// Update the internal state of the advisor, and force invalidate feature
@@ -133,7 +134,7 @@ void MLInlineAdvisor::onSuccessfulInlining(const MLInlineAdvice &Advice,
Function *Callee = Advice.getCallee();
// The caller features aren't valid anymore.
- FAM.invalidate<InlineFeaturesAnalysis>(*Caller);
+ FAM.invalidate<FunctionPropertiesAnalysis>(*Caller);
int64_t IRSizeAfter =
getIRSize(*Caller) + (CalleeWasDeleted ? 0 : Advice.CalleeIRSize);
CurrentIRSize += IRSizeAfter - (Advice.CallerIRSize + Advice.CalleeIRSize);
@@ -146,14 +147,15 @@ void MLInlineAdvisor::onSuccessfulInlining(const MLInlineAdvice &Advice,
// For edges, we 'forget' the edges that the caller and callee used to have
// before inlining, and add back what they currently have together.
int64_t NewCallerAndCalleeEdges =
- FAM.getResult<InlineFeaturesAnalysis>(*Caller)
+ FAM.getResult<FunctionPropertiesAnalysis>(*Caller)
.DirectCallsToDefinedFunctions;
if (CalleeWasDeleted)
--NodeCount;
else
- NewCallerAndCalleeEdges += FAM.getResult<InlineFeaturesAnalysis>(*Callee)
- .DirectCallsToDefinedFunctions;
+ NewCallerAndCalleeEdges +=
+ FAM.getResult<FunctionPropertiesAnalysis>(*Callee)
+ .DirectCallsToDefinedFunctions;
EdgeCount += (NewCallerAndCalleeEdges - Advice.CallerAndCalleeEdges);
assert(CurrentIRSize >= 0 && EdgeCount >= 0 && NodeCount >= 0);
}
@@ -224,8 +226,8 @@ std::unique_ptr<InlineAdvice> MLInlineAdvisor::getAdvice(CallBase &CB) {
NrCtantParams += (isa<Constant>(*I));
}
- auto &CallerBefore = FAM.getResult<InlineFeaturesAnalysis>(Caller);
- auto &CalleeBefore = FAM.getResult<InlineFeaturesAnalysis>(Callee);
+ auto &CallerBefore = FAM.getResult<FunctionPropertiesAnalysis>(Caller);
+ auto &CalleeBefore = FAM.getResult<FunctionPropertiesAnalysis>(Callee);
ModelRunner->setFeature(FeatureIndex::CalleeBasicBlockCount,
CalleeBefore.BasicBlockCount);
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index b534853a1213..771675d35fdf 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -31,10 +31,10 @@
#include "llvm/Analysis/DemandedBits.h"
#include "llvm/Analysis/DependenceAnalysis.h"
#include "llvm/Analysis/DominanceFrontier.h"
+#include "llvm/Analysis/FunctionPropertiesAnalysis.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/IVUsers.h"
#include "llvm/Analysis/InlineAdvisor.h"
-#include "llvm/Analysis/InlineFeaturesAnalysis.h"
#include "llvm/Analysis/InlineSizeEstimatorAnalysis.h"
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/Analysis/LazyValueInfo.h"
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index ad20d02436da..f323d37ca46a 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -132,7 +132,7 @@ FUNCTION_ANALYSIS("domfrontier", DominanceFrontierAnalysis())
FUNCTION_ANALYSIS("loops", LoopAnalysis())
FUNCTION_ANALYSIS("lazy-value-info", LazyValueAnalysis())
FUNCTION_ANALYSIS("da", DependenceAnalysis())
-FUNCTION_ANALYSIS("inliner-features", InlineFeaturesAnalysis())
+FUNCTION_ANALYSIS("func-properties", FunctionPropertiesAnalysis())
FUNCTION_ANALYSIS("inliner-size-estimator", InlineSizeEstimatorAnalysis())
FUNCTION_ANALYSIS("memdep", MemoryDependenceAnalysis())
FUNCTION_ANALYSIS("memoryssa", MemorySSAAnalysis())
diff --git a/llvm/unittests/Analysis/CMakeLists.txt b/llvm/unittests/Analysis/CMakeLists.txt
index b1b396a897ca..eb97f6289b67 100644
--- a/llvm/unittests/Analysis/CMakeLists.txt
+++ b/llvm/unittests/Analysis/CMakeLists.txt
@@ -27,7 +27,7 @@ add_llvm_unittest_with_input_files(AnalysisTests
DivergenceAnalysisTest.cpp
DomTreeUpdaterTest.cpp
GlobalsModRefTest.cpp
- InlineFeaturesAnalysisTest.cpp
+ FunctionPropertiesAnalysisTest.cpp
IVDescriptorsTest.cpp
LazyCallGraphTest.cpp
LoadsTest.cpp
diff --git a/llvm/unittests/Analysis/InlineFeaturesAnalysisTest.cpp b/llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
similarity index 90%
rename from llvm/unittests/Analysis/InlineFeaturesAnalysisTest.cpp
rename to llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
index a3df767b7650..399c6dd4f7de 100644
--- a/llvm/unittests/Analysis/InlineFeaturesAnalysisTest.cpp
+++ b/llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp
@@ -1,4 +1,4 @@
-//===- InlineFeaturesAnalysisTest.cpp - inline features unit tests --------===//
+//===- FunctionPropertiesAnalysisTest.cpp - function properties unit tests-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Analysis/InlineFeaturesAnalysis.h"
+#include "llvm/Analysis/FunctionPropertiesAnalysis.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
@@ -24,7 +24,7 @@ static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
return Mod;
}
-TEST(InlineFeaturesTest, BasicTest) {
+TEST(FunctionPropertiesTest, BasicTest) {
LLVMContext C;
std::unique_ptr<Module> M = parseIR(C,
R"IR(
@@ -59,7 +59,7 @@ define internal i32 @top() {
)IR");
FunctionAnalysisManager FAM;
- InlineFeaturesAnalysis FA;
+ FunctionPropertiesAnalysis FA;
auto BranchesFeatures = FA.run(*M->getFunction("branches"), FAM);
EXPECT_EQ(BranchesFeatures.BasicBlockCount, 4);
More information about the llvm-commits
mailing list