From c3bbc8a9c777995310c5e45b94de60e4527287c7 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Mon, 11 Apr 2016 22:37:13 +0000 Subject: [PATCH] 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. llvm-svn: 266008 --- lib/CodeGen/TailDuplicator.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/CodeGen/TailDuplicator.cpp b/lib/CodeGen/TailDuplicator.cpp index 7929d87d880..1ea15afc170 100644 --- a/lib/CodeGen/TailDuplicator.cpp +++ b/lib/CodeGen/TailDuplicator.cpp @@ -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.