Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: src/IceTargetLoweringX8632.cpp

Issue 1435363002: Merge fixed alloca stack adjustments into the prolog (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Final code review comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceTargetLoweringMIPS32.h ('k') | src/IceTargetLoweringX86Base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLoweringX8632.cpp
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 27f9ae00064e6fc8f57fcce995becebd6c91eee1..e8a86d87e0fd32c0b4fc34a756833fb5515926c5 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 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));
+ }
+ }
- // Account for alloca instructions with known frame offsets.
- SpillAreaSizeBytes += FixedAllocaSizeBytes;
+ // Account for known-frame-offset alloca instructions that were not already
+ // combined into the prolog.
+ 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);
}
« no previous file with comments | « src/IceTargetLoweringMIPS32.h ('k') | src/IceTargetLoweringX86Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698