public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/23242] New: Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0
@ 2005-08-05  0:32 ianw at gelato dot unsw dot edu dot au
  2005-08-05  1:14 ` Andrew Pinski
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: ianw at gelato dot unsw dot edu dot au @ 2005-08-05  0:32 UTC (permalink / raw)
  To: gcc-bugs

Hi,

See the following snippet 

ianw@morrison:~$ gcc-snap -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,obj-c++,ada,treelang
--prefix=/usr/lib/gcc-snapshot --enable-shared --with-system-zlib --disable-nls
--enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--with-java-home=/usr/lib/gcc-snapshot/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
--enable-mpfr --disable-werror i486-linux-gnu
Thread model: posix
gcc version 4.1.0 20050719 (experimental)

ianw@morrison:~$ cat test.c
int main()
{
  volatile unsigned char old, new, *newp;

  newp = &new;

  /* this one works OK */
  __asm__ __volatile__("xchgb %0, %1"
  : "=r"(old), "=m"(new)
  : "0"(0xff), "m"(new) : "memory");

#ifdef DEREF
  /* this one doesn't */
    __asm__ __volatile__("xchgb %0, %1"
  : "=r"(old), "=m"(*newp)
  : "0"(0xff), "m"(*newp) : "memory");
#endif

  return 0;
}

ianw@morrison:~$ gcc-snap -Wall -o test test.c

ianw@morrison:~$ gcc-snap -DDEREF -Wall -o test test.c
/tmp/cc8YTeKG.s: Assembler messages:
/tmp/cc8YTeKG.s:30: Error: bad register name `%sil'

ianw@morrison:~$ gcc-snap -O2 -DDEREF -Wall -o test test.c

I believe this to be the cause of Debian bug #321291
(http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=321291) filed against the
libatomic_ops package (original author CC'd)

-- 
           Summary: Invalid %sil register chosen when dereferenced pointer
                    used in inline asm with -O0
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: inline-asm
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ianw at gelato dot unsw dot edu dot au
                CC: Hans dot Boehm at hp dot com,gcc-bugs at gcc dot gnu dot
                    org
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23242


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Bug inline-asm/23242] New: Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0
  2005-08-05  0:32 [Bug inline-asm/23242] New: Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0 ianw at gelato dot unsw dot edu dot au
@ 2005-08-05  1:14 ` Andrew Pinski
  2005-08-05  1:35 ` [Bug inline-asm/23242] " pinskia at physics dot uc dot edu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Andrew Pinski @ 2005-08-05  1:14 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: ianw, gcc-bugs@gcc.gnu.org BUGS


On Aug 4, 2005, at 8:32 PM, ianw at gelato dot unsw dot edu dot au 
wrote:

>   /* this one doesn't */
>     __asm__ __volatile__("xchgb %0, %1"
>   : "=r"(old), "=m"(*newp)
>   : "0"(0xff), "m"(*newp) : "memory");


This is not a bug.

r is selecting %sil which is a valid register for x86_64.

"r" is assuming that it is a full size register.

Use "Q" instead.

-- Pinski

PS The reason why I am CC you instead of writing this into bugzilla is 
because
bugzilla seems dead.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug inline-asm/23242] Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0
  2005-08-05  0:32 [Bug inline-asm/23242] New: Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0 ianw at gelato dot unsw dot edu dot au
  2005-08-05  1:14 ` Andrew Pinski
@ 2005-08-05  1:35 ` pinskia at physics dot uc dot edu
  2005-08-05  2:17 ` ianw at gelato dot unsw dot edu dot au
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: pinskia at physics dot uc dot edu @ 2005-08-05  1:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at physics dot uc dot edu  2005-08-05 01:35 -------
Subject: Re:  New: Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0


On Aug 4, 2005, at 8:32 PM, ianw at gelato dot unsw dot edu dot au 
wrote:

>   /* this one doesn't */
>     __asm__ __volatile__("xchgb %0, %1"
>   : "=r"(old), "=m"(*newp)
>   : "0"(0xff), "m"(*newp) : "memory");


This is not a bug.

r is selecting %sil which is a valid register for x86_64.

"r" is assuming that it is a full size register.

Use "Q" instead.

-- Pinski

PS The reason why I am CC you instead of writing this into bugzilla is 
because
bugzilla seems dead.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23242


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug inline-asm/23242] Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0
  2005-08-05  0:32 [Bug inline-asm/23242] New: Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0 ianw at gelato dot unsw dot edu dot au
  2005-08-05  1:14 ` Andrew Pinski
  2005-08-05  1:35 ` [Bug inline-asm/23242] " pinskia at physics dot uc dot edu
@ 2005-08-05  2:17 ` ianw at gelato dot unsw dot edu dot au
  2005-08-05  3:14 ` rth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: ianw at gelato dot unsw dot edu dot au @ 2005-08-05  2:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ianw at gelato dot unsw dot edu dot au  2005-08-05 02:17 -------
Subject: Re:  Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0

On Fri, Aug 05, 2005 at 01:35:51AM -0000, pinskia at physics dot uc dot edu wrote:
> On Aug 4, 2005, at 8:32 PM, ianw at gelato dot unsw dot edu dot au 
> wrote:
> 
> >   /* this one doesn't */
> >     __asm__ __volatile__("xchgb %0, %1"
> >   : "=r"(old), "=m"(*newp)
> >   : "0"(0xff), "m"(*newp) : "memory");
>
> This is not a bug.
> 
> r is selecting %sil which is a valid register for x86_64.

Sorry if I'm missing something, I don't work with x86-64 much, but
isn't it a wrong to consider that register when I'm building for i486?

-i


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23242


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug inline-asm/23242] Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0
  2005-08-05  0:32 [Bug inline-asm/23242] New: Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0 ianw at gelato dot unsw dot edu dot au
                   ` (2 preceding siblings ...)
  2005-08-05  2:17 ` ianw at gelato dot unsw dot edu dot au
@ 2005-08-05  3:14 ` rth at gcc dot gnu dot org
  2005-08-05  3:32 ` pinskia at gcc dot gnu dot org
  2005-08-12 18:51 ` Hans dot Boehm at hp dot com
  5 siblings, 0 replies; 10+ messages in thread
From: rth at gcc dot gnu dot org @ 2005-08-05  3:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rth at gcc dot gnu dot org  2005-08-05 03:14 -------
No, because you still need to use "Q" to get a register that may be used
with a low-part.  Even on i486.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23242


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug inline-asm/23242] Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0
  2005-08-05  0:32 [Bug inline-asm/23242] New: Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0 ianw at gelato dot unsw dot edu dot au
                   ` (3 preceding siblings ...)
  2005-08-05  3:14 ` rth at gcc dot gnu dot org
@ 2005-08-05  3:32 ` pinskia at gcc dot gnu dot org
  2005-08-12 18:51 ` Hans dot Boehm at hp dot com
  5 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-05  3:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-05 03:32 -------
*** Bug 23243 has been marked as a duplicate of this bug. ***

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23242


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug inline-asm/23242] Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0
  2005-08-05  0:32 [Bug inline-asm/23242] New: Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0 ianw at gelato dot unsw dot edu dot au
                   ` (4 preceding siblings ...)
  2005-08-05  3:32 ` pinskia at gcc dot gnu dot org
@ 2005-08-12 18:51 ` Hans dot Boehm at hp dot com
  5 siblings, 0 replies; 10+ messages in thread
From: Hans dot Boehm at hp dot com @ 2005-08-12 18:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From Hans dot Boehm at hp dot com  2005-08-12 18:51 -------
Could we reopen this as a documentation bug?  I'm still confused, and the 
amount of discussion suggests I'm not alone.  Currently "r" is documented as 
meaning "general register", with no comments about operand size.  I naively 
interpreted this to mean that the size is infered from the operand, which it 
seems to be in other cases.

"Q" means "a, b, c, or d register for 8-bit instructions that do use upper 
halves".  I don't understand why this applies to xchg.  Did you mean "q"?

Why are 8 bit registers treated separately, but not 16-bit registers?  Why does 
this only appear to be true for X86?  This is unintuitive since it seems that 
the compiler has enough information to get this right; it just choses not to.

Hans



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23242


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug inline-asm/23242] Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0
       [not found] <bug-23242-5429@http.gcc.gnu.org/bugzilla/>
  2008-06-12 21:22 ` pinskia at gcc dot gnu dot org
  2008-08-04  7:46 ` schwab at suse dot de
@ 2008-10-21 21:45 ` schwab at suse dot de
  2 siblings, 0 replies; 10+ messages in thread
From: schwab at suse dot de @ 2008-10-21 21:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from schwab at suse dot de  2008-10-21 21:42 -------
*** Bug 37887 has been marked as a duplicate of this bug. ***


-- 

schwab at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |therealfroggey at gmail dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23242


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug inline-asm/23242] Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0
       [not found] <bug-23242-5429@http.gcc.gnu.org/bugzilla/>
  2008-06-12 21:22 ` pinskia at gcc dot gnu dot org
@ 2008-08-04  7:46 ` schwab at suse dot de
  2008-10-21 21:45 ` schwab at suse dot de
  2 siblings, 0 replies; 10+ messages in thread
From: schwab at suse dot de @ 2008-08-04  7:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from schwab at suse dot de  2008-08-04 07:44 -------
*** Bug 37018 has been marked as a duplicate of this bug. ***


-- 

schwab at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc at karrels dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23242


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug inline-asm/23242] Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0
       [not found] <bug-23242-5429@http.gcc.gnu.org/bugzilla/>
@ 2008-06-12 21:22 ` pinskia at gcc dot gnu dot org
  2008-08-04  7:46 ` schwab at suse dot de
  2008-10-21 21:45 ` schwab at suse dot de
  2 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-06-12 21:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2008-06-12 21:22 -------
*** Bug 36514 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |codemasterhs at yahoo dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23242


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-10-21 21:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-05  0:32 [Bug inline-asm/23242] New: Invalid %sil register chosen when dereferenced pointer used in inline asm with -O0 ianw at gelato dot unsw dot edu dot au
2005-08-05  1:14 ` Andrew Pinski
2005-08-05  1:35 ` [Bug inline-asm/23242] " pinskia at physics dot uc dot edu
2005-08-05  2:17 ` ianw at gelato dot unsw dot edu dot au
2005-08-05  3:14 ` rth at gcc dot gnu dot org
2005-08-05  3:32 ` pinskia at gcc dot gnu dot org
2005-08-12 18:51 ` Hans dot Boehm at hp dot com
     [not found] <bug-23242-5429@http.gcc.gnu.org/bugzilla/>
2008-06-12 21:22 ` pinskia at gcc dot gnu dot org
2008-08-04  7:46 ` schwab at suse dot de
2008-10-21 21:45 ` schwab at suse dot de

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).