https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118790

--- Comment #24 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So
--- gcc/tree-ssa-live.cc.jj     2025-01-02 11:23:05.915664859 +0100
+++ gcc/tree-ssa-live.cc        2025-02-11 14:44:33.940178150 +0100
@@ -369,9 +369,17 @@ mark_all_vars_used_1 (tree *tp, int *wal
     {
       /* When a global var becomes used for the first time also walk its
          initializer (non global ones don't have any).  */
-      if (set_is_used (t) && is_global_var (t)
-         && DECL_CONTEXT (t) == current_function_decl)
-       mark_all_vars_used (&DECL_INITIAL (t));
+      if (set_is_used (t))
+       {
+         if (is_global_var (t)
+             && DECL_CONTEXT (t) == current_function_decl)
+           mark_all_vars_used (&DECL_INITIAL (t));
+         if (DECL_HAS_VALUE_EXPR_P (t))
+           {
+             tree dve = DECL_VALUE_EXPR (t);
+             mark_all_vars_used (&dve);
+           }
+       }
     }
   /* remove_unused_scope_block_p requires information about labels
      which are not DECL_IGNORED_P to tell if they might be used in the IL.  */
?  Except this doesn't work, that new code isn't encountered on the testcase,
so it must be something else that removes the vars.

Reply via email to