Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@cs.Helsinki.FI>
Subject: Re: profiling bug on alpha-linux
Date: Fri, 5 Apr 1996 13:20:11 +0300 (EET DST)	[thread overview]
Message-ID: <d72d1c94aebb7fda890ab12ef315543e.axp-list@archive.invalid> (raw)
In-Reply-To: <m0u54hb-00026UC@atheist.tamu.edu>

On Fri, 5 Apr 1996, Richard Henderson wrote:
> 
> Leaf functions on alpha-linux improperly overwrite the
> return address register ($26) when profiling is on.

Umm.. Wouldn't it be better to use another register for the return 
address when calling _mcount? You could use one of the normal scratch 
registers for it, and then you wouldn't need to save anything.

Of course, that would also mean that the "_mcount" function couldn't be 
written in C (or at least not compiled with gcc), but I'd assume that you 
wouldn't want to do that anyway?

> Case in point, the null function `foo(){ }' compiles,
> with -O -p, to
> 
> ------------------
>         .ent foo
> foo:
>         ldgp $29,0($27)
> foo..ng:
>         .frame $30,0,$26,0
>         .prologue 1
> .data
>         .align 3
> $P32:
>         .quad 0
> .text
>         lda $27,_mcount
>         jsr $26,($27),_mcount
>         ldgp $29,0($26)
>         ret $31,($26),1
>         .end foo
> ------------------
> 
> Note that foo's return address is not saved before the call
> to _mcount kills it.  The fix, of course, is to always save
> the return address register when profiling is on.

What I'd suggest would result in something like

	lda $27,_mcount
	jsr $XX,($27),_mcount
	ldgp $29,0($XX)

where XX is some scratch register (and _mcount returns using a 
sequence of "ret $31,($XX),1"). Kind of like the alternate call sequence 
used by the integer division stuff..

Of course, your fix looks fine too, and I guess this isn't really 
performance-critical anyway.

		Linus

  reply	other threads:[~1996-04-05 10:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-05  6:08 profiling bug on alpha-linux Richard Henderson
1996-04-05 10:20 ` Linus Torvalds [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-04-05  6:12 David Mosberger
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox