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]
Other format: [Raw text]

[Bug c/16331] x86-64 inline asm register constraints insufficient WRT ABI


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


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