Fix isDereferenceablePointer not to try to take the size of an unsized type.
authorHal Finkel <hfinkel@anl.gov>
Thu, 10 Jul 2014 06:06:11 +0000 (06:06 +0000)
committerHal Finkel <hfinkel@anl.gov>
Thu, 10 Jul 2014 06:06:11 +0000 (06:06 +0000)
I'll add a test-case shortly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212687 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Value.cpp

index d61b8e52ea8f18cf4b46a2d9917f67381f007de2..35c241a608ba78fcba9efa512a30fc27a5d1d697 100644 (file)
@@ -492,7 +492,8 @@ static bool isDereferenceablePointer(const Value *V, const DataLayout *DL,
     if (const BitCastInst* BC = dyn_cast<BitCastInst>(V)) {
       Type *STy = BC->getSrcTy()->getPointerElementType(),
            *DTy = BC->getDestTy()->getPointerElementType();
-      if ((DL->getTypeStoreSize(STy) >=
+      if (STy->isSized() && DTy->isSized() &&
+          (DL->getTypeStoreSize(STy) >=
            DL->getTypeStoreSize(DTy)) &&
           (DL->getABITypeAlignment(STy) >=
            DL->getABITypeAlignment(DTy)))