GCC Bugzilla – Bug 12039
[tree-ssa] [unit-at-a-time] does not mark static variable as used.
Last modified: 2003-10-17 22:42:10 UTC
Compile the following code (derived from GCC) with -O2 -funit-at-a-time: static void record_insn_name(int code) { static int last_real_code = 0; last_real_code = code; } int main(void) { record_insn_name(4); return 0; }
Forwarded from <http://gcc.gnu.org/ml/gcc/2003-08/msg01215.html> so confirming as I could confirm this on the tree-ssa (20030822).
There has been two other reports of this one already, one for c++ and another one for c, if I had time I would look at it but I having bootstrap problems again and I am working on a paper now that has to be done by Saturday night.
[Brought in from gcc mailing list.] Andrew, First of all, thank you for looking into this. I produced these using an ssa compiler from the last few hours. I hope this helps. I used something like -fdump-tree-all. I didn't include dumps that seemed identical to those prior. It seems that rewrite_out_of_ssa() seems a likely culprit from examining dumps .dce and .optimized. Off Topic: [snipped] Various Files: // tc1.c static int foo(int n) { static int yy = 0; yy = n; return yy; } int main(void) { int pp; pp = foo(3); return pp; } // tc1.c.t02.original ;; Function foo (foo) ;; enabled by -tree-original { static int yy = 0; yy = n; return <return-value> = yy; } ;; Function main (main) ;; enabled by -tree-original { int pp; pp = foo(3); return <return-value> = pp; } // tc1.c.t03.generic ;; Function foo (foo) foo (n) { static int yy = 0; yy = n; return yy;; } ;; Function main (main) main () { int T.1; int pp; T.1 = foo (3); pp = T.1; return pp;; } // tc1.c.t05.gimple ;; Function main (main) main () { int retval.2; int T.1; int pp; { int n; int <UVecb0>; n = 3; { static int yy = 0; yy = n; { <UVecb0> = yy; goto <ULec40>;; }; }; <ULec40>:;; retval.2 = <UVecb0>; }; T.1 = retval.2; pp = T.1; return pp;; } // tc1.c.t09.ssa ;; Function main (main) main () { int retval.2; int T.1; int pp; { int n; int <UVecb0>; n_1 = 3; { static int yy = 0; yy = 3; <UVecb0>_4 = 3; goto <ULec40>;; }; <ULec40>:;; retval.2_5 = 3; }; T.1_6 = 3; pp_7 = 3; return 3;; } // tc1.c.t13.pre ;; Function main (main) main () { int retval.2; int T.1; int pp; { int n; int <UVecb0>; (void)0; { static int yy = 0; yy = 3; (void)0; goto <ULec40>;; }; <ULec40>:;; (void)0; }; (void)0; (void)0; return 3;; } // tc1.c.t17.optimized ;; Function main (main) main () { { yy = 3; <ULec40>:;; }; return 3;; } Judd [snipped]
*** Bug 12342 has been marked as a duplicate of this bug. ***
Most likely fixed by, I will check once I compile the compiler with this patch applied: Branch: tree-ssa-20020619-branch Changes by: hubicka@gcc.gnu.org 2003-10-17 18:34:04 Modified files: gcc : ChangeLog.tree-ssa tree-cfg.c Log message: * tree-cfg.c (remove_useless_stmts_and_vars_bind): Fix handling of static variables.
Was fixed by the patch so closing.