[llvm] 353484d - [LowerExpectIntrinsic] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr. NFC
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 10 07:35:37 PST 2022
Author: Simon Pilgrim
Date: 2022-01-10T15:34:37Z
New Revision: 353484d191f6518e5f65b73f1d50db8cae0c1a6c
URL: https://github.com/llvm/llvm-project/commit/353484d191f6518e5f65b73f1d50db8cae0c1a6c
DIFF: https://github.com/llvm/llvm-project/commit/353484d191f6518e5f65b73f1d50db8cae0c1a6c.diff
LOG: [LowerExpectIntrinsic] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr. NFC
Added:
Modified:
llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
index 1c186e9a04889..a7eb60b5e0328 100644
--- a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
@@ -64,7 +64,7 @@ getBranchWeight(Intrinsic::ID IntrinsicID, CallInst *CI, int BranchCount) {
// __builtin_expect_with_probability
assert(CI->getNumOperands() >= 3 &&
"expect with probability must have 3 arguments");
- ConstantFP *Confidence = dyn_cast<ConstantFP>(CI->getArgOperand(2));
+ auto *Confidence = cast<ConstantFP>(CI->getArgOperand(2));
double TrueProb = Confidence->getValueAPF().convertToDouble();
assert((TrueProb >= 0.0 && TrueProb <= 1.0) &&
"probability value must be in the range [0.0, 1.0]");
More information about the llvm-commits
mailing list