From 66e23f126d0ffe97f973903de45088ed22552b9e 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. llvm-svn: 212687 --- llvm/lib/IR/Value.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index d61b8e5..35c241a 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/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.7.4