This is the mail archive of the gcc@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]

question regarding asm()



in the info file, this asm is given as an example of specifying registers to
be clobbered:

>     asm ("movl %0,r9;movl %1,r10;call _foo"
>          : /* no outputs */
>          : "g" (from), "g" (to)
>          : "r9", "r10");

Now I have a question.. is gcc supposed to avoid allocating r9 to %1 ??

in fact, gcc tries to avoid allocating "clobbered" registers for input operands,
but if there are no registers left gcc will nevertheless use them.

So, under register pressure, gcc might use r9 for input operand %1.

There was a problem in the linux kernel because egcs allocated
a register for an input operand that was also in the clobberlist
(and actually was overwritten before the input operand was used).

so whats wrong?

a) the example in the documentation
b) gcc, because it allocates wrong registers for the input operands
c) me, because I'm totally confused tonight..

;?

      -----==-
      ----==-- _
      ---==---(_)__  __ ____  __       Marc Lehmann
      --==---/ / _ \/ // /\ \/ /       pcg@goof.com
      -=====/_/_//_/\_,_/ /_/\_\
    The choice of a GNU generation


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