Check to make sure types are sized before calling getTypeSize on them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14649 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2004-07-06 19:28:42 +00:00
parent 08cc64ebfe
commit fae1010218

View File

@@ -2098,8 +2098,9 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
if (const PointerType *PTy = dyn_cast<PointerType>(CI.getType())) {
// Get the type really allocated and the type casted to...
const Type *AllocElTy = AI->getAllocatedType();
unsigned AllocElTySize = TD->getTypeSize(AllocElTy);
const Type *CastElTy = PTy->getElementType();
if (AllocElTy->isSized() && CastElTy->isSized()) {
unsigned AllocElTySize = TD->getTypeSize(AllocElTy);
unsigned CastElTySize = TD->getTypeSize(CastElTy);
// If the allocation is for an even multiple of the cast type size
@@ -2116,6 +2117,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
return ReplaceInstUsesWith(CI, New);
}
}
}
// If the source value is an instruction with only this use, we can attempt to
// propagate the cast into the instruction. Also, only handle integral types