From 5ee0267e4931378841066abc7aa8dec7f1d82abb Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Thu, 10 Jul 2014 06:06:11 +0000 Subject: [PATCH] Fix isDereferenceablePointer not to try to take the size of an unsized type. 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/IR/Value.cpp b/lib/IR/Value.cpp index d61b8e52ea8..35c241a608b 100644 --- a/lib/IR/Value.cpp +++ b/lib/IR/Value.cpp @@ -492,7 +492,8 @@ static bool isDereferenceablePointer(const Value *V, const DataLayout *DL, if (const BitCastInst* BC = dyn_cast(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))) -- 2.11.0