[MachineCombiner][NFC] Prevent dereferencing past-the-end object in an MRI container

llvm-svn: 350896
This commit is contained in:
Gerolf Hoflehner 2019-01-10 21:53:13 +00:00
parent e41f4b39e5
commit cb7d968f73
1 changed files with 2 additions and 0 deletions

View File

@ -231,6 +231,8 @@ unsigned MachineCombiner::getLatency(MachineInstr *Root, MachineInstr *NewRoot,
// Get the first instruction that uses MO
MachineRegisterInfo::reg_iterator RI = MRI->reg_begin(MO.getReg());
RI++;
if (RI == MRI->reg_end())
continue;
MachineInstr *UseMO = RI->getParent();
unsigned LatencyOp = 0;
if (UseMO && BlockTrace.isDepInTrace(*Root, *UseMO)) {