go.arm64 icon indicating copy to clipboard operation
go.arm64 copied to clipboard

liblink: MOV ZR, Rn considered harmful

Open davecheney opened this issue 10 years ago • 1 comments

The use of MOV ZR, R0 caused runtime.usleep to barf. Spelling out the zeroing of the those registers fixed it, 26722042.

I guess we should avoid using ZR anywhere for the moment.

davecheney avatar Feb 13 '15 04:02 davecheney

The following code

// pselect6(0, 0, 0, 0, &ts, 0)
MOV $0, R0
MOV R0, R1
MOV R0, R2
MOV R0, R3
ADD $8, SP, R4
MOV R0, R5

assembles to

   0x0000000000121d94 <+36>:    mov     x0, #0x0                        // #0
   0x0000000000121d98 <+40>:    mov     x1, x0
   0x0000000000121d9c <+44>:    mov     x2, x0
   0x0000000000121da0 <+48>:    mov     x3, x0
   0x0000000000121da4 <+52>:    add     x4, sp, #0x8
   0x0000000000121da8 <+56>:    mov     x5, x0

however, using ZR

// pselect6(0, 0, 0, 0, &ts, 0)
MOV ZR, R0
MOV ZR, R1
MOV ZR, R2
MOV ZR, R3
ADD $8, SP, R4
MOV ZR, R5

assembles to

   0x0000000000121d94 <+36>:    mov     x0, sp
   0x0000000000121d98 <+40>:    mov     x1, sp
   0x0000000000121d9c <+44>:    mov     x2, sp
   0x0000000000121da0 <+48>:    mov     x3, sp
   0x0000000000121da4 <+52>:    add     x4, sp, #0x8
   0x0000000000121da8 <+56>:    mov     x5, sp

sad trombone sad-trombone-o

davecheney avatar Feb 13 '15 05:02 davecheney