This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

"fix" 23602


The actual bug is that we don't generate proper unwind information
across the CFG with -fomit-frame-pointer && !ACCUMULATE_OUTGOING_ARGS.
Fixing that requires a whole new pass that would be able to globally
propagate such information.

In the meantime, disable combinations of options that can lead to
problems.

Tested on i486 and x86_64 linux.


r~



        PR target/23602
        * toplev.c (process_options): Warn about unsupported combinations
        of unwind tables and omit-frame-pointer.
        * config/i386/i386.c (override_options): Similarly.  Enable
        accumulate-outgoing-args if not explicitly disabled.
testsuite/
        * g++.dg/eh/omit-frame-pointer.C: Remove i?86 specific options.
        * g++.dg/eh/omit-frame-pointer2.C: Likewise.
libjava/
        * configure.host (i?86-*): Set -fomit-frame-pointer in libgcj_flags,
        but not BACKTRACESPEC.
        (x86_64-*): Similarly.  Don't set -ffloat-store in 64-bit mode.

Index: gcc/toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.975
diff -u -p -d -r1.975 toplev.c
--- gcc/toplev.c	9 Sep 2005 00:46:45 -0000	1.975
+++ gcc/toplev.c	5 Oct 2005 18:10:21 -0000
@@ -1778,6 +1778,18 @@ process_options (void)
     }
   if (!flag_stack_protect)
     warn_stack_protect = 0;
+
+  /* ??? Unwind info is not correct around the CFG unless either a frame
+     pointer is present or A_O_A is set.  Fixing this requires rewriting
+     unwind info generation to be aware of the CFG and propagating states
+     around edges.  */
+  if (flag_unwind_tables && !ACCUMULATE_OUTGOING_ARGS
+      && flag_omit_frame_pointer)
+    {
+      warning (0, "unwind tables currently requires a frame pointer "
+	       "for correctness");
+      flag_omit_frame_pointer = 0;
+    }
 }
 
 /* Initialize the compiler back end.  */
Index: gcc/config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.861
diff -u -p -d -r1.861 i386.c
--- gcc/config/i386/i386.c	25 Sep 2005 20:01:07 -0000	1.861
+++ gcc/config/i386/i386.c	5 Oct 2005 18:10:24 -0000
@@ -1653,6 +1653,21 @@ override_options (void)
       && !optimize_size)
     target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
 
+  /* ??? Unwind info is not correct around the CFG unless either a frame
+     pointer is present or M_A_O_A is set.  Fixing this requires rewriting
+     unwind info generation to be aware of the CFG and propagating states
+     around edges.  */
+  if ((flag_unwind_tables || flag_asynchronous_unwind_tables
+       || flag_exceptions || flag_non_call_exceptions)
+      && flag_omit_frame_pointer
+      && !(target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
+    {
+      if (target_flags_explicit & MASK_ACCUMULATE_OUTGOING_ARGS)
+	warning (0, "unwind tables currently require either a frame pointer "
+		 "or -maccumulate-outgoing-args for correctness");
+      target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
+    }
+
   /* Figure out what ASM_GENERATE_INTERNAL_LABEL builds as a prefix.  */
   {
     char *p;
Index: gcc/testsuite/g++.dg/eh/omit-frame-pointer.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/eh/omit-frame-pointer.C,v
retrieving revision 1.2
diff -u -p -d -r1.2 omit-frame-pointer.C
--- gcc/testsuite/g++.dg/eh/omit-frame-pointer.C	7 Jan 2002 22:40:52 -0000	1.2
+++ gcc/testsuite/g++.dg/eh/omit-frame-pointer.C	5 Oct 2005 18:10:24 -0000
@@ -1,6 +1,5 @@
 // { dg-do run }
 // { dg-options -fomit-frame-pointer }
-// { dg-options "-fomit-frame-pointer -mno-accumulate-outgoing-args" { target i?86-*-* } }
 
 #include <iostream>
 
Index: gcc/testsuite/g++.dg/eh/omit-frame-pointer2.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/eh/omit-frame-pointer2.C,v
retrieving revision 1.1
diff -u -p -d -r1.1 omit-frame-pointer2.C
--- gcc/testsuite/g++.dg/eh/omit-frame-pointer2.C	18 Dec 2002 16:41:11 -0000	1.1
+++ gcc/testsuite/g++.dg/eh/omit-frame-pointer2.C	5 Oct 2005 18:10:24 -0000
@@ -1,6 +1,5 @@
 // Reduced from PR c++/5246, PR c++/2447
 // { dg-options "-O -fomit-frame-pointer" }
-// { dg-options "-O -fomit-frame-pointer -mno-accumulate-outgoing-args" { target i?86-*-* } }
 // { dg-do run }
 
 void step (int)
Index: libjava/configure.host
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.host,v
retrieving revision 1.71
diff -u -p -d -r1.71 configure.host
--- libjava/configure.host	20 Aug 2005 20:26:25 -0000	1.71
+++ libjava/configure.host	5 Oct 2005 18:10:24 -0000
@@ -95,18 +95,27 @@ case "${host}" in
 	;;
   i686-*|i586-*|i486-*|i386-*)
 	sysdeps_dir=i386
-	libgcj_flags="${libgcj_flags} -ffloat-store"
+	# With -fomit-frame-pointer -maccumulate-outgoing-args (implied),
+	# the .text section of libgcj.so is 30k larger, and the .eh_frame
+	# section is 1.4M smaller.
+	libgcj_flags="${libgcj_flags} -ffloat-store -fomit-frame-pointer"
 	libgcj_interpreter=yes
 	libgcj_cxxflags=
 	libgcj_cflags=
 	DIVIDESPEC=-fno-use-divide-subroutine
-	BACKTRACESPEC=-fomit-frame-pointer
 	enable_hash_synchronization_default=yes
 	slow_pthread_self=yes
 	;;
   x86_64-*)
 	sysdeps_dir=x86-64
-	libgcj_flags="${libgcj_flags} -ffloat-store"
+	# For 64-bit we always use SSE registers for arithmetic,
+	# which doesn't have the extra precision problems of the fpu.
+	# But be careful about 32-bit multilibs.
+	case " $CC " in
+	*" -m32 "*)
+		libgcj_flags="${libgcj_flags} -ffloat-store" ;;
+	esac
+	libgcj_flags="${libgcj_flags} -fomit-frame-pointer"
 	libgcj_cxxflags=
 	libgcj_cflags=
 	DIVIDESPEC=-f%{m32:no-}use-divide-subroutine


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]