This is the mail archive of the 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]

ARM: Imply frame pointer for arm-linux profiling

The arm-linux invocation of mcount does not pass the old value of lr in ip,
the way the arm-elf or arm-netbsd implementations do.  Instead the profiler
grubs around in its caller's stack frame to find the saved lr.  Gross, but
nothing we can do about it now.  This patch makes sure to create a frame
if emitting the call to mcount.  It fixes nest.c and 20021014-1.c in gcc.dg
for arm-linux.  OK for HEAD?

On a related question: The ARM EABI does not appear to say anything about
mcount.  Right now our arm-linux-gnueabi port of glibc uses the same mcount
implementation as arm-linux, complete with this hack.  Should the EABI
specify something?  Does it, that I missed?

Daniel Jacobowitz
CodeSourcery, LLC

2005-05-10  Daniel Jacobowitz  <>

	* config/arm/linux-elf.h (SUBTARGET_FRAME_POINTER_REQUIRED): Define.
	* config/arm/arm.h (SUBTARGET_FRAME_POINTER_REQUIRED): Provide
	default definition.

Index: gcc/gcc/config/arm/linux-elf.h
--- gcc.orig/gcc/config/arm/linux-elf.h	2005-05-09 23:02:30.000000000 -0400
+++ gcc/gcc/config/arm/linux-elf.h	2005-05-10 09:28:04.621846009 -0400
@@ -128,11 +128,14 @@
 	   (TARGET_ARM && NEED_PLT_RELOC) ? "(PLT)" : "");		\
-/* The linux profiler clobbers the link register.  Make sure the
+/* The GNU/Linux profiler clobbers the link register.  Make sure the
    prologue knows to save it.  */
 #define PROFILE_HOOK(X)						\
   emit_insn (gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (SImode, LR_REGNUM)))
+/* The GNU/Linux profiler needs a frame pointer.  */
+#define SUBTARGET_FRAME_POINTER_REQUIRED current_function_profile
 #undef  CC1_SPEC
 #define CC1_SPEC "%{profile:-p}"
Index: gcc/gcc/config/arm/arm.h
--- gcc.orig/gcc/config/arm/arm.h	2005-05-09 23:02:30.000000000 -0400
+++ gcc/gcc/config/arm/arm.h	2005-05-10 09:26:29.943418032 -0400
@@ -861,8 +861,14 @@ extern int arm_structure_size_boundary;
    If we have to have a frame pointer we might as well make use of it.
    APCS says that the frame pointer does not need to be pushed in leaf
    functions, or simple tail call functions.  */
   (current_function_has_nonlocal_label				\
    || (TARGET_ARM && TARGET_APCS_FRAME && ! leaf_function_p ()))
 /* Return number of consecutive hard regs needed starting at reg REGNO

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