public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/94097] New: GCC fails to allocate "rm" input constraint when no more register is left
@ 2020-03-09 10:37 frederic.recoules@univ-grenoble-alpes.fr
  0 siblings, 0 replies; only message in thread
From: frederic.recoules@univ-grenoble-alpes.fr @ 2020-03-09 10:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94097
           Summary: GCC fails to allocate "rm" input constraint when no
                    more register is left
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: inline-asm
          Assignee: unassigned at gcc dot gnu.org
          Reporter: frederic.recoules@univ-grenoble-alpes.fr
  Target Milestone: ---

Consider the following code snippet:

int main (int argc, char *argv[])
{
  int x = 0;
  __asm__ ("movl %1, %0" "\n\t"
           : "=&a" (argc)
           : "rm" (x)
           : "ebx", "ecx", "edx",
             "edi", "esi", "ebp");
  return argc;
}

GCC 9.0 fails because the constraints are "impossible" but 'x' can still be
given by memory reference.

For instance, in the following code, that is quasi equivalent, but with swapped
constraints:

int main (int argc, char *argv[])
{
  int x = 0;
  __asm__ ("movl %1, %0"
           : "=&rm" (argc)
           : "a" (x)
           : "ebx", "ecx", "edx",
             "edi", "esi", "ebp");
  return argc;
}

It produces the following assembly, where a new cell is freshly allocated on
the stack to hold the value:

main:
  pushl %ebp
  xorl %eax, %eax
  pushl %edi
  pushl %esi
  pushl %ebx
  subl $4, %esp
#APP
  movl %eax, (%esp)
#NOAPP
  movl (%esp), %eax
  addl $4, %esp
  popl %ebx
  popl %esi
  popl %edi
  popl %ebp
  ret

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-09 10:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-09 10:37 [Bug inline-asm/94097] New: GCC fails to allocate "rm" input constraint when no more register is left frederic.recoules@univ-grenoble-alpes.fr

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