[X86] Move RDFLAGS/WRFLAGS expansion until after RA
authorBill Wendling <morbo@google.com>
Mon, 30 Jan 2023 21:19:52 +0000 (13:19 -0800)
committerBill Wendling <morbo@google.com>
Mon, 30 Jan 2023 23:32:16 +0000 (15:32 -0800)
commit7d626e7cbb3ac9b3f43a10df8d8edfab1300b156
treef78cb57e3753f40f830abe56ec5bc8803ceba3b0
parent053479118f18e0407f6b91304ebf19a8a735ec1f
[X86] Move RDFLAGS/WRFLAGS expansion until after RA

The register allocator may introduce reloads in the middle of reading
and writing the EFLAGS register, due to the RDFLAGS & WRFLAGS pseudos
being expanded before RA. This may cause an issue where the stack
pointer was adjusted but the stack offset for the reload wasn't
accounted for (see [1]).

To avoid this, expand these pseudos after register allocation.

[1] https://github.com/llvm/llvm-project/issues/59102

Reviewed By: craig.topper, nickdesaulniers, pengfei

Differential Revision: https://reviews.llvm.org/D140045
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86InstrInfo.cpp
llvm/lib/Target/X86/X86InstrInfo.td
llvm/test/CodeGen/X86/x86-64-flags-intrinsics.ll