Do not call getTypeSize on a type that has no size

llvm-svn: 14584
This commit is contained in:
Chris Lattner 2004-07-02 22:55:47 +00:00
parent 6a3e24fcdd
commit 1120899069

View File

@ -2854,7 +2854,8 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
// If alloca'ing a zero byte object, replace the alloca with a null pointer. // 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 // Note that we only do this for alloca's, because malloc should allocate and
// return a unique pointer, even for a zero byte allocation. // 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 ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType()));
return 0; return 0;