On Tue, 9 Aug 2011, Richard Earnshaw wrote:
> Better still would be to change the specification and implementation of
> local register variables to only guarantee them at the beginning of ASM
> statements.

Only for those asm statements taking the same asm-register
variables as arguments.

>  At other times they are simply the same as other local
> variables.  Now we have a problem that the register allocator knows how
> to solve.
>
> In other words, if the user writes
>
> bar (int y)
> {
>   register int x asm ("r0") = y;
>
>   foo()
>
>   asm volatile ("mov r1, r0");
>
> }
>
> The compiler will generate
> (set (reg:SI 999 <x>) (reg:SI <y>))
> (call "foo")
> (set (reg:SI 0 "r0") (reg:SI 999 <x>))
> (asm "mov r1, r0")
> (set (reg:SI 999 <x>) (reg:SI 0 "r0"))

It should rather eliminate the variable x and its assignment as
it isn't used in a way properly conveyed to gcc: the occurrence
of the string "r0" in the asm should not be considered.

I like Ulrich Weigand's proposal better, not the least because
it's how it's already documented to work.

brgds, H-P

Reply via email to