Skip to content

Commit db2e63d

Browse files
authored
Merge pull request #17597 from gottesmm/swift-4.2-branch-projtree-crasher
[4.2][projection] Add non-supported projection users to the non projection…
2 parents e3223eb + 67a5ed0 commit db2e63d

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

lib/SIL/Projection.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,24 @@ createProjection(SILBuilder &B, SILLocation Loc, SILValue Arg) const {
840840
return Proj->createProjection(B, Loc, Arg);
841841
}
842842

843+
// Projection tree only supports structs and tuples today.
844+
static bool isSupportedProjection(const Projection &p) {
845+
switch (p.getKind()) {
846+
case ProjectionKind::Struct:
847+
case ProjectionKind::Tuple:
848+
return true;
849+
case ProjectionKind::Class:
850+
case ProjectionKind::Enum:
851+
case ProjectionKind::Box:
852+
case ProjectionKind::Upcast:
853+
case ProjectionKind::RefCast:
854+
case ProjectionKind::BitwiseCast:
855+
case ProjectionKind::TailElems:
856+
case ProjectionKind::Index:
857+
return false;
858+
}
859+
}
860+
843861
void
844862
ProjectionTreeNode::
845863
processUsersOfValue(ProjectionTree &Tree,
@@ -863,12 +881,11 @@ processUsersOfValue(ProjectionTree &Tree,
863881
continue;
864882
}
865883

866-
// Check whether the user is such a projection.
867884
auto P = Projection(projectionInst);
868885

869-
// If we fail to create a projection, add User as a user to this node and
870-
// continue.
871-
if (!P.isValid()) {
886+
// If we fail to create a projection or this is a type of projection that we
887+
// do not support, add User as a user to this node and continue.
888+
if (!P.isValid() || !isSupportedProjection(P)) {
872889
DEBUG(llvm::dbgs() << " Failed to create projection. Adding "
873890
"to non projection user!\n");
874891
addNonProjectionUser(Op);

0 commit comments

Comments
 (0)