[gcc r17-2919] sched-deps: clear dependency caches before freeing them

Kyrylo Tkachov via Gcc-cvs <[email protected]> Tue, 4 Aug 2026 08:15:12 +0000 (GMT)
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:10a4ba553e6a693b5a75c0a6f67c30989efda307

commit r17-2919-g10a4ba553e6a693b5a75c0a6f67c30989efda307
Author: Kyrylo Tkachov <[email protected]>
Date:   Mon Jul 27 20:04:12 2026 +0200

    sched-deps: clear dependency caches before freeing them
    
    sched_deps_finish resets cache_size before it uses cache_size to clear the
    dependency cache bitmaps.  The cleanup loop therefore has zero iterations.
    The cache arrays are freed, but their bitmap elements are not returned to
    the bitmap obstack.
    
    Move the reset after the cleanup loop.
    
    Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux.
    
    gcc/ChangeLog:
    
            * sched-deps.cc (sched_deps_finish): Reset cache_size after clearing
            and freeing the dependency caches.
    
    Signed-off-by: Kyrylo Tkachov <[email protected]>

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

diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc
index b2da11c7900d..23f3545b54c9 100644
--- a/gcc/sched-deps.cc
+++ b/gcc/sched-deps.cc
@@ -4171,7 +4171,6 @@ sched_deps_finish (void)
   dl_pool = NULL;
 
   h_d_i_d.release ();
-  cache_size = 0;
 
   if (true_dependency_cache)
     {
@@ -4203,6 +4202,8 @@ sched_deps_finish (void)
         }
 
     }
+
+  cache_size = 0;
 }
 
 /* Initialize some global variables needed by the dependency analysis