Do not call getTypeSize on a type that has no size
authorChris Lattner <sabre@nondot.org>
Fri, 2 Jul 2004 22:55:47 +0000 (22:55 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 2 Jul 2004 22:55:47 +0000 (22:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14584 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 28e2eec0b41e5736c1654c2642dd23f886c7f5ec..bf5711948640f2ee89d797ce1e753cf16952e837 100644 (file)
@@ -2854,7 +2854,8 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
   // If alloca'ing a zero byte object, replace the alloca with a null pointer.
   // Note that we only do this for alloca's, because malloc should allocate and
   // return a unique pointer, even for a zero byte allocation.
-  if (isa<AllocaInst>(AI) && TD->getTypeSize(AI.getAllocatedType()) == 0)
+  if (isa<AllocaInst>(AI) && AI.getAllocatedType()->isSized() && 
+      TD->getTypeSize(AI.getAllocatedType()) == 0)
     return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType()));
 
   return 0;