Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Richard Henderson <richard@atheist.tamu.edu>
Subject: profiling bug on alpha-linux
Date: Fri, 5 Apr 1996 00:08:54 -0600 (CST)	[thread overview]
Message-ID: <m0u54hb-00026UC@atheist.tamu.edu> (raw)

Leaf functions on alpha-linux improperly overwrite the
return address register ($26) when profiling is on.

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.

r~

-----
Fri Apr  5 01:03:02 1996  Richard Henderson  <rth@tamu.edu>

        * alpha.c (alpha_sa_size): Do not elide saving $ra when
        profiling is on.  The call to _mcount is going to kill it.
        (output_prolog): Continued.
        (output_epilog): Continued.

Index: alpha.c
===================================================================
RCS file: /home/richard/Repository/cygnus/gcc/config/alpha/alpha.c,v
retrieving revision 1.1.1.1.2.1
retrieving revision 1.1.1.1.2.2
diff -u -r1.1.1.1.2.1 -r1.1.1.1.2.2
--- alpha.c     1996/03/26 02:39:40     1.1.1.1.2.1
+++ alpha.c     1996/04/05 05:49:45     1.1.1.1.2.2
@@ -1335,7 +1335,7 @@ alpha_sa_size ()
 
   /* If some registers were saved but not reg 26, reg 26 must also
      be saved, so leave space for it.  */
-  if (size != 0 && ! regs_ever_live[26])
+  if ((size != 0 || profile_flag) && ! regs_ever_live[26])
     size++;
 
   /* Our size must be even (multiple of 16 bytes).  */
@@ -1599,7 +1599,7 @@ output_prolog (file, size)
           frame_size, current_function_pretend_args_size);
     
   /* Save register 26 if any other register needs to be saved.  */
-  if (sa_size != 0)
+  if (sa_size != 0 || profile_flag)
     {
       reg_mask |= 1 << 26;
       fprintf (file, "\tstq $26,%d($30)\n", reg_offset);
@@ -1684,7 +1684,7 @@ output_epilog (file, size)
 
       /* Restore all the registers, starting with the return address
         register.  */
-      if (sa_size != 0)
+      if (sa_size != 0 || profile_flag)
        {
          fprintf (file, "\tldq $26,%d($30)\n", reg_offset);
          reg_offset += 8;

             reply	other threads:[~1996-04-05  6:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-05  6:08 Richard Henderson [this message]
1996-04-05 10:20 ` profiling bug on alpha-linux Linus Torvalds
  -- 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