public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main
@ 2005-10-14 20:11 pinskia at gcc dot gnu dot org
2005-10-14 20:12 ` [Bug target/24374] " pinskia at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-14 20:11 UTC (permalink / raw)
To: gcc-bugs
Take the following example:
int main1(void);
int main(void)
{
return main1();
}
----
With 3.4.0, we got at -O2:
main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
subl $16, %esp
call main1
leave
ret
While with 4.0.0 and above we get:
main:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
subl $16, %esp
leave
jmp main1
.size main, .-main
This is wrong, we should not be sibcalling optimizing in main at all.
--
Summary: [4.0/4.1 Regression] Sibcalling optimization is
happening in main
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P2
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
GCC target triplet: i?86-*-*
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/24374] [4.0/4.1 Regression] Sibcalling optimization is happening in main
2005-10-14 20:11 [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main pinskia at gcc dot gnu dot org
@ 2005-10-14 20:12 ` pinskia at gcc dot gnu dot org
2005-10-15 17:40 ` pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-14 20:12 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.0.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/24374] [4.0/4.1 Regression] Sibcalling optimization is happening in main
2005-10-14 20:11 [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main pinskia at gcc dot gnu dot org
2005-10-14 20:12 ` [Bug target/24374] " pinskia at gcc dot gnu dot org
@ 2005-10-15 17:40 ` pinskia at gcc dot gnu dot org
2005-10-15 20:02 ` jkj at sco dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-15 17:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2005-10-15 17:40 -------
I should note that the reasons why you don't want to sibcalling optimize to
calls in main is so that the alignment fix up is not lost in the secondary
function.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/24374] [4.0/4.1 Regression] Sibcalling optimization is happening in main
2005-10-14 20:11 [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main pinskia at gcc dot gnu dot org
2005-10-14 20:12 ` [Bug target/24374] " pinskia at gcc dot gnu dot org
2005-10-15 17:40 ` pinskia at gcc dot gnu dot org
@ 2005-10-15 20:02 ` jkj at sco dot com
2005-10-15 20:14 ` jkj at sco dot com
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jkj at sco dot com @ 2005-10-15 20:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jkj at sco dot com 2005-10-15 20:02 -------
Created an attachment (id=9990)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9990&action=view)
This change to calls.c fixes the problem for me
I'm almost certain that there is a better way to do this, but this patch fixed
the problem for me.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/24374] [4.0/4.1 Regression] Sibcalling optimization is happening in main
2005-10-14 20:11 [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main pinskia at gcc dot gnu dot org
` (2 preceding siblings ...)
2005-10-15 20:02 ` jkj at sco dot com
@ 2005-10-15 20:14 ` jkj at sco dot com
2005-10-15 21:18 ` jkj at sco dot com
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jkj at sco dot com @ 2005-10-15 20:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jkj at sco dot com 2005-10-15 20:14 -------
Created an attachment (id=9991)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9991&action=view)
Sorry I uploaded the wrong diff. this is against mainline.
--
jkj at sco dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #9990 is|0 |1
obsolete| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/24374] [4.0/4.1 Regression] Sibcalling optimization is happening in main
2005-10-14 20:11 [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main pinskia at gcc dot gnu dot org
` (3 preceding siblings ...)
2005-10-15 20:14 ` jkj at sco dot com
@ 2005-10-15 21:18 ` jkj at sco dot com
2005-10-16 4:25 ` rth at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jkj at sco dot com @ 2005-10-15 21:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jkj at sco dot com 2005-10-15 21:18 -------
Created an attachment (id=9993)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9993&action=view)
New patch based on comments from Pinski
--
jkj at sco dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #9991 is|0 |1
obsolete| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/24374] [4.0/4.1 Regression] Sibcalling optimization is happening in main
2005-10-14 20:11 [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main pinskia at gcc dot gnu dot org
` (4 preceding siblings ...)
2005-10-15 21:18 ` jkj at sco dot com
@ 2005-10-16 4:25 ` rth at gcc dot gnu dot org
2005-10-31 6:25 ` mmitchel at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rth at gcc dot gnu dot org @ 2005-10-16 4:25 UTC (permalink / raw)
To: gcc-bugs
--
rth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rth at gcc dot gnu dot org
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2005-10-16 04:24:58
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/24374] [4.0/4.1 Regression] Sibcalling optimization is happening in main
2005-10-14 20:11 [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main pinskia at gcc dot gnu dot org
` (5 preceding siblings ...)
2005-10-16 4:25 ` rth at gcc dot gnu dot org
@ 2005-10-31 6:25 ` mmitchel at gcc dot gnu dot org
2005-10-31 7:13 ` jkj at sco dot com
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-10-31 6:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from mmitchel at gcc dot gnu dot org 2005-10-31 06:25 -------
Kean, I think you need to check TREE_PUBLIC (decl) as well; a "static" main
function isn't the main you're looking for. Note that a "static" main is
permitted by gcc, with a warning, by default.
(It looks like the same bug appears in cfgexpand.c, by the way. I'll open a
new PR for that.)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/24374] [4.0/4.1 Regression] Sibcalling optimization is happening in main
2005-10-14 20:11 [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main pinskia at gcc dot gnu dot org
` (6 preceding siblings ...)
2005-10-31 6:25 ` mmitchel at gcc dot gnu dot org
@ 2005-10-31 7:13 ` jkj at sco dot com
2005-11-03 1:40 ` rth at gcc dot gnu dot org
2005-11-03 1:42 ` rth at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: jkj at sco dot com @ 2005-10-31 7:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jkj at sco dot com 2005-10-31 07:12 -------
rth has a completely different fix for this that is much more comprehensive.
http://gcc.gnu.org/ml/gcc/2005-10/msg00412.html has the details. I'm still
working on bringing my 4.1 tree up to speed so I can help him test this.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/24374] [4.0/4.1 Regression] Sibcalling optimization is happening in main
2005-10-14 20:11 [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main pinskia at gcc dot gnu dot org
` (7 preceding siblings ...)
2005-10-31 7:13 ` jkj at sco dot com
@ 2005-11-03 1:40 ` rth at gcc dot gnu dot org
2005-11-03 1:42 ` rth at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: rth at gcc dot gnu dot org @ 2005-11-03 1:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from rth at gcc dot gnu dot org 2005-11-03 01:40 -------
Subject: Bug 24374
Author: rth
Date: Thu Nov 3 01:40:33 2005
New Revision: 106420
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106420
Log:
PR target/9350
PR target/24374
* dwarf2out.c (dwarf2out_reg_save_reg): New.
(dwarf2out_frame_debug_expr): Return after dwarf_handle_frame_unspec.
* function.c (assign_parms): Use calls.internal_arg_pointer.
(expand_main_function): Remove FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
code.
* target-def.h (TARGET_INTERNAL_ARG_POINTER): New.
(TARGET_CALLS): Add it.
* target.h (struct gcc_target): Add calls.internal_arg_pointer.
* targhooks.c (default_internal_arg_pointer): New.
* targhooks.h (default_internal_arg_pointer): Declare.
* tree.h (dwarf2out_reg_save_reg): Declare.
* doc/tm.texi (FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN): Remove.
* config/i386/i386.c (dbx_register_map): Add return column.
(dbx64_register_map, svr4_dbx_register_map): Likewise.
(TARGET_INTERNAL_ARG_POINTER, ix86_internal_arg_pointer): New.
(TARGET_DWARF_HANDLE_FRAME_UNSPEC, ix86_dwarf_handle_frame_unspec):
New. (ix86_function_ok_for_sibcall): Disable if force_align_arg_pointer.
(ix86_save_reg): Save force_align_arg_pointer.
(ix86_emit_save_regs): Make regno unsigned.
(ix86_emit_save_regs_using_mov): Likewise.
(ix86_expand_prologue): Handle force_align_arg_pointer.
(ix86_expand_epilogue): Likewise.
* config/i386/i386.h: (dbx_register_map): Update.
(dbx64_register_map, svr4_dbx_register_map): Update.
(struct machine_function): Add force_align_arg_pointer.
* config/i386/i386.md (UNSPEC_REG_SAVE, UNSPEC_DEF_CFA): New.
(UNSPEC_TP, UNSPEC_TLS_GD, UNSPEC_TLS_LD_BASE): Renumber.
(TARGET_PUSH_MEMORY peepholes): Disable if RTX_FRAME_RELATED_P.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/i386.c
trunk/gcc/config/i386/i386.h
trunk/gcc/config/i386/i386.md
trunk/gcc/doc/tm.texi
trunk/gcc/dwarf2out.c
trunk/gcc/function.c
trunk/gcc/target-def.h
trunk/gcc/target.h
trunk/gcc/targhooks.c
trunk/gcc/targhooks.h
trunk/gcc/tree.h
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug target/24374] [4.0/4.1 Regression] Sibcalling optimization is happening in main
2005-10-14 20:11 [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main pinskia at gcc dot gnu dot org
` (8 preceding siblings ...)
2005-11-03 1:40 ` rth at gcc dot gnu dot org
@ 2005-11-03 1:42 ` rth at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: rth at gcc dot gnu dot org @ 2005-11-03 1:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rth at gcc dot gnu dot org 2005-11-03 01:42 -------
Fixed for mainline. I have no particular need to see this backported to 4.0.
Any change there should be limited to ix86_function_ok_for_sibcall.
--
rth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|4.0.3 |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-11-03 1:42 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-14 20:11 [Bug target/24374] New: [4.0/4.1 Regression] Sibcalling optimization is happening in main pinskia at gcc dot gnu dot org
2005-10-14 20:12 ` [Bug target/24374] " pinskia at gcc dot gnu dot org
2005-10-15 17:40 ` pinskia at gcc dot gnu dot org
2005-10-15 20:02 ` jkj at sco dot com
2005-10-15 20:14 ` jkj at sco dot com
2005-10-15 21:18 ` jkj at sco dot com
2005-10-16 4:25 ` rth at gcc dot gnu dot org
2005-10-31 6:25 ` mmitchel at gcc dot gnu dot org
2005-10-31 7:13 ` jkj at sco dot com
2005-11-03 1:40 ` rth at gcc dot gnu dot org
2005-11-03 1:42 ` rth 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).