GIMPLE statements access use-operand information safely.
GIMPLE IR access to use-operand information is unified for correctness and to satisfy type sanitization.
This commit refactors GIMPLE (GCC’s intermediate representation) to access use-operand information through a common base class. Previously, different statement types accessed this information through distinct, non-aliasing records, which could lead to reordering bugs detected by type sanitizers. Using gimple_statement_with_ops_base ensures consistent and safe access across all relevant statement types.
In Details
The functions gimple_set_use_ops and gimple_use_ops previously accessed the use_ops field via gimple_statement_with_ops for statements with operands. However, statements like gimple_statement_with_memory_ops, gcall, and gasm do not derive from gimple_statement_with_ops, and gimple_vuse_op accesses the same field through gimple_statement_with_memory_ops. These different access paths, while having non-conflicting alias sets, could lead to reordering issues. The change unifies access by using gimple_statement_with_ops_base, which is the common base class for these statement…
- GIMPLE
- Generic Intermediate Representation for Expressions. It is a three-address code representation used internally by GCC after the initial parsing and high-level optimization phases.
- use-ops
- Refers to the operands of a GIMPLE statement that are read (used) by that statement.
- gimple_statement_with_ops_base
- A base class in GCC's GIMPLE representation that provides common fields and methods for statements that involve operands.
- type sanitizer
- A debugging tool, like GCC's
-fsanitize=type, that detects type confusion errors and memory access violations related to type safety.