[LibCallsShrinkWrap] Remove an unnecessary class member variable.

llvm-svn: 301477
This commit is contained in:
Davide Italiano 2017-04-26 21:28:40 +00:00
parent cf8247ef48
commit d7b2a9981c
1 changed files with 7 additions and 8 deletions

View File

@ -74,10 +74,10 @@ namespace {
class LibCallsShrinkWrap : public InstVisitor<LibCallsShrinkWrap> { class LibCallsShrinkWrap : public InstVisitor<LibCallsShrinkWrap> {
public: public:
LibCallsShrinkWrap(const TargetLibraryInfo &TLI, DominatorTree *DT) LibCallsShrinkWrap(const TargetLibraryInfo &TLI, DominatorTree *DT)
: TLI(TLI), DT(DT), Changed(false){}; : TLI(TLI), DT(DT){};
bool isChanged() const { return Changed; }
void visitCallInst(CallInst &CI) { checkCandidate(CI); } void visitCallInst(CallInst &CI) { checkCandidate(CI); }
void perform() { bool perform() {
bool Changed = false;
for (auto &CI : WorkList) { for (auto &CI : WorkList) {
DEBUG(dbgs() << "CDCE calls: " << CI->getCalledFunction()->getName() DEBUG(dbgs() << "CDCE calls: " << CI->getCalledFunction()->getName()
<< "\n"); << "\n");
@ -86,6 +86,7 @@ public:
DEBUG(dbgs() << "Transformed\n"); DEBUG(dbgs() << "Transformed\n");
} }
} }
return Changed;
} }
private: private:
@ -128,7 +129,6 @@ private:
const TargetLibraryInfo &TLI; const TargetLibraryInfo &TLI;
DominatorTree *DT; DominatorTree *DT;
SmallVector<CallInst *, 16> WorkList; SmallVector<CallInst *, 16> WorkList;
bool Changed;
}; };
} // end anonymous namespace } // end anonymous namespace
@ -526,14 +526,14 @@ static bool runImpl(Function &F, const TargetLibraryInfo &TLI,
return false; return false;
LibCallsShrinkWrap CCDCE(TLI, DT); LibCallsShrinkWrap CCDCE(TLI, DT);
CCDCE.visit(F); CCDCE.visit(F);
CCDCE.perform(); bool Changed = CCDCE.perform();
// Verify the dominator after we've updated it locally. // Verify the dominator after we've updated it locally.
#ifndef NDEBUG #ifndef NDEBUG
if (DT) if (DT)
DT->verifyDomTree(); DT->verifyDomTree();
#endif #endif
return CCDCE.isChanged(); return Changed;
} }
bool LibCallsShrinkWrapLegacyPass::runOnFunction(Function &F) { bool LibCallsShrinkWrapLegacyPass::runOnFunction(Function &F) {
@ -555,8 +555,7 @@ PreservedAnalyses LibCallsShrinkWrapPass::run(Function &F,
FunctionAnalysisManager &FAM) { FunctionAnalysisManager &FAM) {
auto &TLI = FAM.getResult<TargetLibraryAnalysis>(F); auto &TLI = FAM.getResult<TargetLibraryAnalysis>(F);
auto *DT = FAM.getCachedResult<DominatorTreeAnalysis>(F); auto *DT = FAM.getCachedResult<DominatorTreeAnalysis>(F);
bool Changed = runImpl(F, TLI, DT); if (!runImpl(F, TLI, DT))
if (!Changed)
return PreservedAnalyses::all(); return PreservedAnalyses::all();
auto PA = PreservedAnalyses(); auto PA = PreservedAnalyses();
PA.preserve<GlobalsAA>(); PA.preserve<GlobalsAA>();