]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
avoid-store-forwarding: Fix sbitmap memory leak in process_store_forwarding
authorPhilipp Tomsich <philipp.tomsich@vrull.eu>
Mon, 23 Feb 2026 10:05:06 +0000 (11:05 +0100)
committerPhilipp Tomsich <philipp.tomsich@vrull.eu>
Wed, 25 Feb 2026 22:01:39 +0000 (23:01 +0100)
forwarded_bytes was allocated with sbitmap_alloc but never freed on any
of the function's return paths.  Use auto_sbitmap instead, which calls
sbitmap_free in its destructor.

gcc/ChangeLog:

* avoid-store-forwarding.cc
(store_forwarding_analyzer::process_store_forwarding): Use
auto_sbitmap for forwarded_bytes to ensure it is freed on all
return paths.

Reviewed-By: Konstantinos Eleftheriou <konstantinos.eleftheriou@vrull.eu>
gcc/avoid-store-forwarding.cc

index 33446beb0091ab14ebf876c976447436731dd575..f9c43a2ec460a68a9647bd309db37ef186b65f8b 100644 (file)
@@ -176,9 +176,7 @@ process_store_forwarding (vec<store_fwd_info> &stores, rtx_insn *load_insn,
      We can also eliminate stores on addresses that are overwritten
      by later stores.  */
 
-  sbitmap forwarded_bytes = sbitmap_alloc (load_size);
-  bitmap_clear (forwarded_bytes);
-
+  auto_sbitmap forwarded_bytes (load_size);
   unsigned int i;
   store_fwd_info* it;
   auto_vec<store_fwd_info> redundant_stores;