From 339b1b5bb0f9aabed696cfbc42752e8ad3053302 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Tue, 1 Oct 2019 10:38:30 +0000 Subject: [PATCH] InstrProf - avoid static analyzer dyn_cast null dereference warning. The static analyzer is warning about a potential null dereference, as we're already earlying-out for a null Constant pointer I've just folded this into a dyn_cast_or_null. No test case, this is by inspection only. llvm-svn: 373322 --- llvm/lib/ProfileData/InstrProf.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index 510fd98..8cad686 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -1078,12 +1078,10 @@ bool isIRPGOFlagSet(const Module *M) { if (!IRInstrVar->hasInitializer()) return false; - const Constant *InitVal = IRInstrVar->getInitializer(); + auto *InitVal = dyn_cast_or_null(IRInstrVar->getInitializer()); if (!InitVal) return false; - - return (dyn_cast(InitVal)->getZExtValue() & - VARIANT_MASK_IR_PROF) != 0; + return (InitVal->getZExtValue() & VARIANT_MASK_IR_PROF) != 0; } // Check if we can safely rename this Comdat function. -- 2.7.4