Clear range info when freeing an SSA name
Ensures range information is cleared when SSA names are freed, fixing bugs related to def-chain recalculation and import fields.
This commit addresses issues in GCC’s SSA (Static Single Assignment) name management by ensuring that range information is cleared when an SSA name is released. It also corrects a bug where clearing the def chain immediately caused it to be rebuilt unnecessarily and ensures the import field is also cleared. These fixes prevent incorrect behavior and potential ICEs, and include new test cases to verify the corrections.
In Details
When an SSA name is released via release_ssa_name_fn in tree-ssanames.cc, any associated range information (range_info) is now explicitly cleared. The range_def_chain::clear method in gimple-range-gori.cc was modified to prevent recalculating the def chain immediately after it has been cleared, which was causing issues. Additionally, the import field of the SSA name was also being left uncleared, which is now fixed. This resolves PR tree-optimization/127719.
- SSA name
- In the context of Static Single Assignment (SSA) form, an SSA name represents a specific version or definition of a variable. Each SSA name is assigned exactly once.
- range info
- Information about the range of possible values or the memory access behavior associated with an SSA name, used for optimizations.
- def chain
- A data structure that tracks the definition sites of a variable or SSA name throughout the program's control flow.
- import field
- Likely refers to a field within the SSA name's structure that tracks if the name was imported from another scope or compilation unit.
- ICE
- Internal Compiler Error; a crash within the compiler itself, usually indicating a bug in the compiler's logic.