From: Chris Lattner Date: Fri, 2 Jul 2004 22:55:47 +0000 (+0000) Subject: Do not call getTypeSize on a type that has no size X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cf27afb64e3387a747a467072536df8259488213;p=oota-llvm.git Do not call getTypeSize on a type that has no size git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14584 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 28e2eec0b41..bf571194864 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -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(AI) && TD->getTypeSize(AI.getAllocatedType()) == 0) + if (isa(AI) && AI.getAllocatedType()->isSized() && + TD->getTypeSize(AI.getAllocatedType()) == 0) return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType())); return 0;