[llvm] [NewPM] Remove CostModelAnalysis Legacy Pass (PR #72941)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 20 18:13:48 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Aiden Grossman (boomanaiden154)
<details>
<summary>Changes</summary>
This pass isn't used/tested anywhere upstream, so remove it.
---
Full diff: https://github.com/llvm/llvm-project/pull/72941.diff
5 Files Affected:
- (modified) llvm/include/llvm/Analysis/Passes.h (-7)
- (modified) llvm/include/llvm/InitializePasses.h (-1)
- (modified) llvm/include/llvm/LinkAllPasses.h (-1)
- (modified) llvm/lib/Analysis/Analysis.cpp (-1)
- (modified) llvm/lib/Analysis/CostModel.cpp (-73)
``````````diff
diff --git a/llvm/include/llvm/Analysis/Passes.h b/llvm/include/llvm/Analysis/Passes.h
index ac1bc3549910c8c..58caf60b4ebe35a 100644
--- a/llvm/include/llvm/Analysis/Passes.h
+++ b/llvm/include/llvm/Analysis/Passes.h
@@ -32,13 +32,6 @@ namespace llvm {
//
FunctionPass *createDependenceAnalysisWrapperPass();
- //===--------------------------------------------------------------------===//
- //
- // createCostModelAnalysisPass - This creates an instance of the
- // CostModelAnalysis pass.
- //
- FunctionPass *createCostModelAnalysisPass();
-
//===--------------------------------------------------------------------===//
//
// createDelinearizationPass - This pass implements attempts to restore
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index 2305db4f775d49c..2090a0a26531b34 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -83,7 +83,6 @@ void initializeCheckDebugMachineModulePass(PassRegistry &);
void initializeCodeGenPreparePass(PassRegistry&);
void initializeComplexDeinterleavingLegacyPassPass(PassRegistry&);
void initializeConstantHoistingLegacyPassPass(PassRegistry&);
-void initializeCostModelAnalysisPass(PassRegistry&);
void initializeCycleInfoWrapperPassPass(PassRegistry &);
void initializeDAEPass(PassRegistry&);
void initializeDAHPass(PassRegistry&);
diff --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h
index 0d15481034151df..273d05f3cddca2d 100644
--- a/llvm/include/llvm/LinkAllPasses.h
+++ b/llvm/include/llvm/LinkAllPasses.h
@@ -69,7 +69,6 @@ namespace {
(void) llvm::createCallGraphViewerPass();
(void) llvm::createCFGSimplificationPass();
(void) llvm::createStructurizeCFGPass();
- (void) llvm::createCostModelAnalysisPass();
(void) llvm::createDeadArgEliminationPass();
(void) llvm::createDeadCodeEliminationPass();
(void) llvm::createDependenceAnalysisWrapperPass();
diff --git a/llvm/lib/Analysis/Analysis.cpp b/llvm/lib/Analysis/Analysis.cpp
index 80ea80303644449..7b15542ee38fbf8 100644
--- a/llvm/lib/Analysis/Analysis.cpp
+++ b/llvm/lib/Analysis/Analysis.cpp
@@ -25,7 +25,6 @@ void llvm::initializeAnalysis(PassRegistry &Registry) {
initializeCallGraphDOTPrinterPass(Registry);
initializeCallGraphPrinterLegacyPassPass(Registry);
initializeCallGraphViewerPass(Registry);
- initializeCostModelAnalysisPass(Registry);
initializeCFGViewerLegacyPassPass(Registry);
initializeCFGPrinterLegacyPassPass(Registry);
initializeCFGOnlyViewerLegacyPassPass(Registry);
diff --git a/llvm/lib/Analysis/CostModel.cpp b/llvm/lib/Analysis/CostModel.cpp
index 1782b399e7fd093..7e2ddea3bbfb7c2 100644
--- a/llvm/lib/Analysis/CostModel.cpp
+++ b/llvm/lib/Analysis/CostModel.cpp
@@ -47,79 +47,6 @@ static cl::opt<bool> TypeBasedIntrinsicCost("type-based-intrinsic-cost",
#define CM_NAME "cost-model"
#define DEBUG_TYPE CM_NAME
-namespace {
- class CostModelAnalysis : public FunctionPass {
-
- public:
- static char ID; // Class identification, replacement for typeinfo
- CostModelAnalysis() : FunctionPass(ID) {
- initializeCostModelAnalysisPass(
- *PassRegistry::getPassRegistry());
- }
-
- private:
- void getAnalysisUsage(AnalysisUsage &AU) const override;
- bool runOnFunction(Function &F) override;
- void print(raw_ostream &OS, const Module*) const override;
-
- /// The function that we analyze.
- Function *F = nullptr;
- /// Target information.
- const TargetTransformInfo *TTI = nullptr;
- };
-} // End of anonymous namespace
-
-// Register this pass.
-char CostModelAnalysis::ID = 0;
-static const char cm_name[] = "Cost Model Analysis";
-INITIALIZE_PASS_BEGIN(CostModelAnalysis, CM_NAME, cm_name, false, true)
-INITIALIZE_PASS_END (CostModelAnalysis, CM_NAME, cm_name, false, true)
-
-FunctionPass *llvm::createCostModelAnalysisPass() {
- return new CostModelAnalysis();
-}
-
-void
-CostModelAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesAll();
-}
-
-bool
-CostModelAnalysis::runOnFunction(Function &F) {
- this->F = &F;
- auto *TTIWP = getAnalysisIfAvailable<TargetTransformInfoWrapperPass>();
- TTI = TTIWP ? &TTIWP->getTTI(F) : nullptr;
-
- return false;
-}
-
-void CostModelAnalysis::print(raw_ostream &OS, const Module*) const {
- if (!F)
- return;
-
- for (BasicBlock &B : *F) {
- for (Instruction &Inst : B) {
- InstructionCost Cost;
- auto *II = dyn_cast<IntrinsicInst>(&Inst);
- if (II && TypeBasedIntrinsicCost) {
- IntrinsicCostAttributes ICA(II->getIntrinsicID(), *II,
- InstructionCost::getInvalid(), true);
- Cost = TTI->getIntrinsicInstrCost(ICA, CostKind);
- }
- else {
- Cost = TTI->getInstructionCost(&Inst, CostKind);
- }
-
- if (auto CostVal = Cost.getValue())
- OS << "Cost Model: Found an estimated cost of " << *CostVal;
- else
- OS << "Cost Model: Invalid cost";
-
- OS << " for instruction: " << Inst << "\n";
- }
- }
-}
-
PreservedAnalyses CostModelPrinterPass::run(Function &F,
FunctionAnalysisManager &AM) {
auto &TTI = AM.getResult<TargetIRAnalysis>(F);
``````````
</details>
https://github.com/llvm/llvm-project/pull/72941
More information about the llvm-commits
mailing list