public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/26840]  New: escaping global variables cause 'definition follows use' error.
@ 2006-03-24  2:59 geoffk at gcc dot gnu dot org
  2006-03-24  3:00 ` [Bug middle-end/26840] " geoffk at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2006-03-24  2:59 UTC (permalink / raw)
  To: gcc-bugs

The following testcase:

extern int f1 (void **);
extern void f2 (void *);

struct s
{
  unsigned char field1;
  int field2;
};

static inline struct s *
get_globals (void)
{
  struct s * r;
  void * rr;

  if (f1 (&rr))
    return 0;
  r = rr;
  if (! r)
    {
      extern struct s t;
      r = &t;
    }
  r->field1 = 1;
  return r;
}

void
atexit_common (const void *dso)
{
  struct s *g = get_globals ();

  if (! g)
    return;
  if (g->field1)
    {
      g->field2 = 0;
      f2 (g);
    }
  else
    f2 (g);
}

when compiled with

./xgcc -B./ -O2 crt3.c -S

ICEs with:

crt3.c: In function 'atexit_common':
crt3.c:30: error: definition in block 7 follows the use
for SSA_NAME: rr_11 in statement:
#   rr_23 = V_MAY_DEF <rr_11>;
#   SFT.1_24 = V_MAY_DEF <SFT.1_22>;
#   SFT.2_25 = V_MAY_DEF <SFT.2_26>;
f2 (g_1);

It appears that the problem is that phicprop1 makes a fairly harmless
modification to this:

#   rr_11 = V_MAY_DEF <rr_16>;
#   SFT.1_22 = V_MAY_DEF <SFT.1_17>;
g_2->field2 = 0

but since it's modified it, it calls update_operands, which turns it into:

#   SFT.1_22 = V_MAY_DEF <SFT.1_17>;
g_1->field2 = 0

deleting the rr_11 set.  That of course leaves no rr_11 sets at all, and
produces the error.

Now, in this particular case I believe the change is correct, in that 'rr'
really can't be modified by this instruction, but then of course you shouldn't
have had an rr_11 at all.  The 036t.forwprop1 dump file says

  #   SFT.1_22 = V_MAY_DEF <SFT.1_17>;
  g_5->field2 = 0;

then 037t.copyprop1 adds rr_11 and says

  #   rr_11 = V_MAY_DEF <rr_16>;
  #   SFT.1_22 = V_MAY_DEF <SFT.1_17>;
  g_2->field2 = 0;

so it's possible that this is the original problem.


-- 
           Summary: escaping global variables cause 'definition follows use'
                    error.
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: geoffk at gcc dot gnu dot org
 GCC build triplet: powerpc-apple-darwin
  GCC host triplet: powerpc-apple-darwin
GCC target triplet: powerpc-apple-darwin


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/26840] escaping global variables cause 'definition follows use' error.
  2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
@ 2006-03-24  3:00 ` geoffk at gcc dot gnu dot org
  2006-03-24  3:03 ` [Bug middle-end/26840] [4.2 Regression] " pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2006-03-24  3:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from geoffk at gcc dot gnu dot org  2006-03-24 03:00 -------
Passing -fno-tree-dominator-opts disables sufficient optimisations to avoid the
problem.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/26840] [4.2 Regression] escaping global variables cause 'definition follows use' error.
  2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
  2006-03-24  3:00 ` [Bug middle-end/26840] " geoffk at gcc dot gnu dot org
@ 2006-03-24  3:03 ` pinskia at gcc dot gnu dot org
  2006-03-24  3:04 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-24  3:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-03-24 03:03 -------
Caused by:
2006-03-20  Jeff Law  <law@redhat.com>

        * tree-pass.h (pass_phi_only_copy_prop): Delete.
        (pass_phi_only_cprop): Declare.
        * passes.c (init_optimization_passes): Replace pass_phi_only_copy_prop
        with phi_only_cprop
        * tree-ssa-dom.c (degenerate_phi_result): New function.
        (remove_stmt_or_phi, get_lhs_or_phi_result): Likewise.
        (get_rhs_or_phi_arg, propagate_rhs_into_lhs): Likewise.
        (eliminate_const_or_copy, eliminate_degenerate_phis_1): Likewise.
        (eliminate_degenerate_phis): Likewise.
        (pass_phi_only_cprop): New pass descriptor.
        * tree-ssa-copy.c (init_copy_prop): Lose PHIS_ONLY argument and
        support code.  Callers updated.
        (execute_copy_prop, do_copy_prop): Likewise and corresponding changes.
        (store_copy_prop): Likewise.
        (do_phi_only_copy_prop, pass_phi_only_copy_prop): Remove.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at redhat dot com
           Severity|major                       |blocker
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|0000-00-00 00:00:00         |2006-03-24 03:03:08
               date|                            |
            Summary|escaping global variables   |[4.2 Regression] escaping
                   |cause 'definition follows   |global variables cause
                   |use' error.                 |'definition follows use'
                   |                            |error.
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/26840] [4.2 Regression] escaping global variables cause 'definition follows use' error.
  2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
  2006-03-24  3:00 ` [Bug middle-end/26840] " geoffk at gcc dot gnu dot org
  2006-03-24  3:03 ` [Bug middle-end/26840] [4.2 Regression] " pinskia at gcc dot gnu dot org
@ 2006-03-24  3:04 ` pinskia at gcc dot gnu dot org
  2006-03-24  3:32 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-24  3:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-03-24 03:04 -------
I am adding the build keyword as this source would come from crt3.c which fixes
a different build failure.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-checking                |build


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/26840] [4.2 Regression] escaping global variables cause 'definition follows use' error.
  2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-03-24  3:04 ` pinskia at gcc dot gnu dot org
@ 2006-03-24  3:32 ` pinskia at gcc dot gnu dot org
  2006-03-24 13:58 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-24  3:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2006-03-24 03:32 -------
This happens also on x86_64-linux-gnu.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
  GCC build triplet|powerpc-apple-darwin        |
   GCC host triplet|powerpc-apple-darwin        |
 GCC target triplet|powerpc-apple-darwin        |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/26840] [4.2 Regression] escaping global variables cause 'definition follows use' error.
  2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-03-24  3:32 ` pinskia at gcc dot gnu dot org
@ 2006-03-24 13:58 ` pinskia at gcc dot gnu dot org
  2006-03-24 14:50 ` dberlin at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-24 13:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2006-03-24 13:58 -------
This was __NOT__ fixed by the patch for PR 26806.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/26840] [4.2 Regression] escaping global variables cause 'definition follows use' error.
  2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-03-24 13:58 ` pinskia at gcc dot gnu dot org
@ 2006-03-24 14:50 ` dberlin at gcc dot gnu dot org
  2006-03-24 14:53 ` law at redhat dot com
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dberlin at gcc dot gnu dot org @ 2006-03-24 14:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from dberlin at gcc dot gnu dot org  2006-03-24 14:49 -------
The only reason i can think that this would occur is if the copies had
different SMT's or NMT's associated with them, but that shouldn't happen, since
they are copies :)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/26840] [4.2 Regression] escaping global variables cause 'definition follows use' error.
  2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-03-24 14:50 ` dberlin at gcc dot gnu dot org
@ 2006-03-24 14:53 ` law at redhat dot com
  2006-03-24 14:56 ` law at redhat dot com
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: law at redhat dot com @ 2006-03-24 14:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from law at redhat dot com  2006-03-24 14:53 -------
Subject: Re:  [4.2 Regression] escaping global
        variables cause 'definition follows use' error.

On Fri, 2006-03-24 at 13:58 +0000, pinskia at gcc dot gnu dot org wrote:
> 
> ------- Comment #5 from pinskia at gcc dot gnu dot org  2006-03-24 13:58 -------
> This was __NOT__ fixed by the patch for PR 26806.
I know.  Never claimed otherwise.  

jeff


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/26840] [4.2 Regression] escaping global variables cause 'definition follows use' error.
  2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2006-03-24 14:53 ` law at redhat dot com
@ 2006-03-24 14:56 ` law at redhat dot com
  2006-03-24 21:59 ` geoffk at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: law at redhat dot com @ 2006-03-24 14:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from law at redhat dot com  2006-03-24 14:56 -------
Subject: Re:  [4.2 Regression] escaping global
        variables cause 'definition follows use' error.

On Fri, 2006-03-24 at 14:49 +0000, dberlin at gcc dot gnu dot org wrote:
> 
> ------- Comment #6 from dberlin at gcc dot gnu dot org  2006-03-24 14:49 -------
> The only reason i can think that this would occur is if the copies had
> different SMT's or NMT's associated with them, but that shouldn't happen, since
> they are copies :)
The problem here is the set of virtual operands changes as a result
of propagating an invariant ADDR_EXPR into a use site.  What's odd
is the code should be mimicking how other passes already deal with
this issue.

For reasons I don't understand yet, we haven't marked those virtual
operands which are removed from the use site for renaming.  I'll be
working on this today.

jeff


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/26840] [4.2 Regression] escaping global variables cause 'definition follows use' error.
  2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2006-03-24 14:56 ` law at redhat dot com
@ 2006-03-24 21:59 ` geoffk at gcc dot gnu dot org
  2006-03-24 23:23 ` law at redhat dot com
  2006-03-24 23:24 ` law at redhat dot com
  10 siblings, 0 replies; 12+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2006-03-24 21:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from geoffk at gcc dot gnu dot org  2006-03-24 21:59 -------
Subject: Bug 26840

Author: geoffk
Date: Fri Mar 24 21:59:48 2006
New Revision: 112361

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112361
Log:
2006-03-23  Geoffrey Keating  <geoffk@apple.com>

        PR 26793
        * config/t-darwin (crt3.o): Work around bug 26840.
        * config/darwin-crt3.c: Rewrite.
        * config/darwin.h (STARTFILE_SPEC): Don't use -l for crt3.o.

Index: gcc/testsuite/ChangeLog
2006-03-24  Geoffrey Keating  <geoffk@apple.com>

        * g++.old-deja/g++.other/init19.C: New.

Added:
    trunk/gcc/testsuite/g++.old-deja/g++.other/init19.C
      - copied, changed from r112297,
branches/apple-local-200502-branch/gcc/testsuite/g++.old-deja/g++.other/init19.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/darwin-crt3.c
    trunk/gcc/config/darwin.h
    trunk/gcc/config/t-darwin
    trunk/gcc/dwarf2out.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/26840] [4.2 Regression] escaping global variables cause 'definition follows use' error.
  2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2006-03-24 21:59 ` geoffk at gcc dot gnu dot org
@ 2006-03-24 23:23 ` law at redhat dot com
  2006-03-24 23:24 ` law at redhat dot com
  10 siblings, 0 replies; 12+ messages in thread
From: law at redhat dot com @ 2006-03-24 23:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from law at redhat dot com  2006-03-24 23:23 -------
Subject: Re:  [4.2 Regression] escaping global
        variables cause 'definition follows use' error.

On Fri, 2006-03-24 at 03:03 +0000, pinskia at gcc dot gnu dot org wrote:
> 
> ------- Comment #2 from pinskia at gcc dot gnu dot org  2006-03-24 03:03 -------
> Caused by:
> 2006-03-20  Jeff Law  <law@redhat.com>
> 
>         * tree-pass.h (pass_phi_only_copy_prop): Delete.
>         (pass_phi_only_cprop): Declare.
>         * passes.c (init_optimization_passes): Replace pass_phi_only_copy_prop
>         with phi_only_cprop
>         * tree-ssa-dom.c (degenerate_phi_result): New function.
>         (remove_stmt_or_phi, get_lhs_or_phi_result): Likewise.
>         (get_rhs_or_phi_arg, propagate_rhs_into_lhs): Likewise.
>         (eliminate_const_or_copy, eliminate_degenerate_phis_1): Likewise.
>         (eliminate_degenerate_phis): Likewise.
>         (pass_phi_only_cprop): New pass descriptor.
>         * tree-ssa-copy.c (init_copy_prop): Lose PHIS_ONLY argument and
>         support code.  Callers updated.
>         (execute_copy_prop, do_copy_prop): Likewise and corresponding changes.
>         (store_copy_prop): Likewise.
>         (do_phi_only_copy_prop, pass_phi_only_copy_prop): Remove.
Fixed by not calling update_stmt directly, but instead letting
mark_new_vars_to_rename call update_stmt at the appropriate time.

Bootstrapped and regression tested on i686-pc-linux-gnu.

Onward to Ada...



> 
> 


------- Comment #11 from law at redhat dot com  2006-03-24 23:23 -------
Created an attachment (id=11117)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11117&action=view)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/26840] [4.2 Regression] escaping global variables cause 'definition follows use' error.
  2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2006-03-24 23:23 ` law at redhat dot com
@ 2006-03-24 23:24 ` law at redhat dot com
  10 siblings, 0 replies; 12+ messages in thread
From: law at redhat dot com @ 2006-03-24 23:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from law at redhat dot com  2006-03-24 23:24 -------
Fix via today's checkin.


-- 

law at redhat dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26840


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-03-24 23:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-24  2:59 [Bug middle-end/26840] New: escaping global variables cause 'definition follows use' error geoffk at gcc dot gnu dot org
2006-03-24  3:00 ` [Bug middle-end/26840] " geoffk at gcc dot gnu dot org
2006-03-24  3:03 ` [Bug middle-end/26840] [4.2 Regression] " pinskia at gcc dot gnu dot org
2006-03-24  3:04 ` pinskia at gcc dot gnu dot org
2006-03-24  3:32 ` pinskia at gcc dot gnu dot org
2006-03-24 13:58 ` pinskia at gcc dot gnu dot org
2006-03-24 14:50 ` dberlin at gcc dot gnu dot org
2006-03-24 14:53 ` law at redhat dot com
2006-03-24 14:56 ` law at redhat dot com
2006-03-24 21:59 ` geoffk at gcc dot gnu dot org
2006-03-24 23:23 ` law at redhat dot com
2006-03-24 23:24 ` law at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).