From 259ca0418ee962a69adc4057bce5d596bd3d42d1 Mon Sep 17 00:00:00 2001 From: Daniil Suchkov Date: Tue, 19 Nov 2019 14:16:39 +0700 Subject: [PATCH] [SCEV] Make SCEV verification available from command line with new PM New pass manager doesn't use verifyAnalysis, so currently there is no way to call SCEV verification from command line when new PM is used. This patch adds a pass that allows you to do that. Reviewers: reames, fhahn, sanjoy.google, nikic Reviewed By: fhahn Subscribers: hiraditya, javed.absar, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70423 --- llvm/include/llvm/Analysis/ScalarEvolution.h | 7 +++++++ llvm/lib/Analysis/ScalarEvolution.cpp | 6 ++++++ llvm/lib/Passes/PassRegistry.def | 1 + 3 files changed, 14 insertions(+) diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index 57f84c1d0ebf..5286f6a220ec 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -1922,6 +1922,13 @@ public: ScalarEvolution run(Function &F, FunctionAnalysisManager &AM); }; +/// Verifier pass for the \c ScalarEvolutionAnalysis results. +class ScalarEvolutionVerifierPass + : public PassInfoMixin { +public: + PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); +}; + /// Printer pass for the \c ScalarEvolutionAnalysis results. class ScalarEvolutionPrinterPass : public PassInfoMixin { diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 66c43cb45111..483159bef987 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -12040,6 +12040,12 @@ ScalarEvolution ScalarEvolutionAnalysis::run(Function &F, AM.getResult(F)); } +PreservedAnalyses +ScalarEvolutionVerifierPass::run(Function &F, FunctionAnalysisManager &AM) { + AM.getResult(F).verify(); + return PreservedAnalyses::all(); +} + PreservedAnalyses ScalarEvolutionPrinterPass::run(Function &F, FunctionAnalysisManager &AM) { AM.getResult(F).print(OS); diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def index d988506b5e98..8b583bde5909 100644 --- a/llvm/lib/Passes/PassRegistry.def +++ b/llvm/lib/Passes/PassRegistry.def @@ -240,6 +240,7 @@ FUNCTION_PASS("verify", LoopVerifierPass()) FUNCTION_PASS("verify", MemorySSAVerifierPass()) FUNCTION_PASS("verify", RegionInfoVerifierPass()) FUNCTION_PASS("verify", SafepointIRVerifierPass()) +FUNCTION_PASS("verify", ScalarEvolutionVerifierPass()) FUNCTION_PASS("view-cfg", CFGViewerPass()) FUNCTION_PASS("view-cfg-only", CFGOnlyViewerPass()) FUNCTION_PASS("transform-warning", WarnMissedTransformationsPass())