[CodeGen] Don't zero callee-save registers with zero-call-used-regs (PR57692)

Callee save registers must be preserved, so -fzero-call-used-regs
should not be zeroing them. The previous implementation only did
not zero callee save registers that were saved&restored inside the
function, but we need preserve all of them.

Fixes https://github.com/llvm/llvm-project/issues/57692.

Differential Revision: https://reviews.llvm.org/D133946
This commit is contained in:
Nikita Popov 2022-09-15 17:00:55 +02:00
parent e540965915
commit b4309800e9
3 changed files with 4 additions and 55 deletions

View File

@ -1273,9 +1273,10 @@ void PEI::insertZeroCallUsedRegs(MachineFunction &MF) {
}
}
// Don't clear registers that are reset before exiting.
for (const CalleeSavedInfo &CSI : MF.getFrameInfo().getCalleeSavedInfo())
for (MCRegister Reg : TRI.sub_and_superregs_inclusive(CSI.getReg()))
// Don't clear registers that must be preserved.
for (const MCPhysReg *CSRegs = TRI.getCalleeSavedRegs(&MF);
MCPhysReg CSReg = *CSRegs; ++CSRegs)
for (MCRegister Reg : TRI.sub_and_superregs_inclusive(CSReg))
RegsToZero.reset(Reg);
const TargetFrameLowering &TFI = *MF.getSubtarget().getFrameLowering();

View File

@ -220,14 +220,6 @@ define dso_local i32 @all(i32 noundef %a, i32 noundef %b, i32 noundef %c) local_
; DEFAULT-NEXT: movi v5.2d, #0000000000000000
; DEFAULT-NEXT: movi v6.2d, #0000000000000000
; DEFAULT-NEXT: movi v7.2d, #0000000000000000
; DEFAULT-NEXT: movi v8.2d, #0000000000000000
; DEFAULT-NEXT: movi v9.2d, #0000000000000000
; DEFAULT-NEXT: movi v10.2d, #0000000000000000
; DEFAULT-NEXT: movi v11.2d, #0000000000000000
; DEFAULT-NEXT: movi v12.2d, #0000000000000000
; DEFAULT-NEXT: movi v13.2d, #0000000000000000
; DEFAULT-NEXT: movi v14.2d, #0000000000000000
; DEFAULT-NEXT: movi v15.2d, #0000000000000000
; DEFAULT-NEXT: movi v16.2d, #0000000000000000
; DEFAULT-NEXT: movi v17.2d, #0000000000000000
; DEFAULT-NEXT: movi v18.2d, #0000000000000000
@ -276,14 +268,6 @@ define dso_local i32 @all(i32 noundef %a, i32 noundef %b, i32 noundef %c) local_
; SVE-NEXT: mov z5.d, #0 // =0x0
; SVE-NEXT: mov z6.d, #0 // =0x0
; SVE-NEXT: mov z7.d, #0 // =0x0
; SVE-NEXT: mov z8.d, #0 // =0x0
; SVE-NEXT: mov z9.d, #0 // =0x0
; SVE-NEXT: mov z10.d, #0 // =0x0
; SVE-NEXT: mov z11.d, #0 // =0x0
; SVE-NEXT: mov z12.d, #0 // =0x0
; SVE-NEXT: mov z13.d, #0 // =0x0
; SVE-NEXT: mov z14.d, #0 // =0x0
; SVE-NEXT: mov z15.d, #0 // =0x0
; SVE-NEXT: mov z16.d, #0 // =0x0
; SVE-NEXT: mov z17.d, #0 // =0x0
; SVE-NEXT: mov z18.d, #0 // =0x0
@ -548,14 +532,6 @@ define dso_local double @all_float(double noundef %a, float noundef %b) local_un
; DEFAULT-NEXT: movi v5.2d, #0000000000000000
; DEFAULT-NEXT: movi v6.2d, #0000000000000000
; DEFAULT-NEXT: movi v7.2d, #0000000000000000
; DEFAULT-NEXT: movi v8.2d, #0000000000000000
; DEFAULT-NEXT: movi v9.2d, #0000000000000000
; DEFAULT-NEXT: movi v10.2d, #0000000000000000
; DEFAULT-NEXT: movi v11.2d, #0000000000000000
; DEFAULT-NEXT: movi v12.2d, #0000000000000000
; DEFAULT-NEXT: movi v13.2d, #0000000000000000
; DEFAULT-NEXT: movi v14.2d, #0000000000000000
; DEFAULT-NEXT: movi v15.2d, #0000000000000000
; DEFAULT-NEXT: movi v16.2d, #0000000000000000
; DEFAULT-NEXT: movi v17.2d, #0000000000000000
; DEFAULT-NEXT: movi v18.2d, #0000000000000000
@ -604,14 +580,6 @@ define dso_local double @all_float(double noundef %a, float noundef %b) local_un
; SVE-NEXT: mov z5.d, #0 // =0x0
; SVE-NEXT: mov z6.d, #0 // =0x0
; SVE-NEXT: mov z7.d, #0 // =0x0
; SVE-NEXT: mov z8.d, #0 // =0x0
; SVE-NEXT: mov z9.d, #0 // =0x0
; SVE-NEXT: mov z10.d, #0 // =0x0
; SVE-NEXT: mov z11.d, #0 // =0x0
; SVE-NEXT: mov z12.d, #0 // =0x0
; SVE-NEXT: mov z13.d, #0 // =0x0
; SVE-NEXT: mov z14.d, #0 // =0x0
; SVE-NEXT: mov z15.d, #0 // =0x0
; SVE-NEXT: mov z16.d, #0 // =0x0
; SVE-NEXT: mov z17.d, #0 // =0x0
; SVE-NEXT: mov z18.d, #0 // =0x0

View File

@ -110,19 +110,13 @@ define dso_local i32 @all_gpr(i32 returned %x) local_unnamed_addr #0 "zero-call-
; I386-LABEL: all_gpr:
; I386: # %bb.0: # %entry
; I386-NEXT: movl {{[0-9]+}}(%esp), %eax
; I386-NEXT: xorl %ebp, %ebp
; I386-NEXT: xorl %ebx, %ebx
; I386-NEXT: xorl %ecx, %ecx
; I386-NEXT: xorl %edi, %edi
; I386-NEXT: xorl %edx, %edx
; I386-NEXT: xorl %esi, %esi
; I386-NEXT: retl
;
; X86-64-LABEL: all_gpr:
; X86-64: # %bb.0: # %entry
; X86-64-NEXT: movl %edi, %eax
; X86-64-NEXT: xorl %ebp, %ebp
; X86-64-NEXT: xorl %ebx, %ebx
; X86-64-NEXT: xorl %ecx, %ecx
; X86-64-NEXT: xorl %edi, %edi
; X86-64-NEXT: xorl %edx, %edx
@ -131,10 +125,6 @@ define dso_local i32 @all_gpr(i32 returned %x) local_unnamed_addr #0 "zero-call-
; X86-64-NEXT: xorl %r9d, %r9d
; X86-64-NEXT: xorl %r10d, %r10d
; X86-64-NEXT: xorl %r11d, %r11d
; X86-64-NEXT: xorl %r12d, %r12d
; X86-64-NEXT: xorl %r13d, %r13d
; X86-64-NEXT: xorl %r14d, %r14d
; X86-64-NEXT: xorl %r15d, %r15d
; X86-64-NEXT: retq
entry:
@ -190,12 +180,8 @@ define dso_local i32 @all(i32 returned %x) local_unnamed_addr #0 "zero-call-used
; I386-NEXT: fstp %st(0)
; I386-NEXT: fstp %st(0)
; I386-NEXT: fstp %st(0)
; I386-NEXT: xorl %ebp, %ebp
; I386-NEXT: xorl %ebx, %ebx
; I386-NEXT: xorl %ecx, %ecx
; I386-NEXT: xorl %edi, %edi
; I386-NEXT: xorl %edx, %edx
; I386-NEXT: xorl %esi, %esi
; I386-NEXT: xorps %xmm0, %xmm0
; I386-NEXT: xorps %xmm1, %xmm1
; I386-NEXT: xorps %xmm2, %xmm2
@ -225,8 +211,6 @@ define dso_local i32 @all(i32 returned %x) local_unnamed_addr #0 "zero-call-used
; X86-64-NEXT: fstp %st(0)
; X86-64-NEXT: fstp %st(0)
; X86-64-NEXT: fstp %st(0)
; X86-64-NEXT: xorl %ebp, %ebp
; X86-64-NEXT: xorl %ebx, %ebx
; X86-64-NEXT: xorl %ecx, %ecx
; X86-64-NEXT: xorl %edi, %edi
; X86-64-NEXT: xorl %edx, %edx
@ -235,10 +219,6 @@ define dso_local i32 @all(i32 returned %x) local_unnamed_addr #0 "zero-call-used
; X86-64-NEXT: xorl %r9d, %r9d
; X86-64-NEXT: xorl %r10d, %r10d
; X86-64-NEXT: xorl %r11d, %r11d
; X86-64-NEXT: xorl %r12d, %r12d
; X86-64-NEXT: xorl %r13d, %r13d
; X86-64-NEXT: xorl %r14d, %r14d
; X86-64-NEXT: xorl %r15d, %r15d
; X86-64-NEXT: xorps %xmm0, %xmm0
; X86-64-NEXT: xorps %xmm1, %xmm1
; X86-64-NEXT: xorps %xmm2, %xmm2