[llvm] 17b9a91 - [InstCombine] canRewriteGEPAsOffset - don't dereference a dyn_cast<>. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 6 06:49:30 PDT 2020
Author: Simon Pilgrim
Date: 2020-10-06T14:48:34+01:00
New Revision: 17b9a91ec274a527e734321701d2791368f146c9
URL: https://github.com/llvm/llvm-project/commit/17b9a91ec274a527e734321701d2791368f146c9
DIFF: https://github.com/llvm/llvm-project/commit/17b9a91ec274a527e734321701d2791368f146c9.diff
LOG: [InstCombine] canRewriteGEPAsOffset - don't dereference a dyn_cast<>. NFCI.
We know V is a IntToPtrInst or PtrToIntInst type so we know its a CastInst - so use cast<> directly.
Prevents clang static analyzer warning that we could deference a null pointer.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 7a7de4db8033..4f2d350d82cc 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -552,7 +552,7 @@ static bool canRewriteGEPAsOffset(Value *Start, Value *Base,
return false;
if (isa<IntToPtrInst>(V) || isa<PtrToIntInst>(V)) {
- auto *CI = dyn_cast<CastInst>(V);
+ auto *CI = cast<CastInst>(V);
if (!CI->isNoopCast(DL))
return false;
More information about the llvm-commits
mailing list