This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: possible bug on PPC/ GNU/LINUX


[Disclaimer: I Am Not An ABI Lawyer]


On Tue, Jun 15, 1999 at 05:10:24PM +0200, Daniel Diaz wrote:
> Hello,
> 
> I'm the author of GNU Prolog and I discovered a bug (I think) while porting 
> my system under PowerPC / GNU/Linux. I need to use a register to store a 
> global variable. Since I cannot find any documentation about which registers 
> I can use I have tried several ones. In particular I use r15 to store the 
> content of a global variable. Since the compiler does not emit an error when 
> using this register I suppose it is OK (r15 is a nonvolatile register wrt to 
> the ABI). When compiling without any optimization flag the function preamble 
> saves (and then restores) the content of r15. Thus I cannot use it. Under 
> other architectures the compilers wanr about a global-clobbered register.
> 
> architecture (uname -a):
> Linux macopine 2.2.6-15apmac #1 Mon May 31 03:54:09 EDT 1999 ppc unknown
> 
> Here is the program bug.c
> 
> register long *reg_bank asm("15");
> 
> void foo(void)
> {
>  reg_bank=0;
> }

> Is it a bug ? Where can I find information on which registers I can use (and 
> this for several machines, e.g. ix86, alpha, PPC).


Are you so sure that r15 is nonvolatile wrt the ABI?  In
gcc/config/rs6000.c I see this:

  /* Find lowest numbered live register.  */
  for (first_reg = 13; first_reg <= 31; first_reg++)
    if (regs_ever_live[first_reg])
      break;

This implies to me that everything from r13 on up should be
saved/restored.  I noticed you specified -ffixed-r8 on the command
line - what about using asm("8") ?  Without -ffixed-r8 this does
produce a warning, but with it there should be no problem.

What I find somewhat more interesting is that r15 is saved/restored
even if -ffixed-r15 is specified.  Something must be wrong with that -
either those registers should not be allowed to be fixed, or they
should be correctly fixed.  The prologue most definitely generates code
which refers to them.

Also from rs6000.c, in output_prolog:

      for ( ; regno < 32; regno++, loc += reg_size)
        asm_fprintf (file, store_reg, reg_names[regno], loc, reg_names[sp_reg]);

The comparable section of config/alpha/alpha.c, in alpha_sa_mask, does
this test to decide whether to actually save the register:

      for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
        if (! fixed_regs[i] && ! call_used_regs[i]
            && regs_ever_live[i] && i != REG_RA)

Should we be doing this also?  It would seem so.

Dan

/--------------------------------\  /--------------------------------\
|       Daniel Jacobowitz        |__|        SCS Class of 2002       |
|   Debian GNU/Linux Developer    __    Carnegie Mellon University   |
|         dan@debian.org         |  |       dmj+@andrew.cmu.edu      |
\--------------------------------/  \--------------------------------/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]