Fix use of TARGET_VTABLE_USES_DESCRIPTORS in libgcov.c

Submitted by Steve Ellcey on Oct. 12, 2010, 5:45 p.m.

Details

Message ID 201010121745.o9CHjCg27298@lucas.cup.hp.com
State New
Headers show

Commit Message

Steve Ellcey Oct. 12, 2010, 5:45 p.m.
This is another patch related to the recent flag handling change.  In
the other cases the problem was that we were using macros that depended
on runtime flags in an ifdef.

Here, in libgcov.c, we use TARGET_VTABLE_USES_DESCRIPTORS in an
expression but libgcov.c is part of the libgcov library and not
part of the compiler and so it cannot access target values which
depend on compiler flags.  Luckily, we don't need the value, we
just need to know if it is set or not so my fix is to set a new
macro (VTABLE_USES_DESCRIPTORS) to a fixed value (0 or 1) based
on whether or not a target sets TARGET_VTABLE_USES_DESCRIPTORS
and then use that macro in libgcov.c.

I am still testing this on IA64, but assuming the testing finishes,
is this OK to checkin?

Steve Ellcey
sje@cup.hp.com


2010-10-11  Steve Ellcey  <sje@cup.hp.com>

	* defaults.h (VTABLE_USES_DESCRIPTORS): New.
	* libgcov.c (__gcov_indirect_call_profiler): Use
	VTABLE_USES_DESCRIPTORS instead of TARGET_VTABLE_USES_DESCRIPTORS.

Comments

Steve Ellcey Oct. 21, 2010, 9:12 p.m.
This is a ping for:

http://gcc.gnu.org/ml/gcc-patches/2010-10/msg01064.html

which is breaking the IA64 HP-UX bootstrap.

Steve Ellcey
sje@cup.hp.com
Richard Henderson Oct. 31, 2010, 11:45 p.m.
On 10/12/2010 10:45 AM, Steve Ellcey wrote:
> +   VTABLE_USES_DESCRIPTORS is set to 0 if TARGET_VTABLE_USES_DESCRIPTORS
> +   is not set by the target or 1 if it is.  This is needed because
> +   TARGET_VTABLE_USES_DESCRIPTORS could depend on compiler flags and
> +   cannot be used in libgcov.c.  */
> +
> +#ifdef TARGET_VTABLE_USES_DESCRIPTORS
> +#define VTABLE_USES_DESCRIPTORS 1
> +#else
>  #define TARGET_VTABLE_USES_DESCRIPTORS 0
> +#define VTABLE_USES_DESCRIPTORS 0
>  #endif

Not ok for defaults.h.

It does seem like the smallest change would be an ifdef test in
libgconv.c, e.g. moving the above sequence into libgconv.c.

A Proper Fix would seem to be providing a cpp-builtin define,
but without adding some sort of -fbuilding-libgcc flag, I don't
know if we want to export such a define to the users.


r~

Patch hide | download patch | download mbox

Index: defaults.h
===================================================================
--- defaults.h	(revision 165348)
+++ defaults.h	(working copy)
@@ -814,13 +814,22 @@  see the files COPYING3 and COPYING.RUNTI
 #endif
 
 /* By default, the C++ compiler will use function addresses in the
-   vtable entries.  Setting this nonzero tells the compiler to use
-   function descriptors instead.  The value of this macro says how
-   many words wide the descriptor is (normally 2).  It is assumed
-   that the address of a function descriptor may be treated as a
-   pointer to a function.  */
-#ifndef TARGET_VTABLE_USES_DESCRIPTORS
+   vtable entries.  Setting TARGET_VTABLE_USES_DESCRIPTORS to nonzero
+   tells the compiler to use function descriptors instead.  The value
+   of this macro says how many words wide the descriptor is (normally 2).
+   It is assumed that the address of a function descriptor may be treated
+   as a pointer to a function.
+
+   VTABLE_USES_DESCRIPTORS is set to 0 if TARGET_VTABLE_USES_DESCRIPTORS
+   is not set by the target or 1 if it is.  This is needed because
+   TARGET_VTABLE_USES_DESCRIPTORS could depend on compiler flags and
+   cannot be used in libgcov.c.  */
+
+#ifdef TARGET_VTABLE_USES_DESCRIPTORS
+#define VTABLE_USES_DESCRIPTORS 1
+#else
 #define TARGET_VTABLE_USES_DESCRIPTORS 0
+#define VTABLE_USES_DESCRIPTORS 0
 #endif
 
 /* By default, the vtable entries are void pointers, the so the alignment
Index: libgcov.c
===================================================================
--- libgcov.c	(revision 165348)
+++ libgcov.c	(working copy)
@@ -777,7 +777,7 @@  __gcov_indirect_call_profiler (gcov_type
      function may have multiple descriptors and we need to dereference
      the descriptors to see if they point to the same function.  */
   if (cur_func == callee_func
-      || (TARGET_VTABLE_USES_DESCRIPTORS && callee_func
+      || (VTABLE_USES_DESCRIPTORS && callee_func
 	  && *(void **) cur_func == *(void **) callee_func))
     __gcov_one_value_profiler_body (counter, value);
 }