Bug 12039 - [tree-ssa] [unit-at-a-time] does not mark static variable as used.
: [tree-ssa] [unit-at-a-time] does not mark static variable as used.
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: rtl-optimization
: tree-ssa
: P1 critical
: tree-ssa
Assigned To: Not yet assigned to anyone
:
: wrong-code
:
:
  Show dependency treegraph
 
Reported: 2003-08-23 03:25 UTC by Andrew Pinski
Modified: 2003-10-17 22:42 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-10-17 14:33:15


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2003-08-23 03:25:15 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;
}
Comment 1 Andrew Pinski 2003-08-23 03:26:39 UTC
Forwarded from <http://gcc.gnu.org/ml/gcc/2003-08/msg01215.html> so confirming
as I 
could confirm this on the tree-ssa (20030822).
Comment 2 Andrew Pinski 2003-08-30 00:51:07 UTC
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.
Comment 3 Judd Jenne 2003-08-31 03:33:11 UTC
[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]
Comment 4 Andrew Pinski 2003-09-19 19:17:51 UTC
*** Bug 12342 has been marked as a duplicate of this bug. ***
Comment 5 Andrew Pinski 2003-10-17 18:48:42 UTC
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.
Comment 6 Andrew Pinski 2003-10-17 22:42:10 UTC
Was fixed by the patch so closing.