Skip to content

Commit 339b1b5

Browse files
committed
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
1 parent d71315f commit 339b1b5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,12 +1078,10 @@ bool isIRPGOFlagSet(const Module *M) {
10781078
if (!IRInstrVar->hasInitializer())
10791079
return false;
10801080

1081-
const Constant *InitVal = IRInstrVar->getInitializer();
1081+
auto *InitVal = dyn_cast_or_null<ConstantInt>(IRInstrVar->getInitializer());
10821082
if (!InitVal)
10831083
return false;
1084-
1085-
return (dyn_cast<ConstantInt>(InitVal)->getZExtValue() &
1086-
VARIANT_MASK_IR_PROF) != 0;
1084+
return (InitVal->getZExtValue() & VARIANT_MASK_IR_PROF) != 0;
10871085
}
10881086

10891087
// Check if we can safely rename this Comdat function.

0 commit comments

Comments
 (0)