mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-25 15:41:05 +00:00
Avoid unnecessary stack realignment in musttail thunks with SSE2 enabled
The X86 musttail implementation finds register parameters to forward by running the calling convention algorithm until a non-register location is returned. However, assigning a vector memory location has the side effect of increasing the function's stack alignment. We shouldn't increase the stack alignment when we are only looking for register parameters, so this change conditionalizes it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258442 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
180abd8ba0
commit
1264f61388
@ -195,6 +195,7 @@ class CCState {
|
||||
private:
|
||||
CallingConv::ID CallingConv;
|
||||
bool IsVarArg;
|
||||
bool AnalyzingMustTailForwardedRegs = false;
|
||||
MachineFunction &MF;
|
||||
const TargetRegisterInfo &TRI;
|
||||
SmallVectorImpl<CCValAssign> &Locs;
|
||||
@ -416,10 +417,15 @@ public:
|
||||
unsigned Result = StackOffset;
|
||||
StackOffset += Size;
|
||||
MaxStackArgAlign = std::max(Align, MaxStackArgAlign);
|
||||
MF.getFrameInfo()->ensureMaxAlignment(Align);
|
||||
ensureMaxAlignment(Align);
|
||||
return Result;
|
||||
}
|
||||
|
||||
void ensureMaxAlignment(unsigned Align) {
|
||||
if (!AnalyzingMustTailForwardedRegs)
|
||||
MF.getFrameInfo()->ensureMaxAlignment(Align);
|
||||
}
|
||||
|
||||
/// Version of AllocateStack with extra register to be shadowed.
|
||||
unsigned AllocateStack(unsigned Size, unsigned Align, unsigned ShadowReg) {
|
||||
MarkAllocated(ShadowReg);
|
||||
|
@ -51,7 +51,7 @@ void CCState::HandleByVal(unsigned ValNo, MVT ValVT,
|
||||
Size = MinSize;
|
||||
if (MinAlign > (int)Align)
|
||||
Align = MinAlign;
|
||||
MF.getFrameInfo()->ensureMaxAlignment(Align);
|
||||
ensureMaxAlignment(Align);
|
||||
MF.getSubtarget().getTargetLowering()->HandleByVal(this, Size, Align);
|
||||
Size = unsigned(alignTo(Size, MinAlign));
|
||||
unsigned Offset = AllocateStack(Size, Align);
|
||||
@ -236,6 +236,7 @@ void CCState::analyzeMustTailForwardedRegisters(
|
||||
// variadic functions, so we need to assume we're not variadic so that we get
|
||||
// all the registers that might be used in a non-variadic call.
|
||||
SaveAndRestore<bool> SavedVarArg(IsVarArg, false);
|
||||
SaveAndRestore<bool> SavedMustTail(AnalyzingMustTailForwardedRegs, true);
|
||||
|
||||
for (MVT RegVT : RegParmTypes) {
|
||||
SmallVector<MCPhysReg, 8> RemainingRegs;
|
||||
|
@ -2,6 +2,7 @@
|
||||
; RUN: llc < %s -enable-tail-merge=0 -mtriple=x86_64-linux-gnux32 | FileCheck %s --check-prefix=LINUX-X32
|
||||
; RUN: llc < %s -enable-tail-merge=0 -mtriple=x86_64-windows | FileCheck %s --check-prefix=WINDOWS
|
||||
; RUN: llc < %s -enable-tail-merge=0 -mtriple=i686-windows | FileCheck %s --check-prefix=X86
|
||||
; RUN: llc < %s -enable-tail-merge=0 -mtriple=i686-windows -mattr=+sse2 | FileCheck %s --check-prefix=X86
|
||||
|
||||
; Test that we actually spill and reload all arguments in the variadic argument
|
||||
; pack. Doing a normal call will clobber all argument registers, and we will
|
||||
@ -136,6 +137,8 @@ define void @g_thunk(i8* %fptr_i8, ...) {
|
||||
; WINDOWS: jmpq *%rcx # TAILCALL
|
||||
|
||||
; X86-LABEL: _g_thunk:
|
||||
; X86-NOT: push %ebp
|
||||
; X86-NOT: andl {{.*}}, %esp
|
||||
; X86: jmpl *%eax # TAILCALL
|
||||
|
||||
; Do a simple multi-exit multi-bb test.
|
||||
|
Loading…
x
Reference in New Issue
Block a user