public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "law at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/60925] [4.9/5 Regression] hppa: can't find a register in class 'R1_REGS' while reloading 'asm'
Date: Wed, 21 Jan 2015 06:03:00 -0000	[thread overview]
Message-ID: <bug-60925-4-zNs3wsUPLU@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60925-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60925

Jeffrey A. Law <law at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-01-21
                 CC|                            |law at redhat dot com
     Ever confirmed|0                           |1

--- Comment #11 from Jeffrey A. Law <law at redhat dot com> ---
Carlos,

In general, you want to avoid using a register that is in a singleton class in
an asm explicitly in an asm.  While it works a hell of a lot better now than it
has in the past, there's still cases where you can put the compiler into a
situation where it can't figure out what to do.  Typically that happens when
you explicit clobber every register that GCC could potentially use to resolve a
reload.  And that's much more likely if you happen to clobber a register that
is a singleton in a class.

For the PA, %r1 is not fixed, but it is in a singleton class because it is the
only register that can be set by addil.  And ldil;add is not equivalent to
addil because of some *insanely* gross stuff done by the HP linker where it
will change addil <whatever>,r27 into addil <whatever>,r0, depending on what
subsection <whatever> is in.  THe linker isn't smart enough to do the same
transformation on an ldil/add sequence which should otherwise be equivalent.

Thus GCC has to put %r1 into its own class as a singleton.

%r1 will often be needed as a reload scratch register as well as an
intermediate for secondary reloads, most of the time to handle references to
data in static storage, but also to handle constants that may be shoved into
static storage.  Registers with this kind of need are handled specially by
reload and their "lifetime" essentially is the entire insn that triggered the
reload.  In this particular case, the lifetime is essentially the entire asm
statement.

So in this case, you have &lock being passed to lll_mutex_lock.  That's a
reference to static storage and thus *may* %r1 as a reload scratch register. 
That use as a reload scratch is seen as interfering with the %r1 in the clobber
list.

>From looking at the ASM you're trying to clobber all the call-clobbered
registers, presumably due to the hidden "call" in the asm (the
branch-and-link-external).  Note that you should probably be including %r2 in
that list.

My asm and PA-fu are a bit rusty, so it's not immediately clear how to do what
you want.  You could try changing r1 so that you're clobbering a register that
has to go into class "a".  At least in that case you might be able to use a
simple clobber ("=a") rather than an earlyclobber ("=&a") for the constraint. 
That gives GCC a bit more leeway in building the conflicts, but may still not
be enough.

Or get lock out of static memory or otherwise hide the fact that its in static
memory so that GCC won't try to create a direct reference to it in the asm.  I
think that's what David's workaround was in effect suggesting.  If by a level
of indirection you can prevent GCC from discovering that futex is in static
memory, then this problem should go away (its address will just be sitting in a
register and can be used directly). 

These are just potential workarounds for a reload issue that is highly unlikely
to ever get fixed.  If your asm clobber the entire set of call-clobbered
registers, you really don't leave reload enough leeway to handle reloads. 
Similarly if it clobbers everything in a particular class, then you run into
the same problem if there's an operand that requires a reload register of that
class.

This is probably a WONTFIX.


  parent reply	other threads:[~2015-01-21  6:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-22 19:36 [Bug target/60925] New: [4.9 " aaro.koskinen at iki dot fi
2014-04-22 19:38 ` [Bug target/60925] " aaro.koskinen at iki dot fi
2014-04-22 19:39 ` aaro.koskinen at iki dot fi
2014-04-23  8:41 ` [Bug target/60925] [4.9/4.10 " rguenth at gcc dot gnu.org
2014-05-22 20:25 ` aaro.koskinen at iki dot fi
2014-05-23 18:01 ` aaro.koskinen at iki dot fi
2014-05-25 11:12 ` aaro.koskinen at iki dot fi
2014-05-25 18:31 ` dave.anglin at bell dot net
2014-05-26 11:34 ` carlos at systemhalted dot org
2014-07-16 13:28 ` jakub at gcc dot gnu.org
2014-10-30 10:40 ` [Bug target/60925] [4.9/5 " jakub at gcc dot gnu.org
2014-12-01 11:59 ` rguenth at gcc dot gnu.org
2015-01-21  6:03 ` law at redhat dot com [this message]
2015-01-29 14:38 ` law at redhat dot com
2015-05-25  4:59 ` carlos at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60925-4-zNs3wsUPLU@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).