public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/16331] New: x86-64 inline asm register constraints insufficient WRT ABI
@ 2004-07-02 16:51 thutt at vmware dot com
  2004-07-02 16:57 ` [Bug c/16331] " falk at debian dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: thutt at vmware dot com @ 2004-07-02 16:51 UTC (permalink / raw)
  To: gcc-bugs

An x86-64 version of gcc 3.3.3 does not allow inline asm to specify constraints
for all the available registers.  Particularly, since r8 and r9 are used in the
ABI, it would be very beneficial to ensure that parameters to a function called
from inline assembly reside in the proper registers.

-- 
           Summary: x86-64 inline asm register constraints insufficient WRT
                    ABI
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thutt at vmware dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c/16331] x86-64 inline asm register constraints insufficient WRT ABI
  2004-07-02 16:51 [Bug c/16331] New: x86-64 inline asm register constraints insufficient WRT ABI thutt at vmware dot com
@ 2004-07-02 16:57 ` falk at debian dot org
  2004-07-02 18:49 ` thutt at vmware dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: falk at debian dot org @ 2004-07-02 16:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2004-07-02 16:57 -------
You can declare variables like

register unsigned long r8 asm("r8")

and pass it to the asm, and it will reside in r8. Therefore, I don't
think it makes sense to add further single register constraints.

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


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


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

* [Bug c/16331] x86-64 inline asm register constraints insufficient WRT ABI
  2004-07-02 16:51 [Bug c/16331] New: x86-64 inline asm register constraints insufficient WRT ABI thutt at vmware dot com
  2004-07-02 16:57 ` [Bug c/16331] " falk at debian dot org
@ 2004-07-02 18:49 ` thutt at vmware dot com
  2004-07-02 18:54 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: thutt at vmware dot com @ 2004-07-02 18:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From thutt at vmware dot com  2004-07-02 18:49 -------
This is only guaranteed to work for global variables.  From the gcc info pages:

Variables in Specified Registers
================================

   GNU C allows you to put a few global variables into specified
hardware registers.  You can also specify the register in which an
ordinary register variable should be allocated.

   * Global register variables reserve registers throughout the program.
     This may be useful in programs such as programming language
     interpreters which have a couple of global variables that are
     accessed very often.

   * Local register variables in specific registers do not reserve the
     registers.  The compiler's data flow analysis is capable of
     determining where the specified registers contain live values, and
     where they are available for other uses.  Stores into local
     register variables may be deleted when they appear to be dead
     according to dataflow analysis.  References to local register
     variables may be deleted or moved or simplified.

     These local variables are sometimes convenient for use with the
     extended `asm' feature (*note Extended Asm::.), if you want to
     write one output of the assembler instruction directly into a
     particular register.  (This will work provided the register you
     specify fits the constraints specified for that operand in the
     `asm'.)

I read this to say that the compiler may, or may not, actually use the suggested
register.

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


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


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

* [Bug c/16331] x86-64 inline asm register constraints insufficient WRT ABI
  2004-07-02 16:51 [Bug c/16331] New: x86-64 inline asm register constraints insufficient WRT ABI thutt at vmware dot com
  2004-07-02 16:57 ` [Bug c/16331] " falk at debian dot org
  2004-07-02 18:49 ` thutt at vmware dot com
@ 2004-07-02 18:54 ` pinskia at gcc dot gnu dot org
  2004-07-06 14:55 ` thutt at vmware dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-02 18:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-02 18:54 -------
The documentation is wrong, there is another bug about this already.

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


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


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

* [Bug c/16331] x86-64 inline asm register constraints insufficient WRT ABI
  2004-07-02 16:51 [Bug c/16331] New: x86-64 inline asm register constraints insufficient WRT ABI thutt at vmware dot com
                   ` (2 preceding siblings ...)
  2004-07-02 18:54 ` pinskia at gcc dot gnu dot org
@ 2004-07-06 14:55 ` thutt at vmware dot com
  2004-08-03  7:06 ` [Bug target/16331] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: thutt at vmware dot com @ 2004-07-06 14:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From thutt at vmware dot com  2004-07-06 14:55 -------
Could you reference the documentation defect number?

And, I'm not sure that just the documentation is wrong; consider:

extern int hokus(void);

void test(void)
{
    register int r8 asm("r8") = hokus();
    register int r9 asm("r9") = 6;
    
    __asm__ __volatile__("call pokus"
                         :
                         :
                         "D" (r8),
                         "S" (2),
                         "d" (3),
                         "c" (4),
                         "r" (r8),
                         "r" (r9)
                         );
    r8 = hokus();
    pokus(r8, 2, 3, 4, 5, 6);
}
0000000000000000 <test>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   e8 00 00 00 00          callq  9 <test+0x9>
                        5: R_X86_64_PC32        hokus+0xfffffffffffffffc
   9:   41 b9 06 00 00 00       mov    $0x6,%r9d
   f:   41 b8 05 00 00 00       mov    $0x5,%r8d
  15:   b9 04 00 00 00          mov    $0x4,%ecx
  1a:   ba 03 00 00 00          mov    $0x3,%edx
  1f:   be 02 00 00 00          mov    $0x2,%esi
  24:   44 89 c7                mov    %r8d,%edi
  27:   b8 00 00 00 00          mov    $0x0,%eax
  2c:   e8 00 00 00 00          callq  31 <test+0x31>
                        2d: R_X86_64_PC32       pokus+0xfffffffffffffffc
  31:   be 02 00 00 00          mov    $0x2,%esi
  36:   ba 03 00 00 00          mov    $0x3,%edx
  3b:   b9 04 00 00 00          mov    $0x4,%ecx
  40:   44 89 c7                mov    %r8d,%edi
  43:   e8 00 00 00 00          callq  48 <test+0x48>
                        44: R_X86_64_PC32       pokus+0xfffffffffffffffc
  48:   c9                      leaveq 
  49:   c3                      retq   

The first call of pokus() completely ignores the assigned value of the variable
r8 -- instead the value '6' into it for the call.  The second call assumes the
the register r8 should be used for the call, but by now the wrong value has bee
placed into it.

Perhaps the documentation is wrong, but so is the code generated.  I'm reopening.




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


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


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

* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
  2004-07-02 16:51 [Bug c/16331] New: x86-64 inline asm register constraints insufficient WRT ABI thutt at vmware dot com
                   ` (3 preceding siblings ...)
  2004-07-06 14:55 ` thutt at vmware dot com
@ 2004-08-03  7:06 ` pinskia at gcc dot gnu dot org
  2005-07-02  1:27 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-03  7:06 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
          Component|c                           |target


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


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

* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
  2004-07-02 16:51 [Bug c/16331] New: x86-64 inline asm register constraints insufficient WRT ABI thutt at vmware dot com
                   ` (4 preceding siblings ...)
  2004-08-03  7:06 ` [Bug target/16331] " pinskia at gcc dot gnu dot org
@ 2005-07-02  1:27 ` pinskia at gcc dot gnu dot org
  2005-07-02 10:17 ` falk at debian dot org
  2005-09-04 19:05 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-02  1:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-02 01:27 -------
(In reply to comment #4)
>     __asm__ __volatile__("call pokus"

This is wrong, you don't want to use call in an asm at all.

-- 


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


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

* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
  2004-07-02 16:51 [Bug c/16331] New: x86-64 inline asm register constraints insufficient WRT ABI thutt at vmware dot com
                   ` (5 preceding siblings ...)
  2005-07-02  1:27 ` pinskia at gcc dot gnu dot org
@ 2005-07-02 10:17 ` falk at debian dot org
  2005-09-04 19:05 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: falk at debian dot org @ 2005-07-02 10:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From falk at debian dot org  2005-07-02 10:17 -------
(In reply to comment #4)

> The first call of pokus() completely ignores the assigned value of the variable
> r8 -- instead the value '6' into it for the call.  The second call assumes the
> the register r8 should be used for the call, but by now the wrong value has bee
> placed into it.

I cannot reproduce this with gcc 3.3.6, the generated assembly looks just
fine for me:

0000000000000000 <test>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   e8 00 00 00 00          callq  9 <test+0x9>
                        5: R_X86_64_PC32        hokus+0xfffffffffffffffc
   9:   41 89 c0                mov    %eax,%r8d
   c:   41 b9 06 00 00 00       mov    $0x6,%r9d
  12:   be 02 00 00 00          mov    $0x2,%esi
  17:   ba 03 00 00 00          mov    $0x3,%edx
  1c:   b9 04 00 00 00          mov    $0x4,%ecx
  21:   44 89 c7                mov    %r8d,%edi
  24:   e8 00 00 00 00          callq  29 <test+0x29>
                        25: R_X86_64_PC32       pokus+0xfffffffffffffffc
  29:   e8 00 00 00 00          callq  2e <test+0x2e>
                        2a: R_X86_64_PC32       hokus+0xfffffffffffffffc
  2e:   41 b9 06 00 00 00       mov    $0x6,%r9d
  34:   41 b8 05 00 00 00       mov    $0x5,%r8d
  3a:   b9 04 00 00 00          mov    $0x4,%ecx
  3f:   ba 03 00 00 00          mov    $0x3,%edx
  44:   be 02 00 00 00          mov    $0x2,%esi
  49:   44 89 c7                mov    %r8d,%edi
  4c:   b8 00 00 00 00          mov    $0x0,%eax
  51:   e8 00 00 00 00          callq  56 <test+0x56>
                        52: R_X86_64_PC32       pokus+0xfffffffffffffffc
  56:   c9                      leaveq 

Please retry and give the exact version and flags you used.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
  2004-07-02 16:51 [Bug c/16331] New: x86-64 inline asm register constraints insufficient WRT ABI thutt at vmware dot com
                   ` (6 preceding siblings ...)
  2005-07-02 10:17 ` falk at debian dot org
@ 2005-09-04 19:05 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-04 19:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-04 19:05 -------
No feedbacck in 3 months.

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


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


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

end of thread, other threads:[~2005-09-04 19:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-02 16:51 [Bug c/16331] New: x86-64 inline asm register constraints insufficient WRT ABI thutt at vmware dot com
2004-07-02 16:57 ` [Bug c/16331] " falk at debian dot org
2004-07-02 18:49 ` thutt at vmware dot com
2004-07-02 18:54 ` pinskia at gcc dot gnu dot org
2004-07-06 14:55 ` thutt at vmware dot com
2004-08-03  7:06 ` [Bug target/16331] " pinskia at gcc dot gnu dot org
2005-07-02  1:27 ` pinskia at gcc dot gnu dot org
2005-07-02 10:17 ` falk at debian dot org
2005-09-04 19:05 ` pinskia at gcc dot gnu dot org

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