CodeGen: Fix a use-after-free in TailDuplication

The call to processPHI already erased MI from its parent, so MI isn't
even valid here, making the getParent() call a use-after-free in
addition to being redundant.

Found by ASan with the ArrayRecycler changes in llvm.org/pr26808.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266008 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Justin Bogner 2016-04-11 22:37:13 +00:00
parent eb5d561d4c
commit b4aa9bf76e

View File

@ -801,8 +801,6 @@ bool TailDuplicator::tailDuplicate(MachineFunction &MF, bool IsSimple,
// from PredBB.
MachineInstr *MI = &*I++;
processPHI(MI, TailBB, PrevBB, LocalVRMap, CopyInfos, UsedByPhi, true);
if (MI->getParent())
MI->eraseFromParent();
}
// Now copy the non-PHI instructions.