================
@@ -2907,6 +2907,10 @@ uint64_t
LoopVectorizationCostModel::getPredBlockCostDivisor(
uint64_t BBFreq = getBFI().getBlockFreq(BB).getFrequency();
assert(HeaderFreq >= BBFreq &&
"Header has smaller block freq than dominated BB?");
+ // Guard against division by zero when BBFreq is 0.
+ // In such cases, return 1 to avoid undefined behavior.
+ if (BBFreq == 0)
----------------
dev-priyanshu15 wrote:
Thanks for the feedback. I've added the assert as you suggested:
assert(BBFreq != 0 && "BlockFrequencyInfo should never return zero frequency");
This validates your point that BlockFrequencyInfo should never return a zero
frequency. If the assert fails, it will help identify the root cause of the
issue.
https://github.com/llvm/llvm-project/pull/172094
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits