[LLVMdev] x86 code emitter ebp and esp conflicts

Peng Cheng gm4cheng at gmail.com
Thu Jan 31 11:58:03 PST 2013


A correction:

After reading the assembly code, the problem is when stack memory
allocation is happening between the stack subtraction and the actual
function call.

For example, the correct call to sin is:

sub esp, 8
move [esp], xmm0    ; line 1
call sin
add esp, 8

While the generated code adds some stack allocation after line 1 as follows:

sub esp, 8
move [esp], xmm0
    move eax, 10h
    call chkstk ; allocate more stack
    mov         esi,esp
    mov         eax,dword ptr [ebp-278h]
    mov         dword ptr [esi+8],eax
    mov         eax,dword ptr [ebp-274h]
    mov         dword ptr [esi+4],eax
    mov         eax,dword ptr [ebp-26Ch]
    mov         dword ptr [esi],eax
call sin
add esp, 8

This causes the stack pointer is pointing to the some user data, i.e., 8
bytes above the true stack top.

Does any one have any idea to prevent the above stack allocation?

Thanks,
-Peng


On Wed, Jan 30, 2013 at 3:38 PM, Peng Cheng <gm4cheng at gmail.com> wrote:

> Bug is reported with test cases.  see
> http://llvm.org/bugs/show_bug.cgi?id=15124 .
>
> Thanks,
> -Peng
>
>
> On Wed, Jan 30, 2013 at 12:14 PM, Anton Korobeynikov <
> anton at korobeynikov.info> wrote:
>
>> > Has anyone seen this problem before?  and is there any fix or work
>> around
>> > for that?
>> Please provide a testcase and fill LLVM problem report into bugzilla.
>>
>> Thanks!
>>
>> --
>> With best regards, Anton Korobeynikov
>> Faculty of Mathematics and Mechanics, Saint Petersburg State University
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130131/fbfb20db/attachment.html>


More information about the llvm-dev mailing list