[llvm] ed57789 - Use cast<> instead of dyn_cast<> as we dereference the pointers immediately. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 30 08:22:11 PDT 2020
Author: Simon Pilgrim
Date: 2020-10-30T15:20:40Z
New Revision: ed577892cf99cced0430c7ecdc9e16f5e76a460b
URL: https://github.com/llvm/llvm-project/commit/ed577892cf99cced0430c7ecdc9e16f5e76a460b
DIFF: https://github.com/llvm/llvm-project/commit/ed577892cf99cced0430c7ecdc9e16f5e76a460b.diff
LOG: Use cast<> instead of dyn_cast<> as we dereference the pointers immediately. NFCI.
Fix clang static analyzer warnings - we're better off relying on cast<> asserting on failure rather than a null dereference crash.
Added:
Modified:
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index df100d85f32c..877495be2dcd 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -2368,11 +2368,10 @@ bool SCEVExpander::isHighCostExpansionHelper(
// Assume to be zero-cost.
return false;
case scConstant: {
- auto *Constant = dyn_cast<SCEVConstant>(S);
// Only evalulate the costs of constants when optimizing for size.
if (CostKind != TargetTransformInfo::TCK_CodeSize)
return 0;
- const APInt &Imm = Constant->getAPInt();
+ const APInt &Imm = cast<SCEVConstant>(S)->getAPInt();
Type *Ty = S->getType();
BudgetRemaining -= TTI.getIntImmCostInst(
WorkItem.ParentOpcode, WorkItem.OperandIdx, Imm, Ty, CostKind);
@@ -2412,7 +2411,7 @@ bool SCEVExpander::isHighCostExpansionHelper(
case scSMaxExpr:
case scUMinExpr:
case scSMinExpr: {
- assert(dyn_cast<SCEVNAryExpr>(S)->getNumOperands() > 1 &&
+ assert(cast<SCEVNAryExpr>(S)->getNumOperands() > 1 &&
"Nary expr should have more than 1 operand.");
// The simple nary expr will require one less op (or pair of ops)
// than the number of it's terms.
More information about the llvm-commits
mailing list