Subject: gcc 2.95.3 problems.
To: None <port-pc532@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: port-pc532
Date: 09/26/2001 15:02:42
Hi folks,

I've been playing around with "new toolchain" (under gnu/dist/toolchain)
and have struck a couple of files where I get a "Could not find a
spill register" error from gcc 2.95.3.  When I compile the following
snipped-down lfs_inode.c, I get:

pc532:pc532/compile/GENERIC 45> /usr/local/gnu/bin/cc -O2 -msb -Werror -Wall \
    -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-format \
    -Wno-uninitialized -Wno-main -I. -I/sys/arch -I/sys -nostdinc -DLKM \
    -DCPU30MHZ -DMAXUSERS=8 -D_KERNEL -D_KERNEL_OPT -c foo_inode.c
foo_inode.c: In function `lfs_update':
foo_inode.c:149: Could not find a spill register
(insn 35 34 559 (set (reg/s:SI 45)
        (and:SI (mem/s:SI (plus:SI (reg/v:SI 32)
                    (const_int 16 [0x10])) 0)
            (const_int 3 [0x3]))) 104 {andsi3} (nil)
    (nil))

Using -O1 compiles successfully in this case, but doesn't on another
file (sys/nfs/nfs_vnops.c), where -O2 works and -O1 doesn't.  The
failure there looks quite different:

foo_vnops.c:96: Could not find a spill register
(insn 193 192 195 (set (mem:DI (plus:SI (plus:SI (reg/v:SI 7 r7)
                    (reg:SI 91))
                (const_int -8 [0xfffffff8])) 0)
        (mem/s:DI (plus:SI (reg/v:SI 31)
                (const_int 8 [0x8])) 0)) 13 {movdi} (insn_list 192 (nil))
    (expr_list:REG_DEAD (reg:SI 91)
        (nil)))


It appears that almost all of our local changes to egcs 2.91.66 have
made it into gcc 2.95.3.  The only differences I can see are a couple of
lines like:

	-        (unspec:DI [(match_operand:DI 1 "reg_or_mem_operand" "0")
	+        (unspec:SI [(match_operand:DI 1 "reg_or_mem_operand" "0")

in ns32k.md (that one for "udivmoddisi4_internal", similar ones for
"udivmoddihi4_internal" and "udivmoddiqi4_internal").  The 2.95.3
genrecog doesn't like it if I change the "DI" back to an "SI" - I get a
"mode mismatch in SET" error.

I've posted a similar problem (the nfs_vnops.c file) to gcc-bugs but
haven't heard anything back from them yet.  Note that I know ~nothing
about gcc internals.  Anyone have any ideas on where to start to track
this down (hi Matthias and Ian!!)?

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD CDs, Support and Service:    http://www.wasabisystems.com/




/*	$NetBSD: lfs_inode.c,v 1.52 2001/07/13 20:30:24 perseant Exp $	*/

/*-
 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Konrad E. Schroder <perseant@hhhh.org>.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by the NetBSD
 *      Foundation, Inc. and its contributors.
 * 4. Neither the name of The NetBSD Foundation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
/*
 * Copyright (c) 1986, 1989, 1991, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)lfs_inode.c	8.9 (Berkeley) 5/8/95
 */

#include <sys/param.h>
#include <sys/mount.h>
#include <sys/kernel.h>

#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
#include <ufs/ufs/ufsmount.h>

#include <ufs/lfs/lfs.h>

int
lfs_update(void *v)
{
	struct vop_update_args /* {
				  struct vnode *a_vp;
				  struct timespec *a_access;
				  struct timespec *a_modify;
				  int a_flags;
				  } */ *ap = v;
	struct inode *ip;
	struct vnode *vp = ap->a_vp;
	int oflag;
	struct timespec ts;
	struct lfs *fs = VFSTOUFS(vp->v_mount)->um_lfs;
	
	if (vp->v_mount->mnt_flag & MNT_RDONLY)
		return (0);
	ip = VTOI(vp);

	/*
	 * If we are called from vinvalbuf, and the file's blocks have
	 * already been scheduled for writing, but the writes have not
	 * yet completed, lfs_vflush will not be called, and vinvalbuf
	 * will cause a panic.  So, we must wait until any pending write
	 * for our inode completes, if we are called with UPDATE_WAIT set.
	 */
	while((ap->a_flags & (UPDATE_WAIT|UPDATE_DIROP)) == UPDATE_WAIT &&
	    WRITEINPROG(vp)) {
#ifdef DEBUG_LFS
		printf("lfs_update: sleeping on inode %d (in-progress)\n",
		       ip->i_number);
#endif
		tsleep(vp, (PRIBIO+1), "lfs_update", 0);
	}
	oflag = ip->i_flag;
	TIMEVAL_TO_TIMESPEC(&time, &ts);
	LFS_ITIMES(ip,
		   ap->a_access ? ap->a_access : &ts,
		   ap->a_modify ? ap->a_modify : &ts, &ts);
	if ((ip->i_flag & (IN_MODIFIED | IN_ACCESSED | IN_CLEANING)) == 0) {
		return (0);
	}
	
	/* If sync, push back the vnode and any dirty blocks it may have. */
	if((ap->a_flags & (UPDATE_WAIT|UPDATE_DIROP))==UPDATE_WAIT) {
		/* Avoid flushing VDIROP. */
		++fs->lfs_diropwait;
		while(vp->v_flag & VDIROP) {
#ifdef DEBUG_LFS
			printf("lfs_update: sleeping on inode %d (dirops)\n",
			       ip->i_number);
			printf("lfs_update: vflags 0x%lx, iflags 0x%x\n",
				vp->v_flag, ip->i_flag);
#endif
			if(fs->lfs_dirops == 0)
				lfs_flush_fs(fs, SEGM_SYNC);
			else
				tsleep(&fs->lfs_writer, PRIBIO+1, "lfs_fsync",
				       0);
			/* XXX KS - by falling out here, are we writing the vn
			twice? */
		}
		--fs->lfs_diropwait;
		return lfs_vflush(vp);
        }
	return 0;
}