[llvm] r266008 - CodeGen: Fix a use-after-free in TailDuplication

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 15:37:13 PDT 2016


Author: bogner
Date: Mon Apr 11 17:37:13 2016
New Revision: 266008

URL: http://llvm.org/viewvc/llvm-project?rev=266008&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/CodeGen/TailDuplicator.cpp

Modified: llvm/trunk/lib/CodeGen/TailDuplicator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplicator.cpp?rev=266008&r1=266007&r2=266008&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TailDuplicator.cpp (original)
+++ llvm/trunk/lib/CodeGen/TailDuplicator.cpp Mon Apr 11 17:37:13 2016
@@ -801,8 +801,6 @@ bool TailDuplicator::tailDuplicate(Machi
         // from PredBB.
         MachineInstr *MI = &*I++;
         processPHI(MI, TailBB, PrevBB, LocalVRMap, CopyInfos, UsedByPhi, true);
-        if (MI->getParent())
-          MI->eraseFromParent();
       }
 
       // Now copy the non-PHI instructions.




More information about the llvm-commits mailing list