@@ -153,26 +153,23 @@ PreservedAnalyses CoroAnnotationElidePass::run(LazyCallGraph::SCC &C,
153153 bool IsCallerPresplitCoroutine = Caller->isPresplitCoroutine ();
154154 bool HasAttr = CB->hasFnAttr (llvm::Attribute::CoroElideSafe);
155155 if (IsCallerPresplitCoroutine && HasAttr) {
156- BranchProbability MinBranchProbability (
157- static_cast <int >(CoroElideBranchRatio * MinBlockCounterExecution),
158- MinBlockCounterExecution);
159-
160156 auto &BFI = FAM.getResult <BlockFrequencyAnalysis>(*Caller);
161157
162- auto Prob = BranchProbability::getBranchProbability (
163- BFI.getBlockFreq (CB->getParent ()).getFrequency (),
164- BFI.getEntryFreq ().getFrequency ());
158+ auto BlockFreq = BFI.getBlockFreq (CB->getParent ()).getFrequency ();
159+ auto EntryFreq = BFI.getEntryFreq ().getFrequency ();
160+ uint64_t MinFreq =
161+ static_cast <uint64_t >(EntryFreq * CoroElideBranchRatio);
165162
166- if (Prob < MinBranchProbability ) {
163+ if (BlockFreq < MinFreq ) {
167164 ORE.emit ([&]() {
168165 return OptimizationRemarkMissed (
169166 DEBUG_TYPE, " CoroAnnotationElideUnlikely" , Caller)
170167 << " '" << ore::NV (" callee" , Callee->getName ())
171168 << " ' not elided in '"
172169 << ore::NV (" caller" , Caller->getName ())
173- << " ' because of low probability : "
174- << ore::NV (" probability " , Prob) << " (threshold: "
175- << ore::NV (" threshold " , MinBranchProbability ) << " )" ;
170+ << " ' because of low frequency : "
171+ << ore::NV (" block_freq " , BlockFreq)
172+ << " (threshold: " << ore::NV (" min_freq " , MinFreq ) << " )" ;
176173 });
177174 continue ;
178175 }
@@ -188,7 +185,8 @@ PreservedAnalyses CoroAnnotationElidePass::run(LazyCallGraph::SCC &C,
188185 return OptimizationRemark (DEBUG_TYPE, " CoroAnnotationElide" , Caller)
189186 << " '" << ore::NV (" callee" , Callee->getName ())
190187 << " ' elided in '" << ore::NV (" caller" , Caller->getName ())
191- << " ' (probability: " << ore::NV (" probability" , Prob) << " )" ;
188+ << " ' (block_freq: " << ore::NV (" block_freq" , BlockFreq)
189+ << " )" ;
192190 });
193191
194192 FAM.invalidate (*Caller, PreservedAnalyses::none ());
0 commit comments