This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: missing increment bug
- To: Ulrich Drepper <drepper at cygnus dot com>
- Subject: Re: missing increment bug
- From: Richard Henderson <rth at redhat dot com>
- Date: Thu, 30 Nov 2000 12:21:25 -0800
- Cc: gcc-patches at gcc dot gnu dot org
- References: <m3n1ehl6dc.fsf@otr.mynet.cygnus.com>
On Thu, Nov 30, 2000 at 09:25:19AM -0800, Ulrich Drepper wrote:
> http://www.cygnus.com/~drepper/l.i.gz
Minimal test case (committed as execute/20001130-1.c) is
static inline int bar(void) { return 1; }
static int mem[3];
static int foo(int x)
{
if (x != 0)
return x;
mem[x++] = foo(bar());
if (x != 1)
abort();
return 0;
}
int main()
{
foo(0);
return 0;
}
We'd thought to emit queued insns before beginning the tail call
sequence, but not the tail recursion sequence. The inline function
invocation is required to trigger the bug.
Fixed thus.
r~
* calls.c (expand_call): Emit queued insns before creating
the tail recursion sequence.
Index: calls.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/calls.c,v
retrieving revision 1.167
diff -c -p -d -r1.167 calls.c
*** calls.c 2000/11/29 00:27:54 1.167
--- calls.c 2000/11/30 20:06:15
*************** expand_call (exp, target, ignore)
*** 2552,2557 ****
--- 2552,2561 ----
int save_pending_stack_adjust = pending_stack_adjust;
int save_stack_pointer_delta = stack_pointer_delta;
+ /* Emit any queued insns now; otherwise they would end up in
+ only one of the alternates. */
+ emit_queue ();
+
/* Use a new sequence to hold any RTL we generate. We do not even
know if we will use this RTL yet. The final decision can not be
made until after RTL generation for the entire function is