Subject: Compiler error on sparc -current?
To: None <current-users@netbsd.org>
From: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
List: current-users
Date: 05/23/1999 13:26:17
I suspect a compiler error on sparc -current. Looks like a statement
`*v++ = *u' gets incremented before assignment.

-- 
Juergen Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig (Germany)

Compiling sbin/dump/tape.c (1.18 1999/03/23 14:22:59 bouyer) I get:

_writerec:
	!#PROLOGUE# 0
	save %sp,-104,%sp
	!#PROLOGUE# 1
	sethi %hi(_slp),%o3
	ld [%o3+%lo(_slp)],%o2
	sethi %hi(_trecno),%l0
	ld [%l0+%lo(_trecno)],%o0
	mov 1,%o5
	ld [%o2+32],%o1
	sll %o0,3,%o0
	st %g0,[%o1+%o0]
	ld [%l0+%lo(_trecno)],%o0
	sethi %hi(_nextblock),%o4
	ld [%o2+32],%o1
	sll %o0,3,%o0
	add %o1,%o0,%o1
	st %o5,[%o1+4]
	ld [%o4+%lo(_nextblock)],%o0
	mov %i0,%o1
	add %o0,1024,%o0
	st %o0,[%o4+%lo(_nextblock)]
	call _memcpy,0
	mov 1024,%o2
	cmp %i1,0
	be L35
	sethi %hi(_needswap),%o0
	ld [%o0+%lo(_needswap)],%o2
	sethi %hi(_u_spcl+16),%o1
	sethi %hi(_lastspclrec),%o0
	ld [%o1+%lo(_u_spcl+16)],%o1
	cmp %o2,0
	be L36
	or %o0,%lo(_lastspclrec),%i0
	call _bswap32,0
	mov %o1,%o0
	b L35
	st %o0,[%i0]
L36:
	mov %o1,%o0
	st %o0,[%i0]
L35:
	ld [%l0+%lo(_trecno)],%o0
	sethi %hi(_u_spcl),%i1
	sethi %hi(_needswap),%i0
	or %i1,%lo(_u_spcl),%o1
	ld [%i0+%lo(_needswap)],%o2
	add %o0,1,%o0
	ld [%o1+16],%o1
	cmp %o2,0
	be L40
	st %o0,[%l0+%lo(_trecno)]
	call _bswap32,0
	mov %o1,%o0
	mov %o0,%o1
L40:
	ld [%i0+%lo(_needswap)],%o0
	cmp %o0,0
	be L42
	add %o1,1,%o1
	call _bswap32,0
	mov %o1,%o0
	b L43
	mov %o0,%o4
L42:
	mov %o1,%o4
L43:
	sethi %hi(_ntrec),%o2
	ld [%l0+%lo(_trecno)],%o3
	or %i1,%lo(_u_spcl),%o0
	ld [%o2+%lo(_ntrec)],%o1
	cmp %o3,%o1
	bl L45
	st %o4,[%o0+16]
	call _flushtape,0
	nop
L45:
	ret
	restore

Changing line 189 from

	*(union u_spcl *)(*(nextblock)++) = *(union u_spcl *)dp;

to
	*(union u_spcl *)(*(nextblock)) = *(union u_spcl *)dp;
	nextblock++;

I get:

_writerec:
	!#PROLOGUE# 0
	save %sp,-104,%sp
	!#PROLOGUE# 1
	sethi %hi(_slp),%o3
	ld [%o3+%lo(_slp)],%o2
	sethi %hi(_trecno),%l1
	ld [%l1+%lo(_trecno)],%o0
	mov 1,%o4
	ld [%o2+32],%o1
	sll %o0,3,%o0
	st %g0,[%o1+%o0]
	ld [%l1+%lo(_trecno)],%o0
	sethi %hi(_nextblock),%l0
	ld [%o2+32],%o1
	sll %o0,3,%o0
	add %o1,%o0,%o1
	st %o4,[%o1+4]
	ld [%l0+%lo(_nextblock)],%o0
	mov %i0,%o1
	call _memcpy,0
	mov 1024,%o2
	ld [%l0+%lo(_nextblock)],%o3
	cmp %i1,0
	add %o3,1024,%o3
	be L35
	st %o3,[%l0+%lo(_nextblock)]
	sethi %hi(_needswap),%o0
	ld [%o0+%lo(_needswap)],%o2
	sethi %hi(_u_spcl+16),%o1
	sethi %hi(_lastspclrec),%o0
	ld [%o1+%lo(_u_spcl+16)],%o1
	cmp %o2,0
	be L36
	or %o0,%lo(_lastspclrec),%l0
	call _bswap32,0
	mov %o1,%o0
	b L35
	st %o0,[%l0]
L36:
	mov %o1,%o0
	st %o0,[%l0]
L35:
	ld [%l1+%lo(_trecno)],%o0
	sethi %hi(_u_spcl),%i0
	sethi %hi(_needswap),%l0
	or %i0,%lo(_u_spcl),%o1
	ld [%l0+%lo(_needswap)],%o2
	add %o0,1,%o0
	ld [%o1+16],%o1
	cmp %o2,0
	be L40
	st %o0,[%l1+%lo(_trecno)]
	call _bswap32,0
	mov %o1,%o0
	mov %o0,%o1
L40:
	ld [%l0+%lo(_needswap)],%o0
	cmp %o0,0
	be L42
	add %o1,1,%o1
	call _bswap32,0
	mov %o1,%o0
	b L43
	mov %o0,%o4
L42:
	mov %o1,%o4
L43:
	sethi %hi(_ntrec),%o2
	ld [%l1+%lo(_trecno)],%o3
	or %i0,%lo(_u_spcl),%o0
	ld [%o2+%lo(_ntrec)],%o1
	cmp %o3,%o1
	bl L45
	st %o4,[%o0+16]
	call _flushtape,0
	nop
L45:
	ret
	restore