Skip to content

Commit 95ea694

Browse files
authored
Merge pull request #17365 from gottesmm/pr-7ec9e4bb93722d95c4f6c047f667b898b8cdb45a
2 parents 8628f0a + 9bba338 commit 95ea694

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
@@ -843,6 +843,24 @@ createProjection(SILBuilder &B, SILLocation Loc, SILValue Arg) const {
843843
return Proj->createProjection(B, Loc, Arg);
844844
}
845845

846+
// Projection tree only supports structs and tuples today.
847+
static bool isSupportedProjection(const Projection &p) {
848+
switch (p.getKind()) {
849+
case ProjectionKind::Struct:
850+
case ProjectionKind::Tuple:
851+
return true;
852+
case ProjectionKind::Class:
853+
case ProjectionKind::Enum:
854+
case ProjectionKind::Box:
855+
case ProjectionKind::Upcast:
856+
case ProjectionKind::RefCast:
857+
case ProjectionKind::BitwiseCast:
858+
case ProjectionKind::TailElems:
859+
case ProjectionKind::Index:
860+
return false;
861+
}
862+
}
863+
846864
void
847865
ProjectionTreeNode::
848866
processUsersOfValue(ProjectionTree &Tree,
@@ -866,12 +884,11 @@ processUsersOfValue(ProjectionTree &Tree,
866884
continue;
867885
}
868886

869-
// Check whether the user is such a projection.
870887
auto P = Projection(projectionInst);
871888

872-
// If we fail to create a projection, add User as a user to this node and
873-
// continue.
874-
if (!P.isValid()) {
889+
// If we fail to create a projection or this is a type of projection that we
890+
// do not support, add User as a user to this node and continue.
891+
if (!P.isValid() || !isSupportedProjection(P)) {
875892
DEBUG(llvm::dbgs() << " Failed to create projection. Adding "
876893
"to non projection user!\n");
877894
addNonProjectionUser(Op);

0 commit comments

Comments
 (0)