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

Inlining bug on MIPS - both 2.95.3 and 3.0 branches


I've put together a testcase for a bug exposed by (accidentally) trying to
build a mipsel-linux kernel with VGA console enabled.

The problem seems to be that we lift a constant term out of a loop into a
spare register.  Of course, __builtin_constant_p is still true for it, so in
the original case we chose to use an inline function which required that
argument to be constant.  We inline the function using the scratch register
instead of the constant, and we lose.

The inline function seems to me to be doing something dodgy - it specifies
the operand with the constraint "ir", implying that a register would be
acceptable.  We're lying to the compiler, so it's not that startling that it
bites us.  On the other hand, there's no need to waste a register on this,
so I'm not sure why the constant gets stored in a temporary.

Is the invalid result a compiler bug?  I'd say that there is at least a
small optimization bug here, but the "ir" constraint might mean that the
compiler's doing everything as best it can.  There doesn't seem to be a way
to use an inline function safely and specify a constant constraint on one
argument to the function - does this need to be a macro?

-- 
Daniel Jacobowitz                           Debian GNU/Linux Developer
Monta Vista Software                              Debian Security Team
                         "I am croutons!"
/* Compile with -O1, target mipsel-hardhat-linux */

extern unsigned long mips_io_port_base;

extern inline void __outbc_p (unsigned int value, unsigned int port) {
	__asm__ __volatile__ ("#BAR\n" "s" "b" "\t%0,%1(%2)" 
		: : "r" (( value ) ), "ir" (port), "r" (mips_io_port_base));  ;
} 

static void vga_pal_blank(void)
{
	int i;

	for (i=0; i<16; i++) {
		__outbc_p(0, 0x3c8);
	}
}

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