[llvm] r277614 - [CloneFunction] Don't crash if the value map doesn't hold something

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 10:37:10 PDT 2016


Author: majnemer
Date: Wed Aug  3 12:37:10 2016
New Revision: 277614

URL: http://llvm.org/viewvc/llvm-project?rev=277614&view=rev
Log:
[CloneFunction] Don't crash if the value map doesn't hold something

It is possible for the value map to not have an entry for some value
that has already been removed.

I don't have a testcase, this is fall-out from a buildbot.

Modified:
    llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp

Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=277614&r1=277613&r2=277614&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Wed Aug  3 12:37:10 2016
@@ -562,7 +562,7 @@ void llvm::CloneAndPruneIntoFromInst(Fun
   // Note that we must test the size on each iteration, the worklist can grow.
   for (unsigned Idx = 0; Idx != Worklist.size(); ++Idx) {
     const Value *OrigV = Worklist[Idx];
-    auto *I = cast<Instruction>(VMap.lookup(OrigV));
+    auto *I = cast_or_null<Instruction>(VMap.lookup(OrigV));
     if (!I)
       continue;
 




More information about the llvm-commits mailing list