RTL verifier checks shared jump tables after each pass
RTL verifier now checks shared jump table references after every pass to catch broken table references and ensure dispatch integrity.
This commit enhances the RTL verifier to rigorously check shared jump table references after each compiler pass. Previously, broken table references could cause the tablejump_p check to be bypassed, leading to undetected issues. The updated verifier now enforces requirements such as live table and label references, adjacency, and sharing flags, and strengthens CFG checks to cover all destination sets. This ensures the integrity of shared jump tables throughout the compilation pipeline, preventing potential crashes like rtl_split_edge.
In Details
This patch bolsters the RTL verifier's capabilities for shared jump tables. It introduces verify_jump_tables in rtlanal.cc to check table references from instruction patterns and JUMP_LABEL after every pass, including after free_cfg which removes CFG information. The verification enforces invariants like live labels, table-entry adjacency, and sharing flags, and strengthens CFG checks to compare complete destination sets. This addresses issues where broken table references could cause tablejump_p to fail and bypass subsequent CFG checks, especially after RTL transformations that mig…
- RTL
- Register Transfer Language. An intermediate representation used by GCC to describe the code being compiled, typically after initial machine-independent optimizations.
- jump table
- A data structure used to implement efficient multi-way branching. It typically contains addresses of target code blocks, allowing a program to jump to a specific block based on an index.
- CFG
- Control Flow Graph. A graphical representation of the execution paths within a program, where nodes represent basic blocks and edges represent control flow transfers.
- shared jump table
- A jump table that is used by multiple dispatch sites within a function. This allows for code reuse and can be an optimization, but requires careful management of references and targets.
- pass
- A distinct stage or transformation in the compiler pipeline that operates on the intermediate representation of the code.