When -fomit-frame-pointer is used, main still uses a frame pointer. The -fomit-frame-pointer portion of the gcc info pages doesn't mention this special case. Release: gcc version 3.2.1 20021207 (Red Hat Linux 8.0 3.2.1-2) Environment: Linux canceled.ardi.com 2.4.20-2.2acpi #1 Thu Jan 2 16:31:33 MST 2003 i686 i686 i386 GNU/Linux How-To-Repeat: attached file includes tiny example.
State-Changed-From-To: open->analyzed State-Changed-Why: Doc bug.
From the docs: Don't keep the frame pointer in a register for functions that don't need one Well main needs it to realign the stack.
If you change main in my example program to xmain, you get the behavior one would expect without any apriori knowledge about what gcc is going to do. If gcc wants to treat main specially, that's fine. But if you don't document this special case, the documentation is incomplete. Just because main might be used as the entry point to a program doesn't mean that gcc users are going to guess that this means that main needs a frame pointer. Without special knowledge (e.g. documentation, examination of the gcc source code, examination of gcc's behavior) a knowledgable person would assume that whether a function needs a frame pointer or not is a question that can be resolved without knowing the function's name.
The note in the documention should be expanded to say approximately "-fomit-frame-pointer does nothing for the function main as it is the entry point and the need for realigning the stack is needed".
Subject: Bug 9350 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
Fixed.
Subject: Bug 9350 Author: stuart Date: Tue Feb 28 01:47:16 2006 New Revision: 111503 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111503 Log: 2006-02-17 Stuart Hastings <stuart@apple.com> * Radar 4356747 (marked APPLE LOCAL "4356747 stack realign") doc/extend.texi (force_align_arg_pointer): Document. doc/invoke.texi (-mstackrealign): Document. config/i386/i386.h (TARGET_OPTIONS): Add -mstackrealgin. config/i386/i386.c (ix86_force_align_arg_pointer): New. (ix86_force_align_arg_pointer_string): New. (ix86_attribute_table): Add "force_align_arg_pointer" attribute. (ix86_function_regparm): Compensate for new attribute. (ix86_internal_arg_pointer): Check for new attribute. 2005-11-02 Richard Henderson <rth@redhat.com> (marked APPLE LOCAL "mainline 2006-02-17 4356747 stack realign") 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. 2006-02-27 Stuart Hastings <stuart@apple.com> Radar 4448096 * testsuite/gcc.target/i386/4448096-1.c: New. * testsuite/g++.dg/4448096-2.C: New. Added: branches/apple-local-200502-branch/gcc/testsuite/gcc.target/i386/20060210-1.c branches/apple-local-200502-branch/gcc/testsuite/gcc.target/i386/20060210-2.c branches/apple-local-200502-branch/gcc/testsuite/gcc.target/i386/20060210-3.c branches/apple-local-200502-branch/gcc/testsuite/gcc.target/i386/20060210-4.c Modified: branches/apple-local-200502-branch/gcc/ChangeLog.apple-ppc branches/apple-local-200502-branch/gcc/config/i386/i386-protos.h branches/apple-local-200502-branch/gcc/config/i386/i386.c branches/apple-local-200502-branch/gcc/config/i386/i386.h branches/apple-local-200502-branch/gcc/config/i386/i386.md branches/apple-local-200502-branch/gcc/doc/extend.texi branches/apple-local-200502-branch/gcc/doc/invoke.texi branches/apple-local-200502-branch/gcc/dwarf2out.c branches/apple-local-200502-branch/gcc/emit-rtl.c branches/apple-local-200502-branch/gcc/function.c branches/apple-local-200502-branch/gcc/rtl.h branches/apple-local-200502-branch/gcc/target-def.h branches/apple-local-200502-branch/gcc/target.h branches/apple-local-200502-branch/gcc/targhooks.c branches/apple-local-200502-branch/gcc/targhooks.h branches/apple-local-200502-branch/gcc/testsuite/ChangeLog.apple-ppc branches/apple-local-200502-branch/gcc/tree.h