Fix PR905 and InstCombine/2006-09-11-EmptyStructCrash.ll
authorChris Lattner <sabre@nondot.org>
Mon, 11 Sep 2006 21:43:16 +0000 (21:43 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 11 Sep 2006 21:43:16 +0000 (21:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30266 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 0e6c1b1f2dda1b06278c156bf2b8879bb72ce64c..6961806bcb79b05d8ff37c0c5bb5869dbb7e7c1d 100644 (file)
@@ -5187,7 +5187,8 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
       Constant *ZeroUInt = Constant::getNullValue(Type::UIntTy);
       unsigned NumZeros = 0;
       while (SrcTy != DstTy && 
-             isa<CompositeType>(SrcTy) && !isa<PointerType>(SrcTy)) {
+             isa<CompositeType>(SrcTy) && !isa<PointerType>(SrcTy) &&
+             SrcTy->getNumContainedTypes() /* not "{}" */) {
         SrcTy = cast<CompositeType>(SrcTy)->getTypeAtIndex(ZeroUInt);
         ++NumZeros;
       }