From c36b21c023548c241efa926c719f239ab98e84fa Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Thu, 13 May 2021 11:24:49 +0300 Subject: [PATCH] X86: modify PreserveAll CC to save full AVX-512 state --- lib/Target/X86/X86CallingConv.td | 3 +++ lib/Target/X86/X86RegisterInfo.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/Target/X86/X86CallingConv.td b/lib/Target/X86/X86CallingConv.td index 98883bbf59a..293e9ec2ab4 100644 --- a/lib/Target/X86/X86CallingConv.td +++ b/lib/Target/X86/X86CallingConv.td @@ -1129,6 +1129,9 @@ def CSR_64_RT_AllRegs : CalleeSavedRegs<(add CSR_64_RT_MostRegs, (sequence "XMM%u", 0, 15))>; def CSR_64_RT_AllRegs_AVX : CalleeSavedRegs<(add CSR_64_RT_MostRegs, (sequence "YMM%u", 0, 15))>; +def CSR_64_RT_AllRegs_512 : CalleeSavedRegs<(add CSR_64_RT_MostRegs, + (sequence "K%u", 0, 7), + (sequence "ZMM%u", 0, 31))>; def CSR_64_MostRegs : CalleeSavedRegs<(add RBX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, R12, R13, R14, R15, RBP, diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index c4748423bae..c13359a3f10 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -306,6 +306,8 @@ X86RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const { case CallingConv::PreserveMost: return CSR_64_RT_MostRegs_SaveList; case CallingConv::PreserveAll: + if (HasAVX512) + return CSR_64_RT_AllRegs_512_SaveList; if (HasAVX) return CSR_64_RT_AllRegs_AVX_SaveList; return CSR_64_RT_AllRegs_SaveList; @@ -429,6 +431,8 @@ X86RegisterInfo::getCallPreservedMask(const MachineFunction &MF, case CallingConv::PreserveMost: return CSR_64_RT_MostRegs_RegMask; case CallingConv::PreserveAll: + if (HasAVX512) + return CSR_64_RT_AllRegs_512_RegMask; if (HasAVX) return CSR_64_RT_AllRegs_AVX_RegMask; return CSR_64_RT_AllRegs_RegMask;