OptimizationRemarkEmitter::OptimizationRemarkEmitter(const Function *F) : F(F), BFI(nullptr) { if (!F->getContext().getDiagnosticHotnessRequested()) return; // First create a dominator tree. DominatorTree DT; DT.recalculate(*const_cast<Function *>(F)); // Generate LoopInfo from it. LoopInfo LI; LI.analyze(DT); // Then compute BranchProbabilityInfo. BranchProbabilityInfo BPI; BPI.calculate(*F, LI); // Finally compute BFI. OwnedBFI = llvm::make_unique<BlockFrequencyInfo>(*F, BPI, LI); BFI = OwnedBFI.get(); }
BranchProbabilityInfo BranchProbabilityAnalysis::run(Function &F, AnalysisManager<Function> &AM) { BranchProbabilityInfo BPI; BPI.calculate(F, AM.getResult<LoopAnalysis>(F)); return BPI; }
BranchProbabilityInfo BranchProbabilityAnalysis::run(Function &F, FunctionAnalysisManager &AM) { BranchProbabilityInfo BPI; BPI.calculate(F, AM.getResult<LoopAnalysis>(F), &AM.getResult<TargetLibraryAnalysis>(F)); return BPI; }