llvm.org GIT mirror llvm / 1264f61
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 Reid Kleckner 4 years ago
3 changed file(s) with 12 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
194194 private:
195195 CallingConv::ID CallingConv;
196196 bool IsVarArg;
197 bool AnalyzingMustTailForwardedRegs = false;
197198 MachineFunction &MF;
198199 const TargetRegisterInfo &TRI;
199200 SmallVectorImpl &Locs;
415416 unsigned Result = StackOffset;
416417 StackOffset += Size;
417418 MaxStackArgAlign = std::max(Align, MaxStackArgAlign);
418 MF.getFrameInfo()->ensureMaxAlignment(Align);
419 ensureMaxAlignment(Align);
419420 return Result;
421 }
422
423 void ensureMaxAlignment(unsigned Align) {
424 if (!AnalyzingMustTailForwardedRegs)
425 MF.getFrameInfo()->ensureMaxAlignment(Align);
420426 }
421427
422428 /// Version of AllocateStack with extra register to be shadowed.
5050 Size = MinSize;
5151 if (MinAlign > (int)Align)
5252 Align = MinAlign;
53 MF.getFrameInfo()->ensureMaxAlignment(Align);
53 ensureMaxAlignment(Align);
5454 MF.getSubtarget().getTargetLowering()->HandleByVal(this, Size, Align);
5555 Size = unsigned(alignTo(Size, MinAlign));
5656 unsigned Offset = AllocateStack(Size, Align);
235235 // variadic functions, so we need to assume we're not variadic so that we get
236236 // all the registers that might be used in a non-variadic call.
237237 SaveAndRestore SavedVarArg(IsVarArg, false);
238 SaveAndRestore SavedMustTail(AnalyzingMustTailForwardedRegs, true);
238239
239240 for (MVT RegVT : RegParmTypes) {
240241 SmallVector RemainingRegs;
11 ; RUN: llc < %s -enable-tail-merge=0 -mtriple=x86_64-linux-gnux32 | FileCheck %s --check-prefix=LINUX-X32
22 ; RUN: llc < %s -enable-tail-merge=0 -mtriple=x86_64-windows | FileCheck %s --check-prefix=WINDOWS
33 ; RUN: llc < %s -enable-tail-merge=0 -mtriple=i686-windows | FileCheck %s --check-prefix=X86
4 ; RUN: llc < %s -enable-tail-merge=0 -mtriple=i686-windows -mattr=+sse2 | FileCheck %s --check-prefix=X86
45
56 ; Test that we actually spill and reload all arguments in the variadic argument
67 ; pack. Doing a normal call will clobber all argument registers, and we will
135136 ; WINDOWS: jmpq *%rcx # TAILCALL
136137
137138 ; X86-LABEL: _g_thunk:
139 ; X86-NOT: push %ebp
140 ; X86-NOT: andl {{.*}}, %esp
138141 ; X86: jmpl *%eax # TAILCALL
139142
140143 ; Do a simple multi-exit multi-bb test.