This is an archive of the discontinued LLVM Phabricator instance.

[SLP] Fix crash on attempt to access on invalid iterator state.
ClosedPublic

Authored by vdmitrie on Jun 29 2023, 6:36 PM.

Details

Summary

The patch fixes corner case when no of scalar instructions
required scheduling for vectorized node.

Diff Detail

Event Timeline

vdmitrie created this revision.Jun 29 2023, 6:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2023, 6:36 PM
vdmitrie requested review of this revision.Jun 29 2023, 6:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2023, 6:36 PM

Could you try this one instead:

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 82563091f7ce..84c30da74d3d 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -9074,8 +9074,8 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {

   // Set the insert point to the beginning of the basic block if the entry
   // should not be scheduled.
-  if (E->State != TreeEntry::NeedToGather &&
-      (doesNotNeedToSchedule(E->Scalars) ||
+  if (doesNotNeedToSchedule(E->Scalars) ||
+      (E->State != TreeEntry::NeedToGather &&
        all_of(E->Scalars, isVectorLikeInstWithConstOps))) {
     Instruction *InsertInst;
     if ((E->getOpcode() == Instruction::GetElementPtr &&
vdmitrie updated this revision to Diff 536331.Jun 30 2023, 11:23 AM

alternative approach to fix the issue

This revision is now accepted and ready to land.Jun 30 2023, 11:28 AM
This revision was landed with ongoing or failed builds.Jun 30 2023, 11:40 AM
This revision was automatically updated to reflect the committed changes.