From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: X-Archive-Original-Message-ID: <199604050958.UAA03593@bajor.apana.org.au> Date: Fri, 5 Apr 1996 13:20:11 +0300 (EET DST) From: Linus Torvalds Subject: Re: profiling bug on alpha-linux In-Reply-To: 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