]> 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>
Wed, 2 Oct 2002 18:46:45 +0000 (18:46 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Wed, 2 Oct 2002 18:46:45 +0000 (18:46 +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: r57745

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 eca95941c4bd8b19fda7362c721b4a6bccb70f9a..346cb9b39a13283ce1062c62ded7ee5ace08bc4e 100644 (file)
@@ -1,3 +1,17 @@
+2002-10-02  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-02  Matt Austern  <austern@apple.com>
        * cp/decl.c (walk_vtables_r): Fixed typo that caused result to
        never get a nonzero value.
index af9c37fc131776369171bcaf648b75e7d3180386..a59168bd898e6fa56ae23c8d345aecf609e7a682 100644 (file)
@@ -695,8 +695,11 @@ extern int x86_prefetch_sse;
 #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 e78f0c2b342862970669d7f3ea01e743e04797df..16c986504dfb63d44acfed95006139b48735935a 100644 (file)
@@ -1,3 +1,12 @@
+2002-10-02  Roger Sayle  <roger@eyesopen.com>
+
+       PR optimization/6627
+       * cp-tree.h (enum ptrmemfunc_vbit_where_t): Delete definition
+       from here, and move it to tree.h.
+       * decl.c (cxx_init_decl_processing): If storing the vbit
+       in function pointers, ensure that force_align_functions_log
+       is atleast one.
+
 2002-10-01  Mark Mitchell  <mark@codesourcery.com>
 
        * decl.c (cp_finish_decl): Make sure array types are laid out,
index 3a9c7e76d710e0510a622b64d1b3db1a94d64b06..db19e539da46f1539513b8c9fbc8f717b9e31dc4 100644 (file)
@@ -2540,32 +2540,6 @@ struct lang_decl GTY(())
    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 4c8dbc408760450a6c669a3002d146fde337bc9c..e095f07c239d4c0e6a30b87a783777db4ebf3d3d 100644 (file)
@@ -6510,6 +6510,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 1578a2499cdc08b2abf2070215e7e1e0b11b1629..e0e7b09a1687d8fc6770ef22b658b3ad03aa2284 100644 (file)
@@ -616,6 +616,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 07c53ec1ccfa996cfdfd51c4c629bb4fd2e6ed74..1c1c1d09154c0be1d424cc21f6c3afe308a8a1f1 100644 (file)
@@ -1,3 +1,10 @@
+2002-10-02  Roger Sayle  <roger@eyesopen.com>
+
+       PR optimization/6627
+       * 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-10-01  Nathan Sidwell  <nathan@codesourcery.com>
 
        * jcf-dump.c (print_constant, case CONSTANT_float): Don't fall
index c6fbb44ddd8d478ba166207d9993f278121f3d5f..706b4f12776bb685731eb247be96969c637dedc4 100644 (file)
@@ -516,6 +516,13 @@ java_init (filename)
   if (flag_inline_functions)
     flag_inline_trees = 1;
 
+  /* 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 9121c212b12d74fb226a8589be2582c0b5dd3f51..261442714fe126434fc68e1039a167c8bce423e5 100644 (file)
@@ -912,6 +912,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 1d0941c323ba3800c93732c823e1f2e6d9bd4ecd..252c2bc392ef1d60f4009754d0a0d8b80cbfc886 100644 (file)
@@ -2114,6 +2114,33 @@ enum tls_model {
 
 extern enum tls_model flag_tls_default;
 \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
 
 /* Approximate positive square root of a host double.  This is for
index d24e914811c7b5341a16771e2b5d1ef49355747c..80d076f21d161e38dafd8adb761bdf003483e804 100644 (file)
@@ -1171,6 +1171,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);