Skip to content

Commit 825def9

Browse files
lukel97IanWood1
authored andcommitted
[VPlan] Use correct constructor when cloning VPWidenIntrinsicRecipe without underlying CallInst (llvm#137493)
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 a4f3be8 commit 825def9

File tree

1 file changed

+5
-2
lines changed
  • llvm/lib/Transforms/Vectorize

1 file changed

+5
-2
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,8 +1351,11 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
13511351
~VPWidenIntrinsicRecipe() override = default;
13521352

13531353
VPWidenIntrinsicRecipe *clone() override {
1354-
return new VPWidenIntrinsicRecipe(*cast<CallInst>(getUnderlyingValue()),
1355-
VectorIntrinsicID, {op_begin(), op_end()},
1354+
if (Value *CI = getUnderlyingValue())
1355+
return new VPWidenIntrinsicRecipe(*cast<CallInst>(CI), VectorIntrinsicID,
1356+
{op_begin(), op_end()}, ResultTy,
1357+
getDebugLoc());
1358+
return new VPWidenIntrinsicRecipe(VectorIntrinsicID, {op_begin(), op_end()},
13561359
ResultTy, getDebugLoc());
13571360
}
13581361

0 commit comments

Comments
 (0)