fix stack probe lowering for x86_intrcc
authorTom Dohrmann <erbse.13@gmx.de>
Tue, 9 May 2023 06:06:30 +0000 (14:06 +0800)
committerPhoebe Wang <phoebe.wang@intel.com>
Tue, 9 May 2023 08:31:42 +0000 (16:31 +0800)
commitf6154364f65709df234f07ad1fe8799e68d84134
tree7324d255c0f7b5f850948c8326400e62c1144d71
parent74fd474eea53e85fc8f64422f565fd2bd50fd7e4
fix stack probe lowering for x86_intrcc

The x86_intrcc calling convention will build two STACKALLOC_W_PROBING machine instructions if the function takes an error code. This is caused by an additional call to emitSPUpdate in llvm/lib/Target/X86/X86FrameLowering.cpp:1650. Previously only the first STACKALLOC_W_PROBING machine instruction was properly handled, the second one was simply ignored. This lead to miscompilations where the stack pointer wasn't properly updated (see https://github.com/rust-lang/rust/issues/109918). This patch fixes this by handling all STACKALLOC_W_PROBING machine instructions.

To be honest I don't quite understand why this didn't lead to more noticeable miscompilations previously.

This is my first time contributing to LLVM.

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D150033
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/test/CodeGen/X86/x86-64-intrcc.ll