Skip to content

Commit

Permalink
PGOMemOPSizeOpt - silence static analyzer dyn_cast<MemIntrinsic> null…
Browse files Browse the repository at this point in the history
… dereference warning. NFCI.

The static analyzer is warning about a potential null dereference, but we should be able to use cast<MemIntrinsic> directly and if not assert will fire for us.

llvm-svn: 372959
  • Loading branch information
RKSimon committed Sep 26, 2019
1 parent 93c8951 commit faa5b39
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ bool MemOPSizeOpt::perform(MemIntrinsic *MI) {
Ctx, Twine("MemOP.Case.") + Twine(SizeId), &Func, DefaultBB);
Instruction *NewInst = MI->clone();
// Fix the argument.
MemIntrinsic * MemI = dyn_cast<MemIntrinsic>(NewInst);
IntegerType *SizeType = dyn_cast<IntegerType>(MemI->getLength()->getType());
auto *MemI = cast<MemIntrinsic>(NewInst);
auto *SizeType = dyn_cast<IntegerType>(MemI->getLength()->getType());
assert(SizeType && "Expected integer type size argument.");
ConstantInt *CaseSizeId = ConstantInt::get(SizeType, SizeId);
MemI->setLength(CaseSizeId);
Expand Down

0 comments on commit faa5b39

Please sign in to comment.