[GuardWidening] Group code by class [NFC]

llvm-svn: 328387
This commit is contained in:
Philip Reames 2018-03-23 23:41:47 +00:00
parent e27b410661
commit 6a1f3446b5
1 changed files with 40 additions and 39 deletions

View File

@ -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<DominatorTreeWrapperPass>().getDomTree(),
getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree(),
getAnalysis<LoopInfoWrapperPass>().getLoopInfo()).run();
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesCFG();
AU.addRequired<DominatorTreeWrapperPass>();
AU.addRequired<PostDominatorTreeWrapperPass>();
AU.addRequired<LoopInfoWrapperPass>();
}
};
}
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<DominatorTreeAnalysis>(F);
auto &LI = AM.getResult<LoopAnalysis>(F);
auto &PDT = AM.getResult<PostDominatorTreeAnalysis>(F);
if (!GuardWideningImpl(DT, PDT, LI).run())
return PreservedAnalyses::all();
PreservedAnalyses PA;
PA.preserveSet<CFGAnalyses>();
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<DominatorTreeAnalysis>(F);
auto &LI = AM.getResult<LoopAnalysis>(F);
auto &PDT = AM.getResult<PostDominatorTreeAnalysis>(F);
if (!GuardWideningImpl(DT, PDT, LI).run())
return PreservedAnalyses::all();
PreservedAnalyses PA;
PA.preserveSet<CFGAnalyses>();
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<DominatorTreeWrapperPass>().getDomTree(),
getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree(),
getAnalysis<LoopInfoWrapperPass>().getLoopInfo()).run();
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesCFG();
AU.addRequired<DominatorTreeWrapperPass>();
AU.addRequired<PostDominatorTreeWrapperPass>();
AU.addRequired<LoopInfoWrapperPass>();
}
};
}
char GuardWideningLegacyPass::ID = 0;
INITIALIZE_PASS_BEGIN(GuardWideningLegacyPass, "guard-widening", "Widen guards",