diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2020-06-27 17:14:15 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2020-06-27 18:30:59 +0300 |
commit | f0634100cdc832605bff355330d2ccdb7f43842f (patch) | |
tree | deef2e0034453cfe7e994bcadae8e1f7c303975f /llvm/lib/Analysis/Loads.cpp | |
parent | 74dc081ef2d830a7fbff68b230176f874f741897 (diff) | |
download | llvm-f0634100cdc832605bff355330d2ccdb7f43842f.zip llvm-f0634100cdc832605bff355330d2ccdb7f43842f.tar.gz llvm-f0634100cdc832605bff355330d2ccdb7f43842f.tar.bz2 |
[Analysis] isDereferenceableAndAlignedPointer(): don't crash on `bitcast <1 x ???*> to ???*`
Diffstat (limited to 'llvm/lib/Analysis/Loads.cpp')
-rw-r--r-- | llvm/lib/Analysis/Loads.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp index e138f19..e524522 100644 --- a/llvm/lib/Analysis/Loads.cpp +++ b/llvm/lib/Analysis/Loads.cpp @@ -41,6 +41,7 @@ static bool isDereferenceableAndAlignedPointer( const Value *V, Align Alignment, const APInt &Size, const DataLayout &DL, const Instruction *CtxI, const DominatorTree *DT, SmallPtrSetImpl<const Value *> &Visited, unsigned MaxDepth) { + assert(V->getType()->isPointerTy() && "Base must be pointer"); // Recursion limit. if (MaxDepth-- == 0) @@ -54,10 +55,11 @@ static bool isDereferenceableAndAlignedPointer( // malloc may return null. // bitcast instructions are no-ops as far as dereferenceability is concerned. - if (const BitCastOperator *BC = dyn_cast<BitCastOperator>(V)) - return isDereferenceableAndAlignedPointer(BC->getOperand(0), Alignment, - Size, DL, CtxI, DT, Visited, - MaxDepth); + if (const BitCastOperator *BC = dyn_cast<BitCastOperator>(V)) { + if (BC->getSrcTy()->isPointerTy()) + return isDereferenceableAndAlignedPointer( + BC->getOperand(0), Alignment, Size, DL, CtxI, DT, Visited, MaxDepth); + } bool CheckForNonNull = false; APInt KnownDerefBytes(Size.getBitWidth(), |