[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331 Gerald Pfeifer gerald at pfeifer dot com changed: What|Removed |Added Status|REOPENED|RESOLVED CC||gccbugzilla@limegreensocks. ||com, gerald at pfeifer dot com Resolution|--- |FIXED --- Comment #17 from Gerald Pfeifer gerald at pfeifer dot com --- David Wohlferd, who has been rewriting the asm documentation, among others, indicated that this is actually now described in the Local Reg Vars section, so I am closing this bug. Please advise if you disagree and there is something left to document or fix in the compiler proper.
[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331 Christian Häggström gcc at kalvdans dot no-ip.org changed: What|Removed |Added CC||gcc at kalvdans dot ||no-ip.org --- Comment #16 from Christian Häggström gcc at kalvdans dot no-ip.org 2012-06-21 17:11:11 UTC --- Can this bug be closed as it works with gcc 3.3.6 as expressed in comment #6? Otherwise, please state again clearly what is still broken since it is hard to follow the discussion.
[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
--- Comment #13 from thutt at vmware dot com 2009-02-10 14:34 --- (In reply to comment #12) (In reply to comment #11) Uros, how hard to support this in x86 backend? snip OTOH, constraints should be used to support correct register allocation for machine instructions, not to emulate ABI in order to support calls from inside asm statements. Please indulge me for a moment. What exactly is a call? Are you considering the only method of transferring control to be the standard 'near call' 'near ret' instructions on the x86? What about the following modes of transferring control to another address? int iret ret sysenter sysexit syscall sysret ud2 int3 jmp Then, what of these? lcall lret ljmp Every one of these is a method to transfer control to another address with a programmer-defined set of input register. More importantly, none of these are directly supported by gcc to invoke functions without resorting to inline assembly. If you're working on an operating system, a virtualization engine or some other embedded device you might need to transfer control using one of these methods. As a really simple example, consider a handler for a timer interrupt. Let's say that the prologue for the interrupt (written in assembly) handler storing all the machine registers into a data structure accessible from C. Then, the prologue transfers to the handler which is conveniently written in C. Wouldn't it be really nice if one could restore all the saved registers in C code using only inline assembly instruction? __asm__(iret : : force restoring registers saved in data structure); I'm confident you can see the advantage of doing this in C and letting the compiler deal with the bookkeeping details, rather than resorting to another assembly language function which does such a simple feat. I think I pretty clearly demonstrate here that calling other functions using the x86 architecture isn't as simple as assuming it's going only to be done with 'call', 'jmp' and 'ret', and many of those methods are not possible with straight C, even with gcc's helpful extensions. Should gcc prevent the developer from using the ABI just because the inline assembly wasn't meant to 'support calls from inside assembly statements'? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
--- Comment #14 from ubizjak at gmail dot com 2009-02-10 15:20 --- OTOH, constraints should be used to support correct register allocation for machine instructions, not to emulate ABI in order to support calls from inside asm statements. Please indulge me for a moment. What exactly is a call? Are you considering the only method of transferring control to be the standard 'near call' 'near ret' instructions on the x86? I was referring at the procedure call, where you need to setup outgoing arguments on the calling point and setup incoming arguments on caller point. gcc will magically match these two no matter what ABI-changing compile flag (i.e. -mregparm) you use. When you call procedure from inside asm, gcc does not know about that, and there is no way that gcc will know where arguments are to be found. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
--- Comment #8 from hjl dot tools at gmail dot com 2009-02-09 20:46 --- Reopened. -- hjl dot tools at gmail dot com changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|INVALID | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
--- Comment #9 from hjl dot tools at gmail dot com 2009-02-09 20:46 --- *** Bug 39139 has been marked as a duplicate of this bug. *** -- hjl dot tools at gmail dot com changed: What|Removed |Added CC||jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
--- Comment #10 from hjl dot tools at gmail dot com 2009-02-09 20:47 --- The rational for this request is at http://gcc.gnu.org/bugzilla/attachment.cgi?id=17274 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
--- Comment #11 from hjl dot tools at gmail dot com 2009-02-09 20:49 --- Uros, how hard to support this in x86 backend? -- hjl dot tools at gmail dot com changed: What|Removed |Added CC||ubizjak at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
--- Comment #12 from ubizjak at gmail dot com 2009-02-09 22:43 --- (In reply to comment #11) Uros, how hard to support this in x86 backend? I remember there were concerns when xmm0 single-register constraint was introduced... We need new constraint letter and new regclass entry. I don't have relevant mail at hand, but IIRC adding new register class is O(n*n). OTOH, constraints should be used to support correct register allocation for machine instructions, not to emulate ABI in order to support calls from inside asm statements. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16331
[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
--- 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
[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
--- 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: test: 0: 55 push %rbp 1: 48 89 e5mov%rsp,%rbp 4: e8 00 00 00 00 callq 9 test+0x9 5: R_X86_64_PC32hokus+0xfffc 9: 41 89 c0mov%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 c7mov%r8d,%edi 24: e8 00 00 00 00 callq 29 test+0x29 25: R_X86_64_PC32 pokus+0xfffc 29: e8 00 00 00 00 callq 2e test+0x2e 2a: R_X86_64_PC32 hokus+0xfffc 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 c7mov%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+0xfffc 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
[Bug target/16331] x86-64 inline asm register constraints insufficient WRT ABI
--- 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