[llvm] 8f2ec97 - [X86] Move target-generic code into CodeGen [NFC]
Bill Wendling via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 27 15:37:36 PDT 2022
Author: Bill Wendling
Date: 2022-04-27T15:37:28-07:00
New Revision: 8f2ec974d1cf0ecde8b1b047db2e1bf0cb3a6c7f
URL: https://github.com/llvm/llvm-project/commit/8f2ec974d1cf0ecde8b1b047db2e1bf0cb3a6c7f
DIFF: https://github.com/llvm/llvm-project/commit/8f2ec974d1cf0ecde8b1b047db2e1bf0cb3a6c7f.diff
LOG: [X86] Move target-generic code into CodeGen [NFC]
This code is the same for all platforms.
Differential Revision: https://reviews.llvm.org/D124566
Added:
Modified:
llvm/lib/CodeGen/PrologEpilogInserter.cpp
llvm/lib/Target/X86/X86FrameLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
index bc4545029788f..f222b4a117708 100644
--- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
@@ -1227,7 +1227,7 @@ void PEI::insertZeroCallUsedRegs(MachineFunction &MF) {
RegsToZero.set(Reg);
}
- // Remove registers that are live when leaving the function.
+ // Don't clear registers that are live when leaving the function.
for (const MachineBasicBlock &MBB : MF)
for (const MachineInstr &MI : MBB.terminators()) {
if (!MI.isReturn())
@@ -1242,6 +1242,31 @@ void PEI::insertZeroCallUsedRegs(MachineFunction &MF) {
}
}
+ // Don't need to clear registers that are used/clobbered by terminating
+ // instructions.
+ for (const MachineBasicBlock &MBB : MF) {
+ if (!MBB.isReturnBlock())
+ continue;
+
+ MachineBasicBlock::const_iterator MBBI = MBB.getFirstTerminator();
+ for (MachineBasicBlock::const_iterator I = MBBI, E = MBB.end(); I != E;
+ ++I) {
+ for (const MachineOperand &MO : I->operands()) {
+ if (!MO.isReg())
+ continue;
+
+ for (const MCPhysReg &Reg :
+ TRI.sub_and_superregs_inclusive(MO.getReg()))
+ RegsToZero.reset(Reg);
+ }
+ }
+ }
+
+ // 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()))
+ RegsToZero.reset(Reg);
+
const TargetFrameLowering &TFI = *MF.getSubtarget().getFrameLowering();
for (MachineBasicBlock &MBB : MF)
if (MBB.isReturnBlock())
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp
index 005ccad0afef7..d524090f902e7 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.cpp
+++ b/llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -500,25 +500,9 @@ void X86FrameLowering::emitZeroCallUsedRegs(BitVector RegsToZero,
MachineBasicBlock &MBB) const {
const MachineFunction &MF = *MBB.getParent();
- // Don't clear registers that will just be reset before exiting.
- for (const CalleeSavedInfo &CSI : MF.getFrameInfo().getCalleeSavedInfo())
- for (MCRegister Reg : TRI->sub_and_superregs_inclusive(CSI.getReg()))
- RegsToZero.reset(Reg);
-
// Insertion point.
MachineBasicBlock::iterator MBBI = MBB.getFirstTerminator();
- // We don't need to zero out registers that are clobbered by "pop"
- // instructions.
- for (MachineBasicBlock::iterator I = MBBI, E = MBB.end(); I != E; ++I)
- for (const MachineOperand &MO : I->operands()) {
- if (!MO.isReg())
- continue;
-
- for (const MCPhysReg &Reg : TRI->sub_and_superregs_inclusive(MO.getReg()))
- RegsToZero.reset(Reg);
- }
-
// Fake a debug loc.
DebugLoc DL;
if (MBBI != MBB.end())
More information about the llvm-commits
mailing list