mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
Revert "Rename InlineFeatureAnalysis to FunctionPropertiesAnalysis"
This reverts commit 44a6bda19b40f2dfcbe92fc3d58bb6276c71ef78. I forgot to correctly attibute it to tarinduj. Fixing and resubmitting.
This commit is contained in:
parent
71ef60fd8c
commit
949ac3f54d
@ -1,4 +1,4 @@
|
|||||||
//=- FunctionPropertiesAnalysis.h - Function Properties extraction -*- C++ -=//
|
//===- InlineFeaturesAnalysis.h - ML Policy Feature extraction -*- C++ -*-===//
|
||||||
//
|
//
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
@ -6,16 +6,16 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#ifndef LLVM_FUNCTIONPROPERTIESANALYSIS_H_
|
#ifndef LLVM_INLINEFEATURESANALYSIS_H_
|
||||||
#define LLVM_FUNCTIONPROPERTIESANALYSIS_H_
|
#define LLVM_INLINEFEATURESANALYSIS_H_
|
||||||
|
|
||||||
#include "llvm/IR/PassManager.h"
|
#include "llvm/IR/PassManager.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class Function;
|
class Function;
|
||||||
|
|
||||||
class FunctionPropertiesAnalysis
|
class InlineFeaturesAnalysis
|
||||||
: public AnalysisInfoMixin<FunctionPropertiesAnalysis> {
|
: public AnalysisInfoMixin<InlineFeaturesAnalysis> {
|
||||||
public:
|
public:
|
||||||
static AnalysisKey Key;
|
static AnalysisKey Key;
|
||||||
struct Result {
|
struct Result {
|
||||||
@ -42,4 +42,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
#endif // LLVM_FUNCTIONPROPERTIESANALYSIS_H_
|
#endif // LLVM_INLINEFEATURESANALYSIS_H_
|
@ -49,7 +49,6 @@ add_llvm_component_library(LLVMAnalysis
|
|||||||
DomTreeUpdater.cpp
|
DomTreeUpdater.cpp
|
||||||
DominanceFrontier.cpp
|
DominanceFrontier.cpp
|
||||||
EHPersonalities.cpp
|
EHPersonalities.cpp
|
||||||
FunctionPropertiesAnalysis.cpp
|
|
||||||
GlobalsModRef.cpp
|
GlobalsModRef.cpp
|
||||||
GuardUtils.cpp
|
GuardUtils.cpp
|
||||||
HeatUtils.cpp
|
HeatUtils.cpp
|
||||||
@ -58,6 +57,7 @@ add_llvm_component_library(LLVMAnalysis
|
|||||||
IndirectCallPromotionAnalysis.cpp
|
IndirectCallPromotionAnalysis.cpp
|
||||||
InlineCost.cpp
|
InlineCost.cpp
|
||||||
InlineAdvisor.cpp
|
InlineAdvisor.cpp
|
||||||
|
InlineFeaturesAnalysis.cpp
|
||||||
InlineSizeEstimatorAnalysis.cpp
|
InlineSizeEstimatorAnalysis.cpp
|
||||||
InstCount.cpp
|
InstCount.cpp
|
||||||
InstructionPrecedenceTracking.cpp
|
InstructionPrecedenceTracking.cpp
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//===- FunctionPropertiesAnalysis.cpp - Function properties extraction ----===//
|
//===- InlineFeaturesAnalysis.cpp - Feature extraction for ML Policies ----===//
|
||||||
//
|
//
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
@ -11,16 +11,15 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/Analysis/FunctionPropertiesAnalysis.h"
|
#include "llvm/Analysis/InlineFeaturesAnalysis.h"
|
||||||
#include "llvm/IR/Instructions.h"
|
#include "llvm/IR/Instructions.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
AnalysisKey FunctionPropertiesAnalysis::Key;
|
AnalysisKey InlineFeaturesAnalysis::Key;
|
||||||
|
|
||||||
FunctionPropertiesAnalysis::Result
|
InlineFeaturesAnalysis::Result
|
||||||
FunctionPropertiesAnalysis::run(const Function &F,
|
InlineFeaturesAnalysis::run(const Function &F, FunctionAnalysisManager &FAM) {
|
||||||
FunctionAnalysisManager &FAM) {
|
|
||||||
Result Ret;
|
Result Ret;
|
||||||
Ret.Uses = ((!F.hasLocalLinkage()) ? 1 : 0) + F.getNumUses();
|
Ret.Uses = ((!F.hasLocalLinkage()) ? 1 : 0) + F.getNumUses();
|
||||||
for (const auto &BB : F) {
|
for (const auto &BB : F) {
|
@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
#include "llvm/ADT/SCCIterator.h"
|
#include "llvm/ADT/SCCIterator.h"
|
||||||
#include "llvm/Analysis/CallGraph.h"
|
#include "llvm/Analysis/CallGraph.h"
|
||||||
#include "llvm/Analysis/FunctionPropertiesAnalysis.h"
|
|
||||||
#include "llvm/Analysis/InlineCost.h"
|
#include "llvm/Analysis/InlineCost.h"
|
||||||
|
#include "llvm/Analysis/InlineFeaturesAnalysis.h"
|
||||||
#include "llvm/Analysis/MLInlineAdvisor.h"
|
#include "llvm/Analysis/MLInlineAdvisor.h"
|
||||||
#include "llvm/Analysis/MLModelRunner.h"
|
#include "llvm/Analysis/MLModelRunner.h"
|
||||||
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
|
#include "llvm/Analysis/OptimizationRemarkEmitter.h"
|
||||||
@ -118,8 +118,7 @@ void MLInlineAdvisor::onPassEntry() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int64_t MLInlineAdvisor::getLocalCalls(Function &F) {
|
int64_t MLInlineAdvisor::getLocalCalls(Function &F) {
|
||||||
return FAM.getResult<FunctionPropertiesAnalysis>(F)
|
return FAM.getResult<InlineFeaturesAnalysis>(F).DirectCallsToDefinedFunctions;
|
||||||
.DirectCallsToDefinedFunctions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the internal state of the advisor, and force invalidate feature
|
// Update the internal state of the advisor, and force invalidate feature
|
||||||
@ -134,7 +133,7 @@ void MLInlineAdvisor::onSuccessfulInlining(const MLInlineAdvice &Advice,
|
|||||||
Function *Callee = Advice.getCallee();
|
Function *Callee = Advice.getCallee();
|
||||||
|
|
||||||
// The caller features aren't valid anymore.
|
// The caller features aren't valid anymore.
|
||||||
FAM.invalidate<FunctionPropertiesAnalysis>(*Caller);
|
FAM.invalidate<InlineFeaturesAnalysis>(*Caller);
|
||||||
int64_t IRSizeAfter =
|
int64_t IRSizeAfter =
|
||||||
getIRSize(*Caller) + (CalleeWasDeleted ? 0 : Advice.CalleeIRSize);
|
getIRSize(*Caller) + (CalleeWasDeleted ? 0 : Advice.CalleeIRSize);
|
||||||
CurrentIRSize += IRSizeAfter - (Advice.CallerIRSize + Advice.CalleeIRSize);
|
CurrentIRSize += IRSizeAfter - (Advice.CallerIRSize + Advice.CalleeIRSize);
|
||||||
@ -147,14 +146,13 @@ void MLInlineAdvisor::onSuccessfulInlining(const MLInlineAdvice &Advice,
|
|||||||
// For edges, we 'forget' the edges that the caller and callee used to have
|
// For edges, we 'forget' the edges that the caller and callee used to have
|
||||||
// before inlining, and add back what they currently have together.
|
// before inlining, and add back what they currently have together.
|
||||||
int64_t NewCallerAndCalleeEdges =
|
int64_t NewCallerAndCalleeEdges =
|
||||||
FAM.getResult<FunctionPropertiesAnalysis>(*Caller)
|
FAM.getResult<InlineFeaturesAnalysis>(*Caller)
|
||||||
.DirectCallsToDefinedFunctions;
|
.DirectCallsToDefinedFunctions;
|
||||||
|
|
||||||
if (CalleeWasDeleted)
|
if (CalleeWasDeleted)
|
||||||
--NodeCount;
|
--NodeCount;
|
||||||
else
|
else
|
||||||
NewCallerAndCalleeEdges +=
|
NewCallerAndCalleeEdges += FAM.getResult<InlineFeaturesAnalysis>(*Callee)
|
||||||
FAM.getResult<FunctionPropertiesAnalysis>(*Callee)
|
|
||||||
.DirectCallsToDefinedFunctions;
|
.DirectCallsToDefinedFunctions;
|
||||||
EdgeCount += (NewCallerAndCalleeEdges - Advice.CallerAndCalleeEdges);
|
EdgeCount += (NewCallerAndCalleeEdges - Advice.CallerAndCalleeEdges);
|
||||||
assert(CurrentIRSize >= 0 && EdgeCount >= 0 && NodeCount >= 0);
|
assert(CurrentIRSize >= 0 && EdgeCount >= 0 && NodeCount >= 0);
|
||||||
@ -226,8 +224,8 @@ std::unique_ptr<InlineAdvice> MLInlineAdvisor::getAdvice(CallBase &CB) {
|
|||||||
NrCtantParams += (isa<Constant>(*I));
|
NrCtantParams += (isa<Constant>(*I));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &CallerBefore = FAM.getResult<FunctionPropertiesAnalysis>(Caller);
|
auto &CallerBefore = FAM.getResult<InlineFeaturesAnalysis>(Caller);
|
||||||
auto &CalleeBefore = FAM.getResult<FunctionPropertiesAnalysis>(Callee);
|
auto &CalleeBefore = FAM.getResult<InlineFeaturesAnalysis>(Callee);
|
||||||
|
|
||||||
ModelRunner->setFeature(FeatureIndex::CalleeBasicBlockCount,
|
ModelRunner->setFeature(FeatureIndex::CalleeBasicBlockCount,
|
||||||
CalleeBefore.BasicBlockCount);
|
CalleeBefore.BasicBlockCount);
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
#include "llvm/Analysis/DemandedBits.h"
|
#include "llvm/Analysis/DemandedBits.h"
|
||||||
#include "llvm/Analysis/DependenceAnalysis.h"
|
#include "llvm/Analysis/DependenceAnalysis.h"
|
||||||
#include "llvm/Analysis/DominanceFrontier.h"
|
#include "llvm/Analysis/DominanceFrontier.h"
|
||||||
#include "llvm/Analysis/FunctionPropertiesAnalysis.h"
|
|
||||||
#include "llvm/Analysis/GlobalsModRef.h"
|
#include "llvm/Analysis/GlobalsModRef.h"
|
||||||
#include "llvm/Analysis/IVUsers.h"
|
#include "llvm/Analysis/IVUsers.h"
|
||||||
#include "llvm/Analysis/InlineAdvisor.h"
|
#include "llvm/Analysis/InlineAdvisor.h"
|
||||||
|
#include "llvm/Analysis/InlineFeaturesAnalysis.h"
|
||||||
#include "llvm/Analysis/InlineSizeEstimatorAnalysis.h"
|
#include "llvm/Analysis/InlineSizeEstimatorAnalysis.h"
|
||||||
#include "llvm/Analysis/LazyCallGraph.h"
|
#include "llvm/Analysis/LazyCallGraph.h"
|
||||||
#include "llvm/Analysis/LazyValueInfo.h"
|
#include "llvm/Analysis/LazyValueInfo.h"
|
||||||
|
@ -132,7 +132,7 @@ FUNCTION_ANALYSIS("domfrontier", DominanceFrontierAnalysis())
|
|||||||
FUNCTION_ANALYSIS("loops", LoopAnalysis())
|
FUNCTION_ANALYSIS("loops", LoopAnalysis())
|
||||||
FUNCTION_ANALYSIS("lazy-value-info", LazyValueAnalysis())
|
FUNCTION_ANALYSIS("lazy-value-info", LazyValueAnalysis())
|
||||||
FUNCTION_ANALYSIS("da", DependenceAnalysis())
|
FUNCTION_ANALYSIS("da", DependenceAnalysis())
|
||||||
FUNCTION_ANALYSIS("func-properties", FunctionPropertiesAnalysis())
|
FUNCTION_ANALYSIS("inliner-features", InlineFeaturesAnalysis())
|
||||||
FUNCTION_ANALYSIS("inliner-size-estimator", InlineSizeEstimatorAnalysis())
|
FUNCTION_ANALYSIS("inliner-size-estimator", InlineSizeEstimatorAnalysis())
|
||||||
FUNCTION_ANALYSIS("memdep", MemoryDependenceAnalysis())
|
FUNCTION_ANALYSIS("memdep", MemoryDependenceAnalysis())
|
||||||
FUNCTION_ANALYSIS("memoryssa", MemorySSAAnalysis())
|
FUNCTION_ANALYSIS("memoryssa", MemorySSAAnalysis())
|
||||||
|
@ -27,7 +27,7 @@ add_llvm_unittest_with_input_files(AnalysisTests
|
|||||||
DivergenceAnalysisTest.cpp
|
DivergenceAnalysisTest.cpp
|
||||||
DomTreeUpdaterTest.cpp
|
DomTreeUpdaterTest.cpp
|
||||||
GlobalsModRefTest.cpp
|
GlobalsModRefTest.cpp
|
||||||
FunctionPropertiesAnalysisTest.cpp
|
InlineFeaturesAnalysisTest.cpp
|
||||||
IVDescriptorsTest.cpp
|
IVDescriptorsTest.cpp
|
||||||
LazyCallGraphTest.cpp
|
LazyCallGraphTest.cpp
|
||||||
LoadsTest.cpp
|
LoadsTest.cpp
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//===- FunctionPropertiesAnalysisTest.cpp - function properties unit tests-===//
|
//===- InlineFeaturesAnalysisTest.cpp - inline features unit tests --------===//
|
||||||
//
|
//
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
@ -6,7 +6,7 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/Analysis/FunctionPropertiesAnalysis.h"
|
#include "llvm/Analysis/InlineFeaturesAnalysis.h"
|
||||||
#include "llvm/AsmParser/Parser.h"
|
#include "llvm/AsmParser/Parser.h"
|
||||||
#include "llvm/IR/Instructions.h"
|
#include "llvm/IR/Instructions.h"
|
||||||
#include "llvm/IR/LLVMContext.h"
|
#include "llvm/IR/LLVMContext.h"
|
||||||
@ -24,7 +24,7 @@ static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) {
|
|||||||
return Mod;
|
return Mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FunctionPropertiesTest, BasicTest) {
|
TEST(InlineFeaturesTest, BasicTest) {
|
||||||
LLVMContext C;
|
LLVMContext C;
|
||||||
std::unique_ptr<Module> M = parseIR(C,
|
std::unique_ptr<Module> M = parseIR(C,
|
||||||
R"IR(
|
R"IR(
|
||||||
@ -59,7 +59,7 @@ define internal i32 @top() {
|
|||||||
)IR");
|
)IR");
|
||||||
|
|
||||||
FunctionAnalysisManager FAM;
|
FunctionAnalysisManager FAM;
|
||||||
FunctionPropertiesAnalysis FA;
|
InlineFeaturesAnalysis FA;
|
||||||
|
|
||||||
auto BranchesFeatures = FA.run(*M->getFunction("branches"), FAM);
|
auto BranchesFeatures = FA.run(*M->getFunction("branches"), FAM);
|
||||||
EXPECT_EQ(BranchesFeatures.BasicBlockCount, 4);
|
EXPECT_EQ(BranchesFeatures.BasicBlockCount, 4);
|
Loading…
Reference in New Issue
Block a user