[X86][VARARG] Avoid spilling xmm registers for va_start.
authorAlexey Lapshin <a.v.lapshin@mail.ru>
Sun, 14 Feb 2021 15:34:19 +0000 (18:34 +0300)
committerAlexey Lapshin <a.v.lapshin@mail.ru>
Sat, 6 Mar 2021 12:25:47 +0000 (15:25 +0300)
commitcf7cdaff64fb2a97f9af533ad0a5ed9c94b72c8e
treec90b4d02a4e0ddd8b4f1047ee60ae51585495e37
parentedf7004851519464f86b0f641da4d6c9506decb1
[X86][VARARG] Avoid spilling xmm registers for va_start.

That review is extracted from D69372.
It fixes https://bugs.llvm.org/show_bug.cgi?id=42219 bug.

For the noimplicitfloat mode, the compiler mustn't generate
floating-point code if it was not asked directly to do so.
This rule does not work with variable function arguments currently.
Though compiler correctly guards block of code, which copies xmm vararg
parameters with a check for %al, it does not protect spills for xmm registers.
Thus, such spills are generated in non-protected areas and could break code,
which does not expect floating-point data. The problem happens in -O0
optimization mode. With this optimization level there is used
FastRegisterAllocator, which spills virtual registers at basic block boundaries.
Register Allocator does not protect spills with additional control-flow modifications.
Thus to resolve that problem, it is suggested to not copy incoming physical
registers into virtual registers. Instead, store incoming physical xmm registers
into the memory from scratch.

Differential Revision: https://reviews.llvm.org/D80163
llvm/lib/Target/X86/X86ExpandPseudo.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/lib/Target/X86/X86InstrCompiler.td
llvm/test/CodeGen/X86/musttail-varargs.ll
llvm/test/CodeGen/X86/vastart-defs-eflags.ll
llvm/test/CodeGen/X86/x32-va_start.ll
llvm/test/CodeGen/X86/x86-64-varargs.ll
llvm/test/CodeGen/X86/xmm-vararg-noopt.ll [new file with mode: 0644]