[llvm] r212687 - Fix isDereferenceablePointer not to try to take the size of an unsized type.

Hal Finkel hfinkel at anl.gov
Wed Jul 9 23:06:11 PDT 2014


Author: hfinkel
Date: Thu Jul 10 01:06:11 2014
New Revision: 212687

URL: http://llvm.org/viewvc/llvm-project?rev=212687&view=rev
Log:
Fix isDereferenceablePointer not to try to take the size of an unsized type.

I'll add a test-case shortly.

Modified:
    llvm/trunk/lib/IR/Value.cpp

Modified: llvm/trunk/lib/IR/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Value.cpp?rev=212687&r1=212686&r2=212687&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Value.cpp (original)
+++ llvm/trunk/lib/IR/Value.cpp Thu Jul 10 01:06:11 2014
@@ -492,7 +492,8 @@ static bool isDereferenceablePointer(con
     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)))





More information about the llvm-commits mailing list