x86 interrupt calling convention: re-align stack pointer on 64-bit if an error code...
authorAmjad Aboud <amjad.aboud@intel.com>
Mon, 3 Apr 2017 20:28:45 +0000 (20:28 +0000)
committerAmjad Aboud <amjad.aboud@intel.com>
Mon, 3 Apr 2017 20:28:45 +0000 (20:28 +0000)
commit0389f62879fc9162fae12e57b93ae3565c915356
treef3cf5519ed3b9533f9d72177a870ee1e7b6f22ed
parent27b71e5b1b40a908f970b11ac6a1b7730ab1ed36
x86 interrupt calling convention: re-align stack pointer on 64-bit if an error code was pushed

The x86_64 ABI requires that the stack is 16 byte aligned on function calls. Thus, the 8-byte error code, which is pushed by the CPU for certain exceptions, leads to a misaligned stack. This results in bugs such as Bug 26413, where misaligned movaps instructions are generated.

This commit fixes the misalignment by adjusting the stack pointer in these cases. The adjustment is done at the beginning of the prologue generation by subtracting another 8 bytes from the stack pointer. These additional bytes are popped again in the function epilogue.

Fixes Bug 26413

Patch by Philipp Oppermann.

Differential Revision: https://reviews.llvm.org/D30049

llvm-svn: 299383
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/x86-64-intrcc-nosse.ll
llvm/test/CodeGen/X86/x86-64-intrcc.ll