summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2019-10-01 10:38:30 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2019-10-01 10:38:30 +0000
commit339b1b5bb0f9aabed696cfbc42752e8ad3053302 (patch)
treec7404209d327d13da08357c96c1aef5b8e30895b /llvm/lib
parentd71315f2ae8a14ca4b55f316ab00faf56c4f6208 (diff)
downloadbcm5719-llvm-339b1b5bb0f9aabed696cfbc42752e8ad3053302.tar.gz
bcm5719-llvm-339b1b5bb0f9aabed696cfbc42752e8ad3053302.zip
InstrProf - avoid static analyzer dyn_cast<ConstantInt> 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<ConstantInt>. No test case, this is by inspection only. llvm-svn: 373322
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ProfileData/InstrProf.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 510fd9887d9..8cad6861b33 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<ConstantInt>(IRInstrVar->getInitializer());
if (!InitVal)
return false;
-
- return (dyn_cast<ConstantInt>(InitVal)->getZExtValue() &
- VARIANT_MASK_IR_PROF) != 0;
+ return (InitVal->getZExtValue() & VARIANT_MASK_IR_PROF) != 0;
}
// Check if we can safely rename this Comdat function.
OpenPOWER on IntegriCloud