On 9/22/26 3:33 AM, [email protected] wrote:
From: Kyrylo Tkachov <[email protected]> A broken table reference can make tablejump_p stop recognizing a dispatch, which bypasses its CFG checks. Those checks also stop when free_cfg removes the CFG before machine reorganization and branch shortening. Check table references from both instruction patterns and JUMP_LABEL in the existing post-pass RTL verifier. Require live table, base and case labels, label-to-table adjacency, and a shared flag for tables with several repeatable users. Honor the existing target copy restriction when counting users. An uncopyable dispatch can also have an out-of-line execution template. Handle jumps in delay-slot sequences. Allow a shared table to lose users and to change entry width. Run the structural check on hook-enabled targets in linear RTL, including after free_cfg. Strengthen the CFG check to compare complete destination sets, including casesi default and exceptional edges. Plugin tests damage individual invariants and check the diagnostics at pass boundaries. Positive tests cover repeated entries, zero or one remaining user, target copy restrictions, shortened tables, delay-slot sequences and casesi default edges. Bootstrapped on aarch64-linux-gnu with RTL and extra checking. gcc/ChangeLog: PR middle-end/126236 * cfgrtl.cc (rtl_verify_edges): Compare all shared-table destinations with the dispatch's successors. * passes.cc (execute_function_todo): Verify tablejump links before CFG verification and after CFG teardown. * rtl.h (verify_jump_tables): Declare. * rtlanal.cc (verify_jump_tables): New function. gcc/testsuite/ChangeLog: PR middle-end/126236 * gcc.dg/plugin/plugin.exp: Register the tablejump tests. * gcc.dg/plugin/tablejump_plugin.cc: New plugin. * gcc.dg/plugin/tablejump-valid.c: New test. * gcc.dg/plugin/tablejump-missing-edge.c: Likewise. * gcc.dg/plugin/tablejump-extra-edge.c: Likewise. * gcc.dg/plugin/tablejump-null-label.c: Likewise. * gcc.dg/plugin/tablejump-stale-label.c: Likewise. * gcc.dg/plugin/tablejump-missing-ref.c: Likewise. * gcc.dg/plugin/tablejump-detached-label.c: Likewise. * gcc.dg/plugin/tablejump-detached-table.c: Likewise. * gcc.dg/plugin/tablejump-detached-pair.c: Likewise. * gcc.dg/plugin/tablejump-deleted-table.c: Likewise. * gcc.dg/plugin/tablejump-unmarked.c: Likewise. * gcc.dg/plugin/tablejump-case-label.c: Likewise. * gcc.dg/plugin/tablejump-base-label.c: Likewise. Signed-off-by: Kyrylo Tkachov <[email protected]>
OK if and when prereqs are approved. jeff
