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
This commit is contained in:
Chris Lattner 2004-07-02 22:55:47 +00:00
parent 7283e7c056
commit cf27afb64e

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.
// 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;