Skip to content

Commit 2cb4100

Browse files
mati865alexcrichton
authored andcommitted
Teach the regmask clobber check to check if any subregister is preserved before considering the super register clobbered (#28)
X86 has some calling conventions where bits 127:0 of a vector register are callee saved, but the upper bits aren't. Previously we could detect that the full ymm register was clobbered when the xmm portion was really preserved. This patch checks the subregisters to make sure they aren't preserved. Fixes PR44140 Differential Revision: https://reviews.llvm.org/D70699
1 parent de1a7db commit 2cb4100

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,25 @@ void CriticalAntiDepBreaker::ScanInstruction(MachineInstr &MI, unsigned Count) {
261261
for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
262262
MachineOperand &MO = MI.getOperand(i);
263263

264-
if (MO.isRegMask())
265-
for (unsigned i = 0, e = TRI->getNumRegs(); i != e; ++i)
266-
if (MO.clobbersPhysReg(i)) {
264+
if (MO.isRegMask()) {
265+
auto ClobbersPhysRegAndSubRegs = [&](unsigned PhysReg) {
266+
for (MCSubRegIterator SRI(PhysReg, TRI, true); SRI.isValid(); ++SRI)
267+
if (!MO.clobbersPhysReg(*SRI))
268+
return false;
269+
270+
return true;
271+
};
272+
273+
for (unsigned i = 0, e = TRI->getNumRegs(); i != e; ++i) {
274+
if (ClobbersPhysRegAndSubRegs(i)) {
267275
DefIndices[i] = Count;
268276
KillIndices[i] = ~0u;
269277
KeepRegs.reset(i);
270278
Classes[i] = nullptr;
271279
RegRefs.erase(i);
272280
}
281+
}
282+
}
273283

274284
if (!MO.isReg()) continue;
275285
unsigned Reg = MO.getReg();

0 commit comments

Comments
 (0)