This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
SH profiling redux
- From: "Kris Warkentin" <kewarken at qnx dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Mon, 25 Mar 2002 13:26:32 -0500
- Subject: SH profiling redux
Hello,
I thought I'd present what I've got here for comment/suggestions. The
following bit in sh.h seems to cause _mcount() to be called and works more
or less. One problem I'm seeing is that with more complicated profiled
code, I often get a gmon.out which has no call graph data. The other
problem is that compiling C++ code generates a compiler error (see below the
patch). I'm not really wild about this solution since it requires some
naughtyness in the _mcount() function to adjust the $pr to skip over the
.LPrf label but I couldn't find a more elegant solution.
I've also put our _mcount() function below just in case I'm doing something
really dumb there. Any help would be much appreciated.
Cheers,
Kris
Index: sh.h
===================================================================
RCS file: /product/tools/gcc/gcc/config/sh/sh.h,v
retrieving revision 1.2
diff -r1.2 sh.h
1120a1121,1138
> /* Define SH_MCOUNT_NAME and include this file to enable gprof
> style profiling. */
> #ifdef SH_MCOUNT_NAME
> #define FUNCTION_PROFILER(STREAM,LABELNO) \
> { \
> char temp[20]; \
> rtx sym; \
> \
> fprintf((STREAM), "\tmov.l\t.LPrf%d,r0\n", (LABELNO)); \
> fprintf((STREAM), "\tsts.l\tpr,@-r15\n"); \
> fprintf((STREAM), "\tjsr\t@r0\n"); \
> fprintf((STREAM), "\tnop\n"); \
> fprintf((STREAM), "\t.align\t2\n"); \
> fprintf((STREAM), "\t.LPrf%d:\n", (LABELNO)); \
> fprintf((STREAM), "\t.long\t%s\n", (SH_MCOUNT_NAME)); \
> fprintf((STREAM), "\tlds.l\t@r15+,pr\n"); \
> }
> #else
1125d1142
<
1132a1150
> #endif
/usr/include/cpp/xstring: In method `class std::_Ptrit<char,int,char *,char
&,ch
ar *,char &>
std::basic_string<char,std::char_traits<char>,std::allocator<char>
>::begin()':
/usr/include/cpp/xstring:337: instantiated from
`std::basic_string<char,std::c
har_traits<char>,std::allocator<char> >::assign(const char *, const char *)'
/usr/include/cpp/xlocinfo:149: instantiated from here
/usr/include/cpp/xstring:659: Internal compiler error.
/usr/include/cpp/xstring:659: Please submit a full bug report.
/usr/include/cpp/xstring:659: See
<URL:http://www.gnu.org/software/gcc/bugs.html
> for instructions.
cc: /usr/lib/gcc-lib/ntosh/2.95.3/cc1plus error 33
{standard input}: Assembler messages:
{standard input}:2996: Warning: end of file not at end of a line; newline
insert
ed
{standard input}:3344: Error: missing operand
{standard input}:3344: Error: invalid operands for opcode
cc: /usr/bin/ntosh-as error 1
#define MCOUNT \
__asm__(".globl _mcount\n" \
"_mcount:\n" \
"mov.l __mcount_addr,r1\n" \
"mov.l @(4,r15),r3\n" \
"mov.l r4,@-r15\n" \
"mov.l r5,@-r15\n" \
"mov.l r6,@-r15\n" \
"mov.l r7,@-r15\n" \
"sts pr,r5 \n" \
"mov r3,r4 \n" \
"add #4,r5 \n" \
"mov #0xfc,r2\n" \
"and r2,r5 \n" \
"mov.l r5,@-r15\n" \
"jsr @r1 \n" \
"nop \n" \
"lds.l @r15+,pr\n" \
"mov.l @r15+,r7\n" \
"mov.l @r15+,r6\n" \
"mov.l @r15+,r5\n" \
"mov.l @r15+,r4\n" \
"rts \n" \
"nop \n" \
".align 2 \n" \
"__mcount_addr: \n" \
".long _mcount_\n" \
"1: \n" \
".type\t_mcount,@function\n" \
".size\t_mcount,.-_mcount\n" \
);