[llvm-commits] [llvm] r39967 - in /llvm/trunk: lib/Target/X86/X86MachineFunctionInfo.h lib/Target/X86/X86RegisterInfo.cpp lib/Target/X86/X86RegisterInfo.h test/CodeGen/X86/2006-05-02-InstrSched2.ll test/CodeGen/X86/2006-05-11-InstrSched.ll test/CodeGen/X86/2007-03-15-GEP-Idx-Sink.ll test/CodeGen/X86/2007-05-07-InvokeSRet.ll

Evan Cheng evan.cheng at apple.com
Wed Jul 18 11:44:39 PDT 2007


On Jul 18, 2007, at 6:42 AM, Dan Gohman wrote:

>>> It looks like this doesn't reset ESP/RSP in the case where a
>>> function calls
>>> alloca but has no static-sized allocation, i.e. when NumBytes is  
>>> zero
>>> and MFI->hasVarSizedObjects() is true.
>>
>> Right. Fixed. Somehow it didn't break anything on x86 / Mac OS X. Do
>> you have a failure case? If so, please reduce it and send it  to me
>> if possible?
>
> This test case shows it:
>
> declare void @bar(<2 x i64>* %n)
>
> define void @foo(i64 %h) {
>   %k = trunc i64 %h to i32
>   %p = alloca <2 x i64>, i32 %k
>   call void @bar(<2 x i64>* %p)
>   ret void
> }
>
>
> It looks like your fix works. One nit though, using LEA instead of MOV
> to do the restore is a little unusual. At a quick glance, it looks  
> like
> moving the MFI->hasVarSizedObjects() logic above the
> "Skip the callee-saved pop instructions" logic would allow it to  
> use MOV
> instead of LEA.

It must restore esp before the pop instructions that restore the  
callee-saved registers. So it cannot be moved up. It's true that it  
should emit MOVe instead of LEA when callee-saved frame size is zero  
though. I'll fix that. Thanks.

>
> That would also make it easier to make the code be able to use the  
> LEAVE
> instruction :).

LEAVE is a bad idea for modern Intel implementations (slow since it's  
micro-coded).

Evan

>
> Dan
>
> -- 
> Dan Gohman, Cray Inc.
> _______________________________________________
> 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