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]

[PATCH] PR opt/6627 (take2): force_align_functions_log


On Sun, 29 Sep 2002, Richard Henderson wrote:
> So I think we want separate variables here.  One that might be
> ignored, and one that shouldn't be.  force_align_functions?

Sounds good!  Here's a revised patch to fix GNATS high priority
PR optimization/6627.  Rather than introduce a new target macro
and work around the semantics of FUNCTION_BOUNDARY, this corrects
the i386 usage of FUNCTION_BOUNDARY, but introduces a new flag
force_align_functions_log that can be used by front-ends to
force function alignment greater than FUNCTION_BOUNDARY.

This patch has been tested with a complete "make bootstrap" and
"make -k check", all languages except Ada and treelang, on
i686-pc-linux-gnu with no new regressions.  I've also checked
by hand that this resolves the problem in PR opt/6627 when
compiled with "gcc -Os", but inserts a "nop" with "g++ -Os"
on i686.

Ok for mainline and to close PR optimization/6627?



2002-10-01  Roger Sayle  <roger@eyesopen.com>

	* toplev.c (force_align_functions_log): New global variable.
	* flags.h (force_align_functions_log): Add extern prototype.
	* varasm.c (assemble_start_function): Use it to force minimum
	function alignment.
	* config/i386/i386.h (FUNCTION_BOUNDARY): Set the correct
	minimum function alignment to one byte.
	(TARGET_PTRMEMFUNC_VBIT_LOCATION): Store the virtual bit in
	the least significant bit of vtable member function pointers.

	* cp/decl.c (cxx_init_decl_processing): If storing the vbit
	in function pointers, ensure that force_align_functions_log
	is atleast one.

	* java/lang.c (java_init): Ensure force_align_functions_log
	is atleast one to aid compatability with g++ vtables.


Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.677
diff -c -3 -p -r1.677 toplev.c
*** toplev.c	27 Sep 2002 12:48:03 -0000	1.677
--- toplev.c	1 Oct 2002 13:02:49 -0000
*************** int align_labels_max_skip;
*** 912,917 ****
--- 912,921 ----
  int align_functions;
  int align_functions_log;

+ /* Like align_functions_log above, but used by front-ends to force the
+    minimum function alignment.  Zero means no alignment is forced.  */
+ int force_align_functions_log;
+
  /* Table of supported debugging formats.  */
  static const struct
  {
Index: flags.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flags.h,v
retrieving revision 1.90
diff -c -3 -p -r1.90 flags.h
*** flags.h	27 Sep 2002 13:30:06 -0000	1.90
--- flags.h	1 Oct 2002 13:02:49 -0000
*************** extern int align_labels_max_skip;
*** 616,621 ****
--- 616,625 ----
  extern int align_functions;
  extern int align_functions_log;

+ /* Like align_functions_log above, but used by front-ends to force the
+    minimum function alignment.  Zero means no alignment is forced.  */
+ extern int force_align_functions_log;
+
  /* Nonzero if we dump in VCG format, not plain text.  */
  extern int dump_for_graph;

Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.313
diff -c -3 -p -r1.313 varasm.c
*** varasm.c	27 Sep 2002 13:30:04 -0000	1.313
--- varasm.c	1 Oct 2002 13:02:50 -0000
*************** assemble_start_function (decl, fnname)
*** 1171,1176 ****
--- 1171,1178 ----

    /* Tell assembler to move to target machine's alignment for functions.  */
    align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
+   if (align < force_align_functions_log)
+     align = force_align_functions_log;
    if (align > 0)
      {
        ASM_OUTPUT_ALIGN (asm_out_file, align);
Index: config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.291
diff -c -3 -p -r1.291 i386.h
*** config/i386/i386.h	30 Sep 2002 13:00:32 -0000	1.291
--- config/i386/i386.h	1 Oct 2002 13:02:51 -0000
*************** extern int x86_prefetch_sse;
*** 695,702 ****
  #define FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN \
    (ix86_preferred_stack_boundary > STACK_BOUNDARY && !TARGET_64BIT)

! /* Allocation boundary for the code of a function.  */
! #define FUNCTION_BOUNDARY 16

  /* Alignment of field after `int : 0' in a structure.  */

--- 695,705 ----
  #define FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN \
    (ix86_preferred_stack_boundary > STACK_BOUNDARY && !TARGET_64BIT)

! /* Minimum allocation boundary for the code of a function.  */
! #define FUNCTION_BOUNDARY 8
!
! /* C++ stores the virtual bit in the lowest bit of function pointers.  */
! #define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_pfn

  /* Alignment of field after `int : 0' in a structure.  */

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.938
diff -c -3 -p -r1.938 decl.c
*** cp/decl.c	30 Sep 2002 16:52:12 -0000	1.938
--- cp/decl.c	1 Oct 2002 13:02:53 -0000
*************** cxx_init_decl_processing ()
*** 6510,6515 ****
--- 6510,6521 ----
        flag_inline_functions = 0;
      }

+   /* Force minimum function alignment if using the least significant
+      bit of function pointers to store the virtual bit.  */
+   if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
+       && force_align_functions_log < 1)
+     force_align_functions_log = 1;
+
    /* Initially, C.  */
    current_lang_name = lang_name_c;

Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/lang.c,v
retrieving revision 1.110
diff -c -3 -p -r1.110 lang.c
*** java/lang.c	30 Sep 2002 14:57:43 -0000	1.110
--- java/lang.c	1 Oct 2002 13:02:54 -0000
*************** java_init (filename)
*** 516,521 ****
--- 516,527 ----
    if (flag_inline_functions)
      flag_inline_trees = 1;

+   /* Force minimum function alignment to ensure interoperability
+      with g++ vtables which may use the least significant bit of
+      member function pointers to store the virtual bit.  */
+   if (force_align_functions_log < 1)
+     force_align_functions_log = 1;
+
    /* Open input file.  */

    if (filename == 0 || !strcmp (filename, "-"))


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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