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.recou...@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