From 6a1f3446b5f2896c22a52dca732ba30c15535cd2 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 23 Mar 2018 23:41:47 +0000 Subject: [PATCH] [GuardWidening] Group code by class [NFC] llvm-svn: 328387 --- llvm/lib/Transforms/Scalar/GuardWidening.cpp | 79 ++++++++++---------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/GuardWidening.cpp b/llvm/lib/Transforms/Scalar/GuardWidening.cpp index c4aeccb85ca7..200df9ded405 100644 --- a/llvm/lib/Transforms/Scalar/GuardWidening.cpp +++ b/llvm/lib/Transforms/Scalar/GuardWidening.cpp @@ -212,32 +212,6 @@ public: /// The entry point for this pass. bool run(); }; - -struct GuardWideningLegacyPass : public FunctionPass { - static char ID; - GuardWideningPass Impl; - - GuardWideningLegacyPass() : FunctionPass(ID) { - initializeGuardWideningLegacyPassPass(*PassRegistry::getPassRegistry()); - } - - bool runOnFunction(Function &F) override { - if (skipFunction(F)) - return false; - return GuardWideningImpl( - getAnalysis().getDomTree(), - getAnalysis().getPostDomTree(), - getAnalysis().getLoopInfo()).run(); - } - - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.setPreservesCFG(); - AU.addRequired(); - AU.addRequired(); - AU.addRequired(); - } -}; - } bool GuardWideningImpl::run() { @@ -651,19 +625,6 @@ bool GuardWideningImpl::combineRangeChecks( return RangeChecksOut.size() != OldCount; } -PreservedAnalyses GuardWideningPass::run(Function &F, - FunctionAnalysisManager &AM) { - auto &DT = AM.getResult(F); - auto &LI = AM.getResult(F); - auto &PDT = AM.getResult(F); - if (!GuardWideningImpl(DT, PDT, LI).run()) - return PreservedAnalyses::all(); - - PreservedAnalyses PA; - PA.preserveSet(); - return PA; -} - #ifndef NDEBUG StringRef GuardWideningImpl::scoreTypeToString(WideningScore WS) { switch (WS) { @@ -681,6 +642,46 @@ StringRef GuardWideningImpl::scoreTypeToString(WideningScore WS) { } #endif +PreservedAnalyses GuardWideningPass::run(Function &F, + FunctionAnalysisManager &AM) { + auto &DT = AM.getResult(F); + auto &LI = AM.getResult(F); + auto &PDT = AM.getResult(F); + if (!GuardWideningImpl(DT, PDT, LI).run()) + return PreservedAnalyses::all(); + + PreservedAnalyses PA; + PA.preserveSet(); + return PA; +} + +namespace { +struct GuardWideningLegacyPass : public FunctionPass { + static char ID; + GuardWideningPass Impl; + + GuardWideningLegacyPass() : FunctionPass(ID) { + initializeGuardWideningLegacyPassPass(*PassRegistry::getPassRegistry()); + } + + bool runOnFunction(Function &F) override { + if (skipFunction(F)) + return false; + return GuardWideningImpl( + getAnalysis().getDomTree(), + getAnalysis().getPostDomTree(), + getAnalysis().getLoopInfo()).run(); + } + + void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.setPreservesCFG(); + AU.addRequired(); + AU.addRequired(); + AU.addRequired(); + } +}; +} + char GuardWideningLegacyPass::ID = 0; INITIALIZE_PASS_BEGIN(GuardWideningLegacyPass, "guard-widening", "Widen guards",