[LLVMbugs] [Bug 237] NEW: [x86] wierd stack/frame pointer manipulation

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Feb 13 21:46:16 PST 2004


           Summary: [x86] wierd stack/frame pointer manipulation
           Product: libraries
           Version: 1.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: X86 Backend
        AssignedTo: gaeke+bugs at uiuc.edu
        ReportedBy: sabre at nondot.org

The X86 backend seems to confuse itself thoroughly when adjusting the stack and
framepointer in several cases, causing inefficient code to be generated.  For
example, this trivial function:

int %test(int %X) {
        ret int %X

Generates this code:

        sub %ESP, 4
        mov %EAX, DWORD PTR [%ESP + 8]
        add %ESP, 4

Obviously the ESP adjustments are unnecessary.  Things get even wierder when you
turn off frame-pointer elimination.  You get:

        sub %ESP, 4
        mov DWORD PTR [%ESP], %EBP
        lea %EBP, DWORD PTR [%ESP + 4]
        mov %EAX, DWORD PTR [%EBP + 4]
        mov %ESP, %EBP
        mov %EBP, DWORD PTR [%ESP - 4]

The strange part of this is that EBP doesn't point to the old EBP value, it
points to the return address!  I think this violates every X86 convention every
invented, and is inefficient (in space and time) to boot.

The X86 backend seems to be consistent in this wierdness at least, so it
compiles programs correctly, but there is no reason for this.


------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the llvm-bugs mailing list