[llvm] f3f3883 - [RISCV] Fix crash reported in https://github.com/llvm/llvm-project/issues/109313
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 11:22:45 PDT 2024
Author: Philip Reames
Date: 2024-09-19T11:22:39-07:00
New Revision: f3f3883f4b9d15770a5ce49956ed4425c71ad69f
URL: https://github.com/llvm/llvm-project/commit/f3f3883f4b9d15770a5ce49956ed4425c71ad69f
DIFF: https://github.com/llvm/llvm-project/commit/f3f3883f4b9d15770a5ce49956ed4425c71ad69f.diff
LOG: [RISCV] Fix crash reported in https://github.com/llvm/llvm-project/issues/109313
Change edc71e22c004d3b3dfc535f7917ea0b47a282ac8 had tried to handle the case
where an instruction wasn't available, but had used a dyn_cast instead of
a dyn_cast_or_null. Switch instead to an explicit null check, and a cast.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 152ddeb52907d0..c850b91a410927 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -1051,13 +1051,12 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
// vp load/store
case Intrinsic::vp_load:
case Intrinsic::vp_store: {
+ if (!ICA.getInst())
+ break;
Intrinsic::ID IID = ICA.getID();
std::optional<unsigned> FOp = VPIntrinsic::getFunctionalOpcodeForVP(IID);
- auto *UI = dyn_cast<VPIntrinsic>(ICA.getInst());
-
- if (!UI)
- break;
assert(FOp.has_value());
+ auto *UI = cast<VPIntrinsic>(ICA.getInst());
if (ICA.getID() == Intrinsic::vp_load)
return getMemoryOpCost(
*FOp, ICA.getReturnType(), UI->getPointerAlignment(),
More information about the llvm-commits
mailing list