Skip to content

Commit aeba58e

Browse files
committed
add safety check in case getVectorSplit fails.
1 parent 96f95a4 commit aeba58e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

llvm/lib/Transforms/Scalar/Scalarizer.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,9 @@ bool ScalarizerVisitor::isTriviallyScalarizable(Intrinsic::ID ID) {
700700
/// element if possible for the intrinsic.
701701
bool ScalarizerVisitor::splitCall(CallInst &CI) {
702702
Type *CallType = CI.getType();
703-
bool AreAllVectors = isStructOfMatchingFixedVectors(CallType);
703+
bool AreAllMatchingVectors = isStructOfMatchingFixedVectors(CallType);
704704
std::optional<VectorSplit> VS;
705-
if (AreAllVectors)
705+
if (AreAllMatchingVectors)
706706
VS = getVectorSplit(CallType->getContainedType(0));
707707
else
708708
VS = getVectorSplit(CallType);
@@ -730,12 +730,17 @@ bool ScalarizerVisitor::splitCall(CallInst &CI) {
730730
if (isVectorIntrinsicWithOverloadTypeAtArg(ID, -1))
731731
Tys.push_back(VS->SplitTy);
732732

733-
if (AreAllVectors) {
733+
if (AreAllMatchingVectors) {
734734
Type *PrevType = CallType->getContainedType(0);
735735
for (unsigned I = 1; I < CallType->getNumContainedTypes(); I++) {
736736
Type *CurrType = cast<FixedVectorType>(CallType->getContainedType(I));
737737
if (PrevType != CurrType) {
738738
std::optional<VectorSplit> CurrVS = getVectorSplit(CurrType);
739+
// This case does not seem to happen, but it is possible for
740+
// VectorSplit.NumPacked >= NumElems. If that happens a VectorSplit
741+
// is not returned and we will bailout of handling this call.
742+
if (!CurrVS)
743+
return false;
739744
Tys.push_back(CurrVS->SplitTy);
740745
PrevType = CurrType;
741746
}

0 commit comments

Comments
 (0)