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

--- Comment #5 from Ammar Faizi <ammarfaizi2 at gmail dot com> ---
(In reply to Jakub Jelinek from comment #3)
> This has been hanging or ICEing on and off since forever.
> E.g. even r105000 ICEs, r200000 works, r210000 ICEs, r10-5912 works, r11-1
> hangs, so does current trunk.
> The first revision after r10-5912 to start hanging was
> r10-6326-gbcf3fa7cf5a3d024b507.
> Note, without optimizations, the inline asm is on or beyond the border what
> can be handled, it uses 6 of the 8 GPRs the arch has, the further two are
> the stack pointer and when not optimizing or if frame pointer is for
> whatever reason needed frame pointer.  The asm also has a memory input.  So,
> it fully depends on optimization (which isn't done with -O0 generally) that
> the address of the
> _arg6 variable can be expressed as offset(%esp) or offset(%ebp).  If it is
> not (and -O0 asks for no optimizations), then there are no registers left
> how to describe the input.

Interestingly, changing the my_syscall6() macro to this one works nicely.

#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6)    \
({                                                              \
        long _eax  = (long)(num);                               \
        long _arg6 = (long)(arg6); /* Always in memory */       \
        __asm__ volatile (                                      \
                "pushl  %[_arg6]\n\t"                           \
                "pushl  %%ebp\n\t"                              \
                "movl   4(%%esp),%%ebp\n\t"                     \
                "int    $0x80\n\t"                              \
                "popl   %%ebp\n\t"                              \
                "addl   $4,%%esp\n\t"                           \
                : "+a"(_eax)            /* %eax */              \
                : "b"(arg1),            /* %ebx */              \
                  "c"(arg2),            /* %ecx */              \
                  "d"(arg3),            /* %edx */              \
                  "S"(arg4),            /* %esi */              \
                  "D"(arg5),            /* %edi */              \
                  [_arg6]"m"(_arg6)     /* memory */            \
                : "memory", "cc"                                \
        );                                                      \
        _eax;                                                   \
})

Link: https://godbolt.org/z/hdsffvr1d

What could possibly be wrong here?
I am not sure what is the behavior difference between this macro with the
previously posted?

Reply via email to