https://gcc.gnu.org/g:80b453d5e4b423730033fd15bc26075347dfd5ba

commit r16-3660-g80b453d5e4b423730033fd15bc26075347dfd5ba
Author: Kugan Vivekanandarajah <kvivekana...@nvidia.com>
Date:   Mon Sep 8 19:10:44 2025 +1000

    [AutoFDO] Check count initialization to fix ICE with AutoFDO
    
    Fix ICE with AutoFDO by adding initialization check
    before accessing IPA counts to avoid issues with uninitialized profile
    counts in self-recursive clone processing.
    
    gcc/ChangeLog:
    
    2025-09-08  Kugan Vivekanandarajah  <kvivekana...@nvidia.com>
    
            * ipa-cp.cc (gather_count_of_non_rec_edges): Check count
            initialization before adding to total.
    
    Signed-off-by: Kugan Vivekanandarajah <kvivekana...@nvidia.com>

Diff:
---
 gcc/ipa-cp.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 480cf48786c7..4f2030a8d8cb 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -4555,7 +4555,8 @@ gather_count_of_non_rec_edges (cgraph_node *node, void 
*data)
   gather_other_count_struct *desc = (gather_other_count_struct *) data;
   for (cgraph_edge *cs = node->callers; cs; cs = cs->next_caller)
     if (cs->caller != desc->orig && cs->caller->clone_of != desc->orig)
-      desc->other_count += cs->count.ipa ();
+      if (cs->count.ipa ().initialized_p ())
+       desc->other_count += cs->count.ipa ();
   return false;
 }

Reply via email to