GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
risc-v

RISC-V vector permconst pass memory leak fixed

A memory leak in the RISC-V vector permconst pass has been fixed by changing a table to an automatic variable and deriving a hasher from free_ptr_hash.

This commit addresses a memory leak identified in the vector_permconst pass for RISC-V targets. The fix involves changing the vector_permconst_table from a dynamically managed structure to an automatic variable, ensuring its memory is properly reclaimed. Additionally, the const_vector_hasher struct now derives from free_ptr_hash, further contributing to memory management correctness. These changes prevent memory from being leaked during the execution of this optimization pass.

In Details

The vector_permconst pass in the RISC-V backend had a memory leak. This was resolved by changing vector_permconst_table to be an automatic variable within process_bb, ensuring stack allocation and deallocation. The const_vector_hasher was also updated to derive from free_ptr_hash, likely to leverage its automatic memory management. This fix prevents the accumulation of memory during repeated analysis or transformation of basic blocks by this pass.

For Context
vector permconst pass
An optimization pass in the GCC RISC-V backend that likely deals with constant vectors and their permutations. This pass aims to simplify or optimize vector operations.
RISC-V
An open-standard instruction set architecture (ISA) based on Reduced Instruction Set Computing principles. GCC supports targeting various RISC-V configurations.
memory leak
A situation where a program allocates memory but fails to release it when it's no longer needed, leading to gradual consumption of available memory.
automatic variable
A variable whose lifetime is limited to the scope in which it is declared. In C++, this typically means it is allocated on the stack and automatically deallocated when the scope is exited.
free_ptr_hash
Likely a base class or utility in GCC's hash table implementation that manages memory for hash table entries, possibly using RAII (Resource Acquisition Is Initialization) principles for automatic memory deallocation.
Filed Under: risc-voptimizationmemory leak