]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/6627 (-fno-align-functions regression from 2.95)
authorRoger Sayle <roger@eyesopen.com>
Sun, 6 Oct 2002 23:02:12 +0000 (23:02 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sun, 6 Oct 2002 23:02:12 +0000 (23:02 +0000)
PR optimization/6627
* 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.
* tree.h (enum ptrmemfunc_vbit_where_t): Move definition to
here from cp/cp-tree.h.

* cp/cp-tree.h (enum ptrmemfunc_vbit_where_t): Delete definition
from here, and move it to tree.h.
* 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): If storing the vbit in function
pointers, ensure that force_align_functions_log is atleast
one to aid compatability with g++ vtables.

From-SVN: r57869

gcc/ChangeLog
gcc/config/i386/i386.h
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/flags.h
gcc/java/ChangeLog
gcc/java/lang.c
gcc/toplev.c
gcc/tree.h
gcc/varasm.c

index 70af48b069421c4524781890eb0f5500d06e242b..0fbaac26fc9a54afa20f540129f0634e4e93a577 100644 (file)
@@ -1,3 +1,17 @@
+2002-10-06  Roger Sayle  <roger@eyesopen.com>
+
+       PR optimization/6627
+       * 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.
+       * tree.h (enum ptrmemfunc_vbit_where_t): Move definition to
+       here from cp/cp-tree.h.
+
 2002-10-06  Neil Booth  <neil@daikokuya.co.uk>
 
        Debian BTS Bug #157416
index 530c8d0fbe8538952356a49e503de28bf1a88ac8..58d2c4331eae2335c6fec004ec6a8e0ee33b9bf3 100644 (file)
@@ -760,8 +760,11 @@ extern int ix86_arch;
 #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
+/* 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 8e72f118befde861fc51da79b79a1a20f42ddeba..b8009df74958150782be33e4e7aa3dcbb48b4b21 100644 (file)
@@ -1,3 +1,12 @@
+2002-10-06  Roger Sayle  <roger@eyesopen.com>
+
+       PR optimization/6627
+       * cp/cp-tree.h (enum ptrmemfunc_vbit_where_t): Delete definition
+       from here, and move it to tree.h.
+       * cp/decl.c (cxx_init_decl_processing): If storing the vbit
+       in function pointers, ensure that force_align_functions_log
+       is atleast one.
+
 2002-10-04  H.J. Lu  (hjl@gnu.org)
 
        * pt.c (tsubst_decl, case VAR_DECL): Back out the last change.
index 787114f492b4802e9502ec98d762593b88584802..4bd08799e6fd3750a2c08121067795a8452a23a9 100644 (file)
@@ -2557,32 +2557,6 @@ extern int flag_new_for_scope;
    member function. [expr.unary.op]/3 */
 #define PTRMEM_OK_P(NODE) TREE_LANG_FLAG_0 (NODE)
 
-/* A pointer-to-function member type looks like:
-
-     struct {
-       __P __pfn;
-       ptrdiff_t __delta;
-     };
-
-   If __pfn is NULL, it is a NULL pointer-to-member-function.
-  
-   (Because the vtable is always the first thing in the object, we
-   don't need its offset.)  If the function is virtual, then PFN is
-   one plus twice the index into the vtable; otherwise, it is just a
-   pointer to the function.
-
-   Unfortunately, using the lowest bit of PFN doesn't work in
-   architectures that don't impose alignment requirements on function
-   addresses, or that use the lowest bit to tell one ISA from another,
-   for example.  For such architectures, we use the lowest bit of
-   DELTA instead of the lowest bit of the PFN, and DELTA will be
-   multiplied by 2.  */
-enum ptrmemfunc_vbit_where_t
-{
-  ptrmemfunc_vbit_in_pfn,
-  ptrmemfunc_vbit_in_delta
-};
-
 /* Get the POINTER_TYPE to the METHOD_TYPE associated with this
    pointer to member function.  TYPE_PTRMEMFUNC_P _must_ be true,
    before using this macro.  */
index 105e7a0d0d57d4eb6c87fe3da181683d5d159339..230ac04417124f9cadee2a54061cfdf5251c6682 100644 (file)
@@ -6517,6 +6517,12 @@ cxx_init_decl_processing ()
       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 40d42f2d0d51b7f1314392ff778e8f816a856756..85e07924b5d709a78e69f2a3230ffc81e17cad67 100644 (file)
@@ -604,6 +604,10 @@ extern int align_labels_max_skip;
 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 8cae2952e36e3a6304a79451f74a046e95929281..d705a01fbaeff181751054e8925beaa540f45f75 100644 (file)
@@ -1,3 +1,10 @@
+2002-10-06  Roger Sayle  <roger@eyesopen.com>
+
+       PR optimization/6627
+       * java/lang.c (java_init): If storing the vbit in function
+       pointers, ensure that force_align_functions_log is atleast
+       one to aid compatability with g++ vtables.
+
 2002-08-14  Release Manager
 
        * GCC 3.2 Released.
index 99c4547bdc61906eadc08ce360007941affb1bea..57ad7a1c2349def014f63da52b3a30b8c3c6290d 100644 (file)
@@ -458,6 +458,13 @@ java_init (filename)
   flag_minimal_debug = 0;
 #endif
 
+  /* Force minimum function alignment if g++ uses the least significant
+     bit of function pointers to store the virtual bit. This is required
+     to keep vtables compatible.  */
+  if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
+      && force_align_functions_log < 1)
+    force_align_functions_log = 1;
+
   /* Open input file.  */
 
   if (filename == 0 || !strcmp (filename, "-"))
index 2a44398925cebd5871f9fe7edc53e5baee38909e..d2732ce0e2de768be1b35d5f3134639869763e45 100644 (file)
@@ -879,6 +879,10 @@ int align_labels_max_skip;
 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 9346f7da60f722e040abf4ff66ff2c729adf66c7..084c3065cbd323d577b685105180ed028c94616d 100644 (file)
@@ -2051,6 +2051,33 @@ extern tree integer_types[itk_none];
 #define long_long_integer_type_node    integer_types[itk_long_long]
 #define long_long_unsigned_type_node   integer_types[itk_unsigned_long_long]
 
+\f
+/* A pointer-to-function member type looks like:
+
+     struct {
+       __P __pfn;
+       ptrdiff_t __delta;
+     };
+
+   If __pfn is NULL, it is a NULL pointer-to-member-function.
+
+   (Because the vtable is always the first thing in the object, we
+   don't need its offset.)  If the function is virtual, then PFN is
+   one plus twice the index into the vtable; otherwise, it is just a
+   pointer to the function.
+
+   Unfortunately, using the lowest bit of PFN doesn't work in
+   architectures that don't impose alignment requirements on function
+   addresses, or that use the lowest bit to tell one ISA from another,
+   for example.  For such architectures, we use the lowest bit of
+   DELTA instead of the lowest bit of the PFN, and DELTA will be
+   multiplied by 2.  */
+
+enum ptrmemfunc_vbit_where_t
+{
+  ptrmemfunc_vbit_in_pfn,
+  ptrmemfunc_vbit_in_delta
+};
 \f
 #define NULL_TREE (tree) NULL
 
index 4c27011bc8c7f0b5cea2f0e3d4ab950a637f09ac..9e683a54edebbed9ed50995e7215a42612e556ca 100644 (file)
@@ -1194,6 +1194,8 @@ assemble_start_function (decl, fnname)
 
   /* 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);