This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH -v4 9/9] tracing: add function graph tracer support for MIPS
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: wuzhangjin at gmail dot com
- Cc: pajko <kpajko79 at gmail dot com>, linux-kernel at vger dot kernel dot org, GCC Patches <gcc-patches at gcc dot gnu dot org>, Adam Nemet <anemet at caviumnetworks dot com>, rostedt at goodmis dot org, linux-mips at linux-mips dot org, Thomas Gleixner <tglx at linutronix dot de>, Ralf Baechle <ralf at linux-mips dot org>, Nicholas Mc Guire <der dot herr at hofr dot at>, David Daney <ddaney at caviumnetworks dot com>
- Date: Sun, 25 Oct 2009 15:55:34 +0000
- Subject: Re: [PATCH -v4 9/9] tracing: add function graph tracer support for MIPS
- References: <028867b99ec532b84963a35e7d552becc783cafc.1256135456.git.wuzhangjin@gmail.com> <2f73eae542c47ac5bbb9f7280e6c0271d193e90d.1256135456.git.wuzhangjin@gmail.com> <3f0d3515f74a58f4cfd11e61b62a129fdc21e3a7.1256135456.git.wuzhangjin@gmail.com> <96110ea5dd4d3d54eb97d0bb708a5bd81c7a50b5.1256135456.git.wuzhangjin@gmail.com> <af3ec1b5cd06b6f6a461c9fa7d09a51fabccb08d.1256135456.git.wuzhangjin@gmail.com> <a6f2959a69b6a77dd32cc36a5c8202f97d524f1e.1256135456.git.wuzhangjin@gmail.com> <53bdfdd95ec4fa00d4cc505bb5972cf21243a14d.1256135456.git.wuzhangjin@gmail.com> <26008418.post@talk.nabble.com> <1256467717.6143.13.camel@falcon>
Wu Zhangjin <wuzhangjin@gmail.com> writes:
> (Added linux-mips mailing list and the other people to the CC list.)
>
> On Thu, 2009-10-22 at 04:37 -0700, pajko wrote:
> [...]
>> >
>>
>> All this stuff can be avoided having PROFILE_BEFORE_PROLOGUE enabled in GCC
>> (gcc/config/mips/mips.h), like it is done one several other architectures.
>> Some of them even require it to be set for a working _mcount.
>> Putting the call of _mcount before the function prologue should make no harm
>> (it's working for me), and this way RA can be hooked for function graph
>> tracing
>> before it is saved to stack in the function prologue. Thus there will be no
>> difference between leaf and non-leaf functions.
>
> Good idea! Seems PROFILE_BEFORE_PROLOGUE is commented by default in
> gcc/config/mips/mips.h of gcc 4.4:
>
> /* #define PROFILE_BEFORE_PROLOGUE */
>
> if we enable this macro, the handling will be the same to non-leaf and
> leaf function, so, David's patch to gcc is not need again.
Defining PROFILE_BEFORE_PROLOGUE isn't correct for abicalls code,
because "jal _mcount" is a macro that loads _mcount from the
GOT into $25. We don't have access to $28 at the beginning of
the function, and we mustn't clobber the incoming value of $25.
So we could only make this change for non-abicalls code.
It's then a choice between (a) having new non-abicalls-specific
behaviour or (b) going with David's patch. The advantage of
(a) is that the linux code is slightly simpler. The disadvantage
is that it makes the _mcount interface differ between -mabicalls
and -mno-abicalls. And IMO the disadvantage outweights the advantage.
If this new behaviour is useful for linux, it could easily be useful
for userspace too. And with the new PLT support, non-shared abicalls
code is supposed to be link-compatible with non-abicalls code.
I think David's patch is the way to go.
Richard