From: Andrew Pinski Date: Sat, 13 Dec 2025 09:23:13 +0000 (-0800) Subject: final_cleanupcfg: Make sure TODO_cleanup_cfg is unset X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=94d8ce172848b39de198eb7f6e07ccd3685ef66e;p=thirdparty%2Fgcc.git final_cleanupcfg: Make sure TODO_cleanup_cfg is unset While I was looking into the code generation of PR 122727, I noticed that TODO_cleanup_cfg could be set from the call to execute_fixup_cfg even though cleanupcfg did nothing afterwards. This means the forwarder blocks that were just created with make_forwarders_with_degenerate_phis are being removed. Instead of conditionally unsetting TODO_cleanup_cfg, unconditionally unset TODO_cleanup_cfg after the call to make_forwarders_with_degenerate_phis. Since we already did the cleanup (maybe twice). Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/46555 gcc/ChangeLog: * tree-cfgcleanup.cc (execute_cleanup_cfg_post_optimizing): Unconditionally set TODO_cleanup_cfg. Signed-off-by: Andrew Pinski --- diff --git a/gcc/tree-cfgcleanup.cc b/gcc/tree-cfgcleanup.cc index 093fde93da6..2521e6d09fd 100644 --- a/gcc/tree-cfgcleanup.cc +++ b/gcc/tree-cfgcleanup.cc @@ -1409,10 +1409,7 @@ execute_cleanup_cfg_post_optimizing (void) { unsigned int todo = execute_fixup_cfg (); if (cleanup_tree_cfg ()) - { - todo &= ~TODO_cleanup_cfg; - todo |= TODO_update_ssa; - } + todo |= TODO_update_ssa; maybe_remove_unreachable_handlers (); cleanup_dead_labels (); if (group_case_labels () && cleanup_tree_cfg ()) @@ -1423,6 +1420,11 @@ execute_cleanup_cfg_post_optimizing (void) if (optimize) make_forwarders_with_degenerate_phis (cfun); + /* Make sure todo does not have cleanup cfg as we don't want + remove the forwarder blocks we just created. cleanup cfg + has already happened. */ + todo &= ~TODO_cleanup_cfg; + basic_block bb = single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)); gimple_stmt_iterator gsi = gsi_start_nondebug_after_labels_bb (bb); /* If the first (and only) bb and the only non debug