gimplify: Allow declarations in recalculate_side_effects
Gimplifier now correctly handles declarations within recalculate_side_effects, preventing ICEs.
This change modifies the gimplify pass to correctly handle declarations when calculating side effects. Previously, the compiler would ICE if it encountered a declaration (like PARM_DECL or tcc_declaration) within a context where side effects were being recalculated, as these were not expected. The fix allows these declarations, particularly those marked as volatile, to be processed without crashing the compiler.
In Details
The gimplify pass converts high-level constructs into GIMPLE. The recalculate_side_effects function, used during optimization, previously asserted that it would not be called with PARM_DECL or tcc_declaration. This commit relaxes that assertion, allowing these declaration types to be passed, with the understanding that their side-effect behavior (e.g., for TREE_VOLATILE) is handled by the frontend or other passes.
- gimplify
- A GCC compiler pass that transforms the code from GENERIC intermediate representation into GIMPLE, a simpler three-address-like form.
- recalculate_side_effects
- A function within GCC that re-evaluates the side effects of an expression, often used during optimization passes to determine if an operation can be safely reordered or eliminated.
- PARM_DECL
- A GCC internal representation for a function parameter declaration.
- tcc_declaration
- A specific type of declaration encountered during C-to-C compilation, often related to type compatibility checks.
- ICE
- Internal Compiler Error, a fatal error that occurs when the compiler encounters a situation it cannot handle, usually due to a bug.