Chromium Code Reviews| Index: src/IceTargetLoweringX8632.cpp |
| diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp |
| index 27f9ae00064e6fc8f57fcce995becebd6c91eee1..2f3729e0a5b62bd6fd4c7ff9a82f91b763d7667e 100644 |
| --- a/src/IceTargetLoweringX8632.cpp |
| +++ b/src/IceTargetLoweringX8632.cpp |
| @@ -506,20 +506,36 @@ void TargetX8632::addProlog(CfgNode *Node) { |
| SpillAreaSizeBytes = StackSize - StackOffset; |
| } |
| - // Generate "sub esp, SpillAreaSizeBytes" |
| - if (SpillAreaSizeBytes) |
| + // Combine fixed allocations into SpillAreaSizeBytes if we are emitting |
|
Jim Stichnoth
2015/11/16 14:47:57
reflow to 80-cols
sehr
2015/11/16 18:42:24
Done.
|
| + // the fixed allocations in the prolog. |
| + if (PrologEmitsFixedAllocas) |
| + SpillAreaSizeBytes += FixedAllocaSizeBytes; |
| + if (SpillAreaSizeBytes) { |
| + // Generate "sub esp, SpillAreaSizeBytes" |
| _sub(getPhysicalRegister(Traits::RegisterSet::Reg_esp), |
| Ctx->getConstantInt32(SpillAreaSizeBytes)); |
| + // If the fixed allocas are aligned more than the stack frame, align the |
| + // stack pointer accordingly. |
| + if (PrologEmitsFixedAllocas && |
| + FixedAllocaAlignBytes > Traits::X86_STACK_ALIGNMENT_BYTES) { |
| + assert(IsEbpBasedFrame); |
| + _and(getPhysicalRegister(Traits::RegisterSet::Reg_esp), |
| + Ctx->getConstantInt32(-FixedAllocaAlignBytes)); |
|
John
2015/11/16 14:00:02
~FixedAllocaAlignBytes?
sehr
2015/11/16 18:42:24
FixedAllocaAlignBytes is a power of 2, so what I w
|
| + } |
| + } |
| - // Account for alloca instructions with known frame offsets. |
| - SpillAreaSizeBytes += FixedAllocaSizeBytes; |
| + // Account for alloca instructions with known frame offsets if they were |
| + // not combined with prolog. |
|
Jim Stichnoth
2015/11/16 14:47:57
maybe it would be better something like, "Account
sehr
2015/11/16 18:42:24
Done.
|
| + if (!PrologEmitsFixedAllocas) |
| + SpillAreaSizeBytes += FixedAllocaSizeBytes; |
| Ctx->statsUpdateFrameBytes(SpillAreaSizeBytes); |
| // Initialize the stack adjustment so that after all the known-frame-offset |
| // alloca instructions are emitted, the stack adjustment will reach zero. |
| resetStackAdjustment(); |
| - updateStackAdjustment(-FixedAllocaSizeBytes); |
| + if (!PrologEmitsFixedAllocas) |
| + updateStackAdjustment(-FixedAllocaSizeBytes); |
| // Fill in stack offsets for stack args, and copy args into registers for |
| // those that were register-allocated. Args are pushed right to left, so |
| @@ -539,11 +555,14 @@ void TargetX8632::addProlog(CfgNode *Node) { |
| ++NumXmmArgs; |
| continue; |
| } |
| - // For esp-based frames, the esp value may not stabilize to its home value |
| - // until after all the fixed-size alloca instructions have executed. In |
| - // this case, a stack adjustment is needed when accessing in-args in order |
| - // to copy them into registers. |
| - size_t StackAdjBytes = IsEbpBasedFrame ? 0 : -FixedAllocaSizeBytes; |
| + // For esp-based frames where the allocas are done outside the prolog, the |
| + // esp value may not stabilize to its home value until after all the |
| + // fixed-size alloca instructions have executed. In this case, a stack |
| + // adjustment is needed when accessing in-args in order to copy them into |
| + // registers. |
| + size_t StackAdjBytes = 0; |
| + if (!IsEbpBasedFrame && !PrologEmitsFixedAllocas) |
| + StackAdjBytes -= FixedAllocaSizeBytes; |
| finishArgumentLowering(Arg, FramePtr, BasicFrameOffset, StackAdjBytes, |
| InArgsSizeBytes); |
| } |