[LLVMbugs] [Bug 12198] New: should accept inline asm with -fomit-frame-pointer -mstackrealign

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 6 15:16:24 PST 2012


http://llvm.org/bugs/show_bug.cgi?id=12198

             Bug #: 12198
           Summary: should accept inline asm with -fomit-frame-pointer
                    -mstackrealign
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


This is reduced from ffmpeg by delta:

typedef int int32_t;
void mlp_filter_channel_x86(int32_t *state, const int32_t *coeff,
                            unsigned int filter_shift, int32_t mask,
                            int blocksize, int32_t *sample_buffer)
{
    const void *firjump;
    const void *iirjump;
    __asm__ volatile(
        "%0 %1 %2 %3 %4 %5 %6 %7"
        : "+r"(state),
          "+r"(coeff),
          "+r"(sample_buffer),
          "+m"(blocksize)
        : "m"(mask), "m"(firjump), "m"(iirjump) , "m"(filter_shift)
        : "eax", "edx", "esi", "ecx"
    );
}

It took me a long time to figure out how this is supposed to even work:

$ gcc -m32 000.c
000.c: In function ‘mlp_filter_channel_x86’:
000.c:8: error: can't find a register in class ‘GENERAL_REGS’ while reloading
‘asm’
000.c:8: error: ‘asm’ operand has impossible constraints

What works is omitting the frame pointer.

$ gcc -m32 -fomit-frame-pointer 000.c -S -o -
[...]
        %ebp %edi %ebx 52(%esp) 48(%esp) 12(%esp) 8(%esp) 44(%esp)
[...]

Clang doesn't need to omit the frame pointer, which is impressive.

$ clang -m32 000.c -S -o -
[...]
        %edi %ebx %ebp 24(%esp) 28(%esp) 16(%esp) 12(%esp) 32(%esp)
[...]

$ clang -m32 -fomit-frame-pointer 000.c -S -o -
[...]
        %edi %ebx %ebp 24(%esp) 28(%esp) 16(%esp) 12(%esp) 32(%esp)
[...]

But then asking it to realign the stack breaks everything:

$ llvm/Debug+Asserts/bin/clang -m32 -fomit-frame-pointer -mstackrealign 000.c
-S -o -
        .file   "000.c"
000.c:9:9: error: ran out of registers during register allocation
        "%0 %1 %2 %3 %4 %5 %6 %7"
        ^
[...]
        %edi %ebx %eax 24(%esp) 28(%esp) 16(%esp) 12(%esp) 32(%esp)
[...]

Even though that works with gcc:

$ gcc -m32 -fomit-frame-pointer -mstackrealign 000.c -S -o -
[...]
        %ebp %edi %ebx 52(%esp) 48(%esp) 12(%esp) 8(%esp) 44(%esp)
[...]

I want clang -m32 -fomit-frame-pointer -mstackrealign to work on this testcase.
GCC handles it.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list