Forgot dyn_cast check.
authorEvan Cheng <evan.cheng@apple.com>
Tue, 24 May 2011 23:47:50 +0000 (23:47 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 24 May 2011 23:47:50 +0000 (23:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132025 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopUnswitch.cpp

index 9761d682978772bd7c7ceed9590d19d989a790e6..a33e7956433c5c161336361b05cf32af80848d2e 100644 (file)
@@ -881,8 +881,8 @@ void LoopUnswitch::RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC,
     
     for (Value::use_iterator UI = LIC->use_begin(), E = LIC->use_end();
          UI != E; ++UI) {
-      Instruction *U = cast<Instruction>(*UI);
-      if (!L->contains(U))
+      Instruction *U = dyn_cast<Instruction>(*UI);
+      if (!U || !L->contains(U))
         continue;
       U->replaceUsesOfWith(LIC, Replacement);
       Worklist.push_back(U);
@@ -896,8 +896,8 @@ void LoopUnswitch::RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC,
   // can.  This case occurs when we unswitch switch statements.
   for (Value::use_iterator UI = LIC->use_begin(), E = LIC->use_end();
        UI != E; ++UI) {
-    Instruction *U = cast<Instruction>(*UI);
-    if (!L->contains(U))
+    Instruction *U = dyn_cast<Instruction>(*UI);
+    if (!U || !L->contains(U))
       continue;
 
     Worklist.push_back(U);