llvm.org GIT mirror llvm / 336b636
Fix the Red Zone calculation for functions with frame pointers. Don't use the Red Zone when dynamic stack realignment is needed. This could be implemented, but most x86-64 ABIs don't require dynamic stack realignment so it isn't urgent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63074 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
1 changed file(s) with 10 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
720720 // Get desired stack alignment
721721 uint64_t MaxAlign = MFI->getMaxAlignment();
722722
723 // Add RETADDR move area to callee saved frame size.
724 int TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
725 if (TailCallReturnAddrDelta < 0)
726 X86FI->setCalleeSavedFrameSize(
727 X86FI->getCalleeSavedFrameSize() +(-TailCallReturnAddrDelta));
728
723729 // If this is x86-64 and the Red Zone is not disabled, if we are a leaf
724730 // function, and use up to 128 bytes of stack space, don't have a frame
725731 // pointer, calls, or dynamic alloca then we do not need to adjust the
726732 // stack pointer (we fit in the Red Zone).
727733 if (Is64Bit && !DisableRedZone &&
734 !needsStackRealignment(MF) &&
728735 !MFI->hasVarSizedObjects() && // No dynamic alloca.
729736 !MFI->hasCalls()) { // No calls.
730 StackSize = std::max((uint64_t)X86FI->getCalleeSavedFrameSize(),
737 uint64_t MinSize = X86FI->getCalleeSavedFrameSize();
738 if (hasFP(MF)) MinSize += SlotSize;
739 StackSize = std::max(MinSize,
731740 StackSize > 128 ? StackSize - 128 : 0);
732741 MFI->setStackSize(StackSize);
733742 }
734
735 // Add RETADDR move area to callee saved frame size.
736 int TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta();
737 if (TailCallReturnAddrDelta < 0)
738 X86FI->setCalleeSavedFrameSize(
739 X86FI->getCalleeSavedFrameSize() +(-TailCallReturnAddrDelta));
740743
741744 // Insert stack pointer adjustment for later moving of return addr. Only
742745 // applies to tail call optimized functions where the callee argument stack