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