[Top] [All Lists]

[patch] <asm/io.h> troubles - [ Inlining bug on MIPS

Subject: [patch] <asm/io.h> troubles - [ Inlining bug on MIPS - both 2.95.3 and 3.0 branches]
From: Daniel Jacobowitz <>
Date: Wed, 14 Mar 2001 08:57:37 -0500
User-agent: Mutt/1.3.16i
I submitted the following GCC bug report a couple of days ago, and had
a discussion with Geoff Keating about asm constraints.  It looks as if
the problem I was seeing is a (very) longstanding bug in GCC's reload
pass, and is very unlikely to get fixed.

How does this workaround patch look?  I changed the constant-using
functions from io.h into macros.  I'm not thrilled by it, but it does
seem to be correct.  I have a suspicion we could change the confusing
"i#*X" constraints back to simply "i" - they were part of my effort to
make the inline functions work, before I was defeated by reload.  It
should be correct either way, though. 

----- Forwarded message from Daniel Jacobowitz <> -----

Date: Fri, 9 Mar 2001 18:10:02 -0500
From: Daniel Jacobowitz <>
Subject: 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?


----- End forwarded message -----

Daniel Jacobowitz                           Debian GNU/Linux Developer
Monta Vista Software                              Debian Security Team
                         "I am croutons!"

Attachment: hhl-kernel-2.4.2-1.64.patch
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>
  • [patch] <asm/io.h> troubles - [ Inlining bug on MIPS - both 2.95.3 and 3.0 branches], Daniel Jacobowitz <=