Ensure stack allocations maintain 16-byte alignment for AVX instructions
This commit is contained in:
@@ -231,7 +231,13 @@ bool X64Emitter::Emit(HIRBuilder* builder, EmitFunctionInfo& func_info) {
|
|||||||
locals_page_delta_ = 0;
|
locals_page_delta_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_true((stack_size + 8) % 16 == 0);
|
// Ensure that after we SUB the stack_size, RSP is 16-byte aligned.
|
||||||
|
// On function entry, RSP is misaligned by 8 (due to CALL pushing return
|
||||||
|
// address). So we need stack_size to be 8 mod 16, not 0 mod 16.
|
||||||
|
if ((stack_size % 16) == 0) {
|
||||||
|
stack_size += 8; // Make it 8 mod 16
|
||||||
|
}
|
||||||
|
assert_true((stack_size % 16) == 8); // Should be 8 mod 16 for alignment
|
||||||
func_info.stack_size = stack_size;
|
func_info.stack_size = stack_size;
|
||||||
stack_size_ = stack_size;
|
stack_size_ = stack_size;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user