public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14312] New: [tree-ssa regression] tailcalls not being generated when functions contain pointers
@ 2004-02-27 1:04 rearnsha at gcc dot gnu dot org
2004-02-27 1:05 ` [Bug optimization/14312] " rearnsha at gcc dot gnu dot org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2004-02-27 1:04 UTC (permalink / raw)
To: gcc-bugs
The attached function no-longer generates tail calls in tree-ssa. This is a
regression from 3.5.0 (the problem seems to be some intermediate variables that
are created by earlier passes and which are marked non-static, addressable).
Compile the attached code with
arm-elf-gcc -O2 -S test.c
void bar(int i);
void baz(int *);
void foo(int *x) { if (*x < 0) { baz (x); return; } bar(*x);
}
observe that the resulting code is
foo:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, uses_anonymous_args = 0
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}
ldr r3, [r0, #0]
cmp r3, #0
sub fp, ip, #4
blt .L5
mov r0, r3
bl bar
ldmfd sp, {fp, sp, pc}
.L5:
bl baz
ldmfd sp, {fp, sp, pc}
when it should be
ldr r3, [r0, #0]
cmp r3, #0
@ lr needed for prologue
blt .L4
mov r0, r3
b bar
.L4:
b baz
--
Summary: [tree-ssa regression] tailcalls not being generated when
functions contain pointers
Product: gcc
Version: tree-ssa
Status: UNCONFIRMED
Keywords: pessimizes-code
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rearnsha at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: arm-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14312
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14312] [tree-ssa regression] tailcalls not being generated when functions contain pointers
2004-02-27 1:04 [Bug optimization/14312] New: [tree-ssa regression] tailcalls not being generated when functions contain pointers rearnsha at gcc dot gnu dot org
@ 2004-02-27 1:05 ` rearnsha at gcc dot gnu dot org
2004-02-27 2:01 ` [Bug optimization/14312] [tree-ssa] [regression] " pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2004-02-27 1:05 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Known to fail| |tree-ssa
Known to work| |3.4.0 3.5.0
Last reconfirmed|0000-00-00 00:00:00 |2004-02-27 01:05:54
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14312
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14312] [tree-ssa] [regression] tailcalls not being generated when functions contain pointers
2004-02-27 1:04 [Bug optimization/14312] New: [tree-ssa regression] tailcalls not being generated when functions contain pointers rearnsha at gcc dot gnu dot org
2004-02-27 1:05 ` [Bug optimization/14312] " rearnsha at gcc dot gnu dot org
@ 2004-02-27 2:01 ` pinskia at gcc dot gnu dot org
2004-02-27 12:38 ` rth at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-27 2:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-02-27 02:01 -------
Confirmed. Next time please do not confirm your own bug.
--
What |Removed |Added
----------------------------------------------------------------------------
GCC target triplet|arm-elf |
Known to work|3.4.0 3.5.0 |3.4.0
Summary|[tree-ssa regression] |[tree-ssa] [regression]
|tailcalls not being |tailcalls not being
|generated when functions |generated when functions
|contain pointers |contain pointers
Target Milestone|--- |tree-ssa
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14312
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14312] [tree-ssa] [regression] tailcalls not being generated when functions contain pointers
2004-02-27 1:04 [Bug optimization/14312] New: [tree-ssa regression] tailcalls not being generated when functions contain pointers rearnsha at gcc dot gnu dot org
2004-02-27 1:05 ` [Bug optimization/14312] " rearnsha at gcc dot gnu dot org
2004-02-27 2:01 ` [Bug optimization/14312] [tree-ssa] [regression] " pinskia at gcc dot gnu dot org
@ 2004-02-27 12:38 ` rth at gcc dot gnu dot org
2004-02-27 13:16 ` dnovillo at redhat dot com
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rth at gcc dot gnu dot org @ 2004-02-27 12:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From rth at gcc dot gnu dot org 2004-02-27 12:37 -------
Diego, the problem here is that we reject FOO for tail-call optimization because
we find "TMT.1" is a "local variable" with TREE_ADDRESSABLE set. Clearly we need
to be ignoring memory tags.
Will you please invent a way to recoginize them and ignore them in
suitable_for_tail_opt_p?
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |dnovillo at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14312
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14312] [tree-ssa] [regression] tailcalls not being generated when functions contain pointers
2004-02-27 1:04 [Bug optimization/14312] New: [tree-ssa regression] tailcalls not being generated when functions contain pointers rearnsha at gcc dot gnu dot org
` (2 preceding siblings ...)
2004-02-27 12:38 ` rth at gcc dot gnu dot org
@ 2004-02-27 13:16 ` dnovillo at redhat dot com
2004-02-27 18:39 ` cvs-commit at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: dnovillo at redhat dot com @ 2004-02-27 13:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dnovillo at redhat dot com 2004-02-27 13:16 -------
Subject: Re: [tree-ssa] [regression] tailcalls not
being generated when functions contain pointers
On Fri, 2004-02-27 at 07:38, rth at gcc dot gnu dot org wrote:
> Will you please invent a way to recoginize them and ignore them in
> suitable_for_tail_opt_p?
>
There's nothing to invent, really. suitable_for_tail_opt_p was doing a
very weak test. It should really test whether the local variable is
call-clobbered, which is computed using escape analysis.
We ought to check other places in the optimizers where we use
addressability instead of is_call_clobbered.
Fixed with this patch. Will commit if testing doesn't show any
regressions.
Diego.
PR optimization/14312
* tree-tailcall.c (suitable_for_tail_opt_p): Call
is_call_clobbered instead of checking addressability.
Index: tree-tailcall.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-tailcall.c,v
retrieving revision 1.1.2.19
diff -d -c -p -r1.1.2.19 tree-tailcall.c
*** tree-tailcall.c 25 Feb 2004 03:22:47 -0000 1.1.2.19
--- tree-tailcall.c 27 Feb 2004 13:14:14 -0000
*************** suitable_for_tail_opt_p (void)
*** 72,87 ****
if (current_function_stdarg)
return false;
! /* No local variable should have its address taken, as otherwise it might
! be passed to the recursive call. This of course is overly
! conservative and should be replaced by a dataflow analysis later. */
for (i = 0; i < (int) VARRAY_ACTIVE_SIZE (referenced_vars); i++)
{
tree var = VARRAY_TREE (referenced_vars, i);
if (decl_function_context (var) == current_function_decl
! && !TREE_STATIC (var)
! && TREE_ADDRESSABLE (var))
return false;
}
--- 72,86 ----
if (current_function_stdarg)
return false;
! /* No local variable should be call-clobbered. We ignore any kind
! of memory tag, as these are not real variables. */
for (i = 0; i < (int) VARRAY_ACTIVE_SIZE (referenced_vars); i++)
{
tree var = VARRAY_TREE (referenced_vars, i);
if (decl_function_context (var) == current_function_decl
! && var_ann (var)->mem_tag_kind == NOT_A_TAG
! && is_call_clobbered (var))
return false;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14312
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14312] [tree-ssa] [regression] tailcalls not being generated when functions contain pointers
2004-02-27 1:04 [Bug optimization/14312] New: [tree-ssa regression] tailcalls not being generated when functions contain pointers rearnsha at gcc dot gnu dot org
` (3 preceding siblings ...)
2004-02-27 13:16 ` dnovillo at redhat dot com
@ 2004-02-27 18:39 ` cvs-commit at gcc dot gnu dot org
2004-02-27 18:45 ` dnovillo at gcc dot gnu dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-02-27 18:39 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-02-27 18:39 -------
Subject: Bug 14312
CVSROOT: /cvs/gcc
Module name: gcc
Branch: tree-ssa-20020619-branch
Changes by: dnovillo@gcc.gnu.org 2004-02-27 18:39:01
Modified files:
gcc : ChangeLog.tree-ssa tree-pretty-print.c
tree-ssa-alias.c tree-tailcall.c
gcc/testsuite : ChangeLog.tree-ssa
Added files:
gcc/testsuite/gcc.dg/tree-ssa: tailcall-2.c
Log message:
PR optimization/14312
* tree-pretty-print.c (dump_generic_node): Mark tail calls.
* tree-ssa-alias.c (compute_may_aliases): Restore call to
dump_referenced_vars.
(compute_points_to_and_addr_escape): If the address of a
variable V is stored into a non-pointer variable, mark V as
call-clobbered.
* tree-tailcall.c (suitable_for_tail_opt_p): Check for
call-clobbered instead of TREE_ADDRESSABLE.
Ignore memory tags.
(optimize_tail_call): Add newline to dump output.
testsuite/ChangeLog.tree-ssa
* gcc.dg/tree-ssa/tailcall-2.c: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.tree-ssa.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.1231&r2=1.1.2.1232
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-pretty-print.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.76&r2=1.1.2.77
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-alias.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.6&r2=1.1.2.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-tailcall.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.19&r2=1.1.2.20
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.tree-ssa.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.177&r2=1.1.2.178
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/tailcall-2.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=NONE&r2=1.1.2.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14312
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14312] [tree-ssa] [regression] tailcalls not being generated when functions contain pointers
2004-02-27 1:04 [Bug optimization/14312] New: [tree-ssa regression] tailcalls not being generated when functions contain pointers rearnsha at gcc dot gnu dot org
` (4 preceding siblings ...)
2004-02-27 18:39 ` cvs-commit at gcc dot gnu dot org
@ 2004-02-27 18:45 ` dnovillo at gcc dot gnu dot org
2004-03-04 3:00 ` dnovillo at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: dnovillo at gcc dot gnu dot org @ 2004-02-27 18:45 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dnovillo at gcc dot gnu dot org 2004-02-27 18:45 -------
Fixed. http://gcc.gnu.org/ml/gcc-patches/2004-02/msg02622.html
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14312
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14312] [tree-ssa] [regression] tailcalls not being generated when functions contain pointers
2004-02-27 1:04 [Bug optimization/14312] New: [tree-ssa regression] tailcalls not being generated when functions contain pointers rearnsha at gcc dot gnu dot org
` (5 preceding siblings ...)
2004-02-27 18:45 ` dnovillo at gcc dot gnu dot org
@ 2004-03-04 3:00 ` dnovillo at gcc dot gnu dot org
2004-03-07 2:03 ` pinskia at gcc dot gnu dot org
2004-03-09 15:05 ` dnovillo at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: dnovillo at gcc dot gnu dot org @ 2004-03-04 3:00 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dnovillo at gcc dot gnu dot org 2004-03-04 03:00 -------
The fix seems to have broken bootstraps on PPC. Re-opening.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14312
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14312] [tree-ssa] [regression] tailcalls not being generated when functions contain pointers
2004-02-27 1:04 [Bug optimization/14312] New: [tree-ssa regression] tailcalls not being generated when functions contain pointers rearnsha at gcc dot gnu dot org
` (6 preceding siblings ...)
2004-03-04 3:00 ` dnovillo at gcc dot gnu dot org
@ 2004-03-07 2:03 ` pinskia at gcc dot gnu dot org
2004-03-09 15:05 ` dnovillo at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-07 2:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-03-07 02:03 -------
Patch that most likely will fix the bootstrap problem is here: <http://gcc.gnu.org/ml/gcc/
2004-03/msg00370.html>.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14312
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug optimization/14312] [tree-ssa] [regression] tailcalls not being generated when functions contain pointers
2004-02-27 1:04 [Bug optimization/14312] New: [tree-ssa regression] tailcalls not being generated when functions contain pointers rearnsha at gcc dot gnu dot org
` (7 preceding siblings ...)
2004-03-07 2:03 ` pinskia at gcc dot gnu dot org
@ 2004-03-09 15:05 ` dnovillo at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: dnovillo at gcc dot gnu dot org @ 2004-03-09 15:05 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From dnovillo at gcc dot gnu dot org 2004-03-09 15:05 -------
Fixed with
* calls.c (initialize_argument_information): Add
parameter may_tail_call. Set to false for invisible
pass-by-reference arguments that require stack
allocation.
Update all users.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14312
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2004-03-09 15:05 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-27 1:04 [Bug optimization/14312] New: [tree-ssa regression] tailcalls not being generated when functions contain pointers rearnsha at gcc dot gnu dot org
2004-02-27 1:05 ` [Bug optimization/14312] " rearnsha at gcc dot gnu dot org
2004-02-27 2:01 ` [Bug optimization/14312] [tree-ssa] [regression] " pinskia at gcc dot gnu dot org
2004-02-27 12:38 ` rth at gcc dot gnu dot org
2004-02-27 13:16 ` dnovillo at redhat dot com
2004-02-27 18:39 ` cvs-commit at gcc dot gnu dot org
2004-02-27 18:45 ` dnovillo at gcc dot gnu dot org
2004-03-04 3:00 ` dnovillo at gcc dot gnu dot org
2004-03-07 2:03 ` pinskia at gcc dot gnu dot org
2004-03-09 15:05 ` dnovillo at gcc dot gnu dot org
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).