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 for virtual destructor vtable on IA64 HP-UX


Mark,
g++ puts virtual destructor entries at the order of the function is defined.
HP aCC always put virtual destructor entries at the end of a vtable, aCC is
not able to change it at this stage. To make g++ objects can work together
with aCC objects, I modified g++ to simulate the aCC behavior. This would
only affect HP-UX on IA64 platform. Could you please review it and check it
in if okay?

Thanks.

----
Jessica Han
Open Source Tools
Hewlett-Packard
(408) 447-6154


2002-09-11 Jessica Han <jessica@cup.hp.com>
	*defaults.h         Set TARGET_PUT_DESTRUCTOR_AT_THE_END default value 0
	*config/ia64/hpux.h Set TARGET_PUT_DESTRUCTOR_AT_THE_END
	*cp/class.c	        Put virtual destructors at the end of vtable when
TARGET_PUT_DESTRUCTOR_AT_THE_END is set
	*doc/tm.texi 	  Description for TARGET_PUT_DESTRUCTOR_AT_THE_END

*** defaults.h.1.91	Tue Sep 10 10:57:27 2002
--- defaults.h	Tue Sep 10 12:23:14 2002
*************** do { fputs (integer_asm_op (POINTER_SIZE
*** 450,455 ****
--- 450,461 ----
  #define TARGET_VTABLE_DATA_ENTRY_DISTANCE 1
  #endif

+ /* Always put virtual destructor entries at the end of a vtable.
+  */
+ #ifndef TARGET_PUT_DESTRUCTOR_AT_THE_END
+ #define TARGET_PUT_DESTRUCTOR_AT_THE_END 0
+ #endif
+
  /* Select a format to encode pointers in exception handling data.  We
     prefer those that result in fewer dynamic relocations.  Assume no
     special support here and encode direct references.  */
*** hpux.h.1.13	Tue Sep 10 10:58:17 2002
--- hpux.h	Tue Sep 10 17:29:31 2002
*************** do {							\
*** 135,140 ****
--- 135,146 ----
  #undef TARGET_HPUX_LD
  #define TARGET_HPUX_LD	1

+ /* HP aCC always put virtual destructor entries at the bottom of a vtable,
we
+    have to simulate it to make g++ work with aCC.
+  */
+ #undef TARGET_PUT_DESTRUCTOR_AT_THE_END
+ #define TARGET_PUT_DESTRUCTOR_AT_THE_END 1
+
  /* Put out the needed function declarations at the end.  */

  #define ASM_FILE_END(STREAM) ia64_hpux_asm_file_end(STREAM)
*** class.c.1.465	Tue Sep 10 11:08:44 2002
--- class.c	Wed Sep 11 16:00:23 2002
*************** create_vtable_ptr (t, empty_p, virtuals_
*** 4351,4357 ****

    /* Collect the virtual functions declared in T.  */
    for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn))
!     if (DECL_VINDEX (fn) && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn)
  	&& TREE_CODE (DECL_VINDEX (fn)) != INTEGER_CST)
        {
  	tree new_virtual = make_node (TREE_LIST);
--- 4351,4359 ----

    /* Collect the virtual functions declared in T.  */
    for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn))
!     if (DECL_VINDEX (fn)
!         && ((TARGET_PUT_DESTRUCTOR_AT_THE_END && !DECL_DESTRUCTOR_P (fn))
||
!             (!TARGET_PUT_DESTRUCTOR_AT_THE_END &&
!DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn)))
  	&& TREE_CODE (DECL_VINDEX (fn)) != INTEGER_CST)
        {
  	tree new_virtual = make_node (TREE_LIST);
*************** create_vtable_ptr (t, empty_p, virtuals_
*** 4363,4368 ****
--- 4365,4385 ----
  	*virtuals_p = new_virtual;
        }

+   if (TARGET_PUT_DESTRUCTOR_AT_THE_END)
+     for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn))
+       if (DECL_VINDEX (fn) && DECL_DESTRUCTOR_P (fn) &&
+           !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn)
+           && TREE_CODE (DECL_VINDEX (fn)) != INTEGER_CST)
+         {
+           tree new_virtual = make_node (TREE_LIST);
+
+           BV_FN (new_virtual) = fn;
+           BV_DELTA (new_virtual) = integer_zero_node;
+
+           TREE_CHAIN (new_virtual) = *virtuals_p;
+           *virtuals_p = new_virtual;
+         }
+
    /* If we couldn't find an appropriate base class, create a new field
       here.  Even if there weren't any new virtual functions, we might need
a
       new virtual function table if we're supposed to include vptrs in
*** tm.texi.1.165	Tue Sep 10 11:13:25 2002
--- tm.texi	Tue Sep 10 11:42:33 2002
*************** There are a few non-descriptor entries i
*** 1731,1736 ****
--- 1731,1740 ----
  zero.  If these entries must be padded (say, to preserve the alignment
  specified by @code{TARGET_VTABLE_ENTRY_ALIGN}), set this to the number
  of words in each data entry.
+
+ @findex TARGET_PUT_DESTRUCTOR_AT_THE_END
+ @item TARGET_PUT_DESTRUCTOR_AT_THE_END
+ By default, normal vtable entries for virtual destructors are laid out at
the squence destructors are defined. When this marco is set, put the virtual
destructor entries at the bottom of tha vtable.
  @end table

  @node Escape Sequences

----
Jessica Han
Open Source Tools
Hewlett-Packard
(408) 447-6154


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