This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Mips profiling
- From: "Kris Warkentin" <kewarken at qnx dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Thu, 21 Mar 2002 14:26:08 -0500
- Subject: Re: Mips profiling
- References: <1aa501c1d0ed$373bff70$b6010c0a@catdog>
Replying to myself with some more observations - it seems that profiled code
on mips when compiled with optimization level -O2 is invalid. I've verified
it on QNX6 (2.95.3) and Irix (3.0.1). As near as I can tell from my
preliminary analysis, somewhere along the line the ra register is getting
clobbered and we wind up executing instructions off in the wild blue yonder.
cheers,
Kris
----- Original Message -----
From: "Kris Warkentin" <kewarken@qnx.com>
To: <gcc@gcc.gnu.org>
Sent: Thursday, March 21, 2002 10:29 AM
Subject: Mips profiling
> I've been looking at the following chunk of code from
gcc/config/mips/mips.h
> and something is puzzling me. The bit about 'mcount pops 2 words from
> stack' seems wrong. I believe the first four arguments to a function in
> mips will be passed in registers and the stack won't be involved. If I
read
> this correctly, we're leaking 8 bytes of stack memory per function call.
> The other question would be 'why don't we have something in the branch
delay
> slot of jal _mcount'? Wouldn't this cause problems depending on what this
> code was inserted before? Or did removing the '.set noreorder' which used
> to be in front of '.set noat' take care of this?
>
> cheers,
>
> Kris
>
> /* Output assembler code to FILE to increment profiler label # LABELNO
> for profiling a function entry. */
>
> #define FUNCTION_PROFILER(FILE, LABELNO) \
> { \
> if (TARGET_MIPS16) \
> sorry ("mips16 function profiling"); \
> fprintf (FILE, "\t.set\tnoat\n"); \
> fprintf (FILE, "\tmove\t%s,%s\t\t# save current return address\n", \
> reg_names[GP_REG_FIRST + 1], reg_names[GP_REG_FIRST + 31]); \
> fprintf (FILE, \
> "\t%s\t%s,%s,%d\t\t# _mcount pops 2 words from stack\n", \
> TARGET_64BIT ? "dsubu" : "subu", \
> reg_names[STACK_POINTER_REGNUM], \
> reg_names[STACK_POINTER_REGNUM], \
> Pmode == DImode ? 16 : 8); \
> fprintf (FILE, "\tjal\t_mcount\n"); \
> fprintf (FILE, "\t.set\tat\n"); \
> }
>
>
>
>