Fix RequiredStackAlignment initialization sizeof(Traits::WordType) evaluates to obtaining the size of the numeric value of the IceType_i32 or IceType_i64 enum. Because enums default to being constants with an underlying type of 'int', this becomes 4 for both the x86-32 and x86-64 backends, while 8 was intended for the latter. A misaligned stack may have a significant performance impact. Note that an even greater stack alignment might be required, as both the Microsoft and System V x64 ABI require 16-byte alignment. This change only addresses the obvious semantics bug. Bug: b/193550986 Change-Id: If33c0a10d73c50bfb1bbc25f16acb97b3575e27a Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/55809 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Reviewed-by: Sean Risser <srisser@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/third_party/subzero/src/IceTargetLoweringX8632.h b/third_party/subzero/src/IceTargetLoweringX8632.h index a012d17..8272ebe 100644 --- a/third_party/subzero/src/IceTargetLoweringX8632.h +++ b/third_party/subzero/src/IceTargetLoweringX8632.h
@@ -874,7 +874,7 @@ void findRMW(); bool IsEbpBasedFrame = false; - size_t RequiredStackAlignment = sizeof(Traits::WordType); + size_t RequiredStackAlignment = sizeof(int32_t); // 4 bytes size_t SpillAreaSizeBytes = 0; size_t FixedAllocaSizeBytes = 0; size_t FixedAllocaAlignBytes = 0;
diff --git a/third_party/subzero/src/IceTargetLoweringX8664.h b/third_party/subzero/src/IceTargetLoweringX8664.h index 738ddae..78074d2 100644 --- a/third_party/subzero/src/IceTargetLoweringX8664.h +++ b/third_party/subzero/src/IceTargetLoweringX8664.h
@@ -868,7 +868,7 @@ void findRMW(); bool IsEbpBasedFrame = false; - size_t RequiredStackAlignment = sizeof(Traits::WordType); + size_t RequiredStackAlignment = sizeof(int64_t); // 8 bytes size_t SpillAreaSizeBytes = 0; size_t FixedAllocaSizeBytes = 0; size_t FixedAllocaAlignBytes = 0;