Check void type before using RAUWd.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84049 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index 07ee071..a217a32 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -781,7 +781,10 @@
     
     // Anything that uses the instructions in this basic block should have their
     // uses replaced with undefs.
-    I->replaceAllUsesWith(UndefValue::get(I->getType()));
+    // If I is not void type then replaceAllUsesWith undef.
+    // This allows ValueHandlers and custom metadata to adjust itself.
+    if (I->getType() != Type::getVoidTy(I->getContext()))
+      I->replaceAllUsesWith(UndefValue::get(I->getType()));
   }
   
   // If this is the edge to the header block for a loop, remove the loop and