summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineSink.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2019-10-31 12:34:17 +0000
committerJeremy Morse <jeremy.morse@sony.com>2019-10-31 12:39:06 +0000
commita8db456b53a1783e2c8b3f3a6666dfa715a885d4 (patch)
tree5169ab07643d51756c2486e72cc47ed9702ba272 /llvm/lib/CodeGen/MachineSink.cpp
parentd382a8a768b3636c5aa1a934977c54d0215633cf (diff)
downloadbcm5719-llvm-a8db456b53a1783e2c8b3f3a6666dfa715a885d4.tar.gz
bcm5719-llvm-a8db456b53a1783e2c8b3f3a6666dfa715a885d4.zip
Revert "[DebugInfo] MachineSink: Insert undef DBG_VALUEs when sinking instructions"
This reverts commit ee50590e1684c197bc4336984795e48bf53c7a4e. PR43855 reports a performance regression from this commit, which I'll look into.
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineSink.cpp53
1 files changed, 3 insertions, 50 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index 4c55158a004..27a2e7023f2 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -736,9 +736,6 @@ static bool SinkingPreventsImplicitNullCheck(MachineInstr &MI,
static void performSink(MachineInstr &MI, MachineBasicBlock &SuccToSinkTo,
MachineBasicBlock::iterator InsertPos,
SmallVectorImpl<MachineInstr *> *DbgVals = nullptr) {
- const MachineRegisterInfo &MRI = MI.getMF()->getRegInfo();
- const TargetInstrInfo &TII = *MI.getMF()->getSubtarget().getInstrInfo();
-
// If debug values are provided use those, otherwise call collectDebugValues.
SmallVector<MachineInstr *, 2> DbgValuesToSink;
if (DbgVals)
@@ -761,57 +758,13 @@ static void performSink(MachineInstr &MI, MachineBasicBlock &SuccToSinkTo,
SuccToSinkTo.splice(InsertPos, ParentBlock, MI,
++MachineBasicBlock::iterator(MI));
- // Sink a copy of debug users to the insert position. Mark the original
- // DBG_VALUE location as 'undef', indicating that any earlier variable
- // location should be terminated as we've optimised away the value at this
- // point.
- // If the sunk instruction is a copy, try to forward the copy instead of
- // leaving an 'undef' DBG_VALUE in the original location. Don't do this if
- // there's any subregister weirdness involved.
+ // Move previously adjacent debug value instructions to the insert position.
for (SmallVectorImpl<MachineInstr *>::iterator DBI = DbgValuesToSink.begin(),
DBE = DbgValuesToSink.end();
DBI != DBE; ++DBI) {
MachineInstr *DbgMI = *DBI;
- MachineInstr *NewDbgMI = DbgMI->getMF()->CloneMachineInstr(*DBI);
- SuccToSinkTo.insert(InsertPos, NewDbgMI);
-
- // Copy DBG_VALUE operand and set the original to undef. We then check to
- // see whether this is something that can be copy-forwarded. If it isn't,
- // continue around the loop.
- MachineOperand DbgMO = DbgMI->getOperand(0);
- DbgMI->getOperand(0).setReg(0);
-
- const MachineOperand *SrcMO = nullptr, *DstMO = nullptr;
- if (!TII.isCopyInstr(MI, SrcMO, DstMO))
- continue;
-
- // Check validity of forwarding this copy.
- bool PostRA = MRI.getNumVirtRegs() == 0;
-
- // Trying to forward between physical and virtual registers is too hard.
- if (DbgMO.getReg().isVirtual() != SrcMO->getReg().isVirtual())
- continue;
-
- // Only try virtual register copy-forwarding before regalloc, and physical
- // register copy-forwarding after regalloc.
- bool arePhysRegs = !DbgMO.getReg().isVirtual();
- if (arePhysRegs != PostRA)
- continue;
-
- // Pre-regalloc, only forward if all subregisters agree (or there are no
- // subregs at all). More analysis might recover some forwardable copies.
- if (!PostRA && (DbgMO.getSubReg() != SrcMO->getSubReg() ||
- DbgMO.getSubReg() != DstMO->getSubReg()))
- continue;
-
- // Post-regalloc, we may be sinking a DBG_VALUE of a sub or super-register
- // of this copy. Only forward the copy if the DBG_VALUE operand exactly
- // matches the copy destination.
- if (PostRA && DbgMO.getReg() != DstMO->getReg())
- continue;
-
- DbgMI->getOperand(0).setReg(SrcMO->getReg());
- DbgMI->getOperand(0).setSubReg(SrcMO->getSubReg());
+ SuccToSinkTo.splice(InsertPos, ParentBlock, DbgMI,
+ ++MachineBasicBlock::iterator(DbgMI));
}
}
OpenPOWER on IntegriCloud