[CodeGen] Skip some instructions that shouldn't affect shrink-wrapping

r320606 checked for MI.isMetaInstruction which skips all DBG_VALUEs.

This also skips IMPLICIT_DEFs and other instructions that may def / read
a register.

Differential Revision: https://reviews.llvm.org/D42119

llvm-svn: 322584
This commit is contained in:
Francis Visoiu Mistrih 2018-01-16 18:55:26 +00:00
parent d3ec3e5684
commit 54a9e7a400
1 changed files with 5 additions and 5 deletions

View File

@ -240,10 +240,6 @@ INITIALIZE_PASS_END(ShrinkWrap, DEBUG_TYPE, "Shrink Wrap Pass", false, false)
bool ShrinkWrap::useOrDefCSROrFI(const MachineInstr &MI,
RegScavenger *RS) const {
// Ignore DBG_VALUE and other meta instructions that must not affect codegen.
if (MI.isMetaInstruction())
return false;
if (MI.getOpcode() == FrameSetupOpcode ||
MI.getOpcode() == FrameDestroyOpcode) {
DEBUG(dbgs() << "Frame instruction: " << MI << '\n');
@ -252,6 +248,9 @@ bool ShrinkWrap::useOrDefCSROrFI(const MachineInstr &MI,
for (const MachineOperand &MO : MI.operands()) {
bool UseOrDefCSR = false;
if (MO.isReg()) {
// Ignore instructions like DBG_VALUE which don't read/def the register.
if (!MO.isDef() && !MO.readsReg())
continue;
unsigned PhysReg = MO.getReg();
if (!PhysReg)
continue;
@ -267,7 +266,8 @@ bool ShrinkWrap::useOrDefCSROrFI(const MachineInstr &MI,
}
}
}
if (UseOrDefCSR || MO.isFI()) {
// Skip FrameIndex operands in DBG_VALUE instructions.
if (UseOrDefCSR || (MO.isFI() && !MI.isDebugValue())) {
DEBUG(dbgs() << "Use or define CSR(" << UseOrDefCSR << ") or FI("
<< MO.isFI() << "): " << MI << '\n');
return true;