Skip to content

Commit cececf5

Browse files
committed
[VPlan] Use correct constructor when cloning VPWidenIntrinsicRecipe without underlying CallInst
I noticed this when working on a patch downstream, and I don't think this is an issue upstream yet. But if a VPWidenIntrinsicRecipe is created without an underlying CallInst, e.g. in createEVLRecipe, it will crash if you try to clone it because it assumes the CallInst always exists. This fixes it by using the CallInst-less constructor in this case.
1 parent f218cd2 commit cececf5

File tree

1 file changed

+7
-3
lines changed
  • llvm/lib/Transforms/Vectorize

1 file changed

+7
-3
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,9 +1347,13 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
13471347
~VPWidenIntrinsicRecipe() override = default;
13481348

13491349
VPWidenIntrinsicRecipe *clone() override {
1350-
return new VPWidenIntrinsicRecipe(*cast<CallInst>(getUnderlyingValue()),
1351-
VectorIntrinsicID, {op_begin(), op_end()},
1352-
ResultTy, getDebugLoc());
1350+
if (auto *CI = getUnderlyingValue())
1351+
return new VPWidenIntrinsicRecipe(*cast<CallInst>(CI), VectorIntrinsicID,
1352+
{op_begin(), op_end()}, ResultTy,
1353+
getDebugLoc());
1354+
else
1355+
return new VPWidenIntrinsicRecipe(
1356+
VectorIntrinsicID, {op_begin(), op_end()}, ResultTy, getDebugLoc());
13531357
}
13541358

13551359
VP_CLASSOF_IMPL(VPDef::VPWidenIntrinsicSC)

0 commit comments

Comments
 (0)