[InstCombine] canRewriteGEPAsOffset - don't dereference a dyn_cast<>. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 6 Oct 2020 12:52:25 +0000 (13:52 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 6 Oct 2020 13:48:34 +0000 (14:48 +0100)
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.

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

index 7a7de4d..4f2d350 100644 (file)
@@ -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;