[llvm-commits] [llvm] r62338 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/ret-addr.ll
Bill Wendling
wendling at apple.com
Fri Jan 16 12:49:47 PST 2009
They are there because of the "Frame Address" lowering. They should go
away, but I haven't investigated that yet.
$ cat a.c
void *x() {
return __builtin_frame_address(0);
}
void *y() {
return __builtin_frame_address(1);
}
void *z() {
return __builtin_frame_address(2);
}
$ llvm-gcc -S -o - a.c -Os
.text
.align 1,0x90
.globl _z
_z:
pushl %ebp
movl %esp, %ebp
pushl %ebp
movl (%ebp), %eax
movl (%eax), %eax
popl %ebp
popl %ebp
ret
.align 1,0x90
.globl _y
_y:
pushl %ebp
movl %esp, %ebp
pushl %ebp
movl (%ebp), %eax
popl %ebp
popl %ebp
ret
.align 1,0x90
.globl _x
_x:
pushl %ebp
movl %esp, %ebp
pushl %ebp
movl %ebp, %eax
popl %ebp
popl %ebp
ret
On Jan 16, 2009, at 11:49 AM, Evan Cheng wrote:
> Where are the extra push and pop coming from?
>
> Evan
> On Jan 16, 2009, at 11:43 AM, Bill Wendling wrote:
>
>> For Depth > 1 (2 in this case), I get this from LLVM:
>>
>> .align 1,0x90
>> .globl _h
>> _h:
>> pushl %ebp
>> movl %esp, %ebp
>> pushl %ebp
>> movl (%ebp), %eax
>> movl (%eax), %eax
>> movl 4(%eax), %eax
>> popl %ebp
>> popl %ebp
>> ret
>>
>> And this from GCC:
>>
>> .globl _h
>> _h:
>> pushl %ebp
>> movl %esp, %ebp
>> movl 0(%ebp), %eax
>> movl (%eax), %eax
>> movl 4(%eax), %eax
>> leave
>> ret
>>
>> Except for the extraneous push/pop, these are the same, right? Or
>> am I
>> missing something?
>>
>> -bw
>>
>> On Fri, Jan 16, 2009 at 11:37 AM, Dale Johannesen <dalej at apple.com>
>> wrote:
>>> This doesn't do the right thing for Depth > 1. I don't think we
>>> need
>>> to short term, but the test should be ==1 and a comment should
>>> indicate this.
>>>
>>> On Jan 16, 2009, at 11:25 AMPST, Bill Wendling wrote:
>>>>
>>>> + if (Depth > 0) {
>>>> + SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
>>>> + SDValue Offset =
>>>> + DAG.getConstant(TD->getPointerSize(),
>>>> + Subtarget->is64Bit() ? MVT::i64 : MVT::i32);
>>>> + return DAG.getLoad(getPointerTy(), DAG.getEntryNode(),
>>>> + DAG.getNode(ISD::ADD, getPointerTy(),
>>>> FrameAddr, Offset),
>>>> + NULL, 0);
>>>> + }
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list