This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, arm] Thumb profiling is broken
- From: Nick Clifton <nickc at redhat dot com>
- To: anemet at Lnxw dot COM
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 24 Sep 2002 17:50:54 +0100
- Subject: Re: [PATCH, arm] Thumb profiling is broken
Hi Adam,
With regard to this patch submission:
> THUMB_FUNCTION_PROFILER emits the reference to the profiler label
> without the leading dot:
[snip]
> Apparently, THUMB_FUNCTION_PROFILER and ARM_FUNCTION_PROFILER are
> supposed to emit the same thing, so I kept the ARM version for both
> modes.
I agree that the problem exists, and that your solution works, but
it does have a problem. Certain other header files (eg netbsd.h,
linux-elf.h) in the gcc/config/arm directory provide alternative
definitions for ARM_FUNCTION_PROFILER and if you rename it in arm.h
you would also have to rename them there.
A simpler solution I feel is to just remove the definition of
THUMB_FUNCTION_PROFILER and then change the definition of
FUNCTION_PROFILER so that it uses ARM_FUNCTION_PROFILER.
In fact we can be slightly sneaker and change the definition only if
THUMB_FUNCTION_PROFILER is not defined, so that if, in the future,
we find that for some targets we do need a special thumb version of
the profiler we can just define THUMB_FUNCTION_PROFILER and not have
to change anything else.
Hence I am going to apply the patch below which is an amalgam of
your idea and mine.
Cheers
Nick
PS. Sorry for the very long delay in getting round to look at your
patch!
2002-09-24 Adam Nemet <anemet@lnxw.com>
Nick Clifton <nickc@redhat.com>
* config/arm/arm.h (THUMB_FUNCTION_PROFILER): Remove.
(FUNCTION_PROFILER): Only invoke THUMB_FUNCTION_PROFILER if it
is defined.
Index: gcc/config/arm/arm.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.h,v
retrieving revision 1.162
diff -c -3 -p -w -r1.162 arm.h
*** gcc/config/arm/arm.h 20 Sep 2002 06:36:33 -0000 1.162
--- gcc/config/arm/arm.h 24 Sep 2002 16:41:29 -0000
*************** typedef struct
*** 1547,1553 ****
will output the .text section.
The ``mov ip,lr'' seems like a good idea to stick with cc convention.
! ``prof'' doesn't seem to mind about this! */
#ifndef ARM_FUNCTION_PROFILER
#define ARM_FUNCTION_PROFILER(STREAM, LABELNO) \
{ \
--- 1547,1556 ----
will output the .text section.
The ``mov ip,lr'' seems like a good idea to stick with cc convention.
! ``prof'' doesn't seem to mind about this!
!
! Note - this version of the code is designed to work in both ARM and
! Thumb modes. */
#ifndef ARM_FUNCTION_PROFILER
#define ARM_FUNCTION_PROFILER(STREAM, LABELNO) \
{ \
*************** typedef struct
*** 1564,1583 ****
}
#endif
! #ifndef THUMB_FUNCTION_PROFILER
! #define THUMB_FUNCTION_PROFILER(STREAM, LABELNO) \
! { \
! fprintf (STREAM, "\tmov\tip, lr\n"); \
! fprintf (STREAM, "\tbl\tmcount\n"); \
! fprintf (STREAM, "\t.word\tLP%d\n", LABELNO); \
! }
! #endif
!
#define FUNCTION_PROFILER(STREAM, LABELNO) \
if (TARGET_ARM) \
ARM_FUNCTION_PROFILER (STREAM, LABELNO) \
else \
THUMB_FUNCTION_PROFILER (STREAM, LABELNO)
/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
the stack pointer does not matter. The value is tested only in
--- 1567,1582 ----
}
#endif
! #ifdef THUMB_FUNCTION_PROFILER
#define FUNCTION_PROFILER(STREAM, LABELNO) \
if (TARGET_ARM) \
ARM_FUNCTION_PROFILER (STREAM, LABELNO) \
else \
THUMB_FUNCTION_PROFILER (STREAM, LABELNO)
+ #else
+ #define FUNCTION_PROFILER(STREAM, LABELNO) \
+ ARM_FUNCTION_PROFILER (STREAM, LABELNO)
+ #endif
/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
the stack pointer does not matter. The value is tested only in